- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章R语言多元Logistic逻辑回归应用实例由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
可以使用逐步过程确定多元逻辑回归。此函数选择模型以最小化AIC.
可以使用阶梯函数通过逐步过程确定多元逻辑回归。此函数选择模型以最小化AIC.
通常建议不要盲目地遵循逐步程序,而是要使用拟合统计(AIC,AICc,BIC)比较模型,或者根据生物学或科学上合理的可用变量建立模型.
多元相关是研究潜在自变量之间关系的一种工具。例如,如果两个独立变量彼此相关,可能在最终模型中都不需要这两个变量,但可能有理由选择一个变量而不是另一个变量.
创建数值变量的数据框 。
Data.num $ Status = as.numeric(Data.num $ Status)Data.num $ Length = as.numeric(Data.num $ Length)Data.num $ Migr = as.numeric(Data.num $ Migr)Data.num $ Insect = as.numeric(Data.num $ Insect)Data.num $ Diet = as.numeric(Data.num $ Diet)Data.num $ Broods = as.numeric(Data.num $ Broods)Data。 num $ Wood = as.numeric(Data.num $ Wood)Data.num $ Upland = as.numeric(Data.num $ Upland)Data.num $ Water = as.numeric(Data.num $ Water)Data.num $ Release = as.numeric(Data.num $ Release)Data.num $ Indiv = as.numeric(Data.num $ Indiv)###检查新数据框headtail(Data.num)1 1 1520 9600.0 1.21 1 12 2 6.0 1 0 0 1 6 292 1 1250 5000.0 0.56 1 0 1 6.0 1 0 0 1 10 853 1 870 3360.0 0.07 1 0 1 4.0 1 0 0 1 3 877 0 170 31.0 0.55 3 12 2 4.0 NA 1 0 0 1 278 0 210 36.9 2.00 2 8 2 3.7 1 0 0 1 1 279 0 225 106.5 1.20 2 12 2 4.8 2 0 0 0 1 2###检查变量之间的相关性###这里使用了Spearman相关性
在此示例中,数据包含缺失值。在R中缺失值用NA表示。SAS通常会无缝地处理缺失值。虽然这使用户更容易,但可能无法确保用户了解这些缺失值的作用。在某些情况下,R要求用户明确如何处理缺失值。处理多元回归中的缺失值的一种方法是从数据集中删除具有任何缺失值的所有观察值。这是我们在逐步过程之前要做的事情,创建一个名为Data.omit的数据框。但是,当我们创建最终模型时,我们只想排除那些在最终模型中实际包含的变量中具有缺失值的观察。为了测试最终模型的整体p值,绘制最终模型,或使用glm.compare函数,我们将创建一个名为Data.final的数据框,只排除那些观察结果.
尽管二项式和poission系列中的模型应该没问题,但是对于使用某些glm拟合的步骤过程存在一些注意事项.
最终模型 。
summary(model.final)Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -3.5496482 2.0827400 -1.704 0.088322 . Upland -4.5484289 2.0712502 -2.196 0.028093 * Migr -1.8184049 0.8325702 -2.184 0.028956 * Mass 0.0019029 0.0007048 2.700 0.006940 **Indiv 0.0137061 0.0038703 3.541 0.000398 ***Insect 0.2394720 0.1373456 1.744 0.081234 . Wood 1.8134445 1.3105911 1.384 0.166455
伪R方 。
$Pseudo.R.squared.for.model.vs.null Pseudo.R.squaredMcFadden 0.700475Cox and Snell (ML) 0.637732Nagelkerke (Cragg and Uhler) 0.833284
在最终模型中创建包含变量的数据框,并省略NA.
Analysis of Deviance TableModel 1: Status ~ Upland + Migr + Mass + Indiv + Insect + WoodModel 2: Status ~ 1Resid. Df Resid. Dev Df Deviance Pr(>Chi) 1 63 30.392 2 69 93.351 -6 -62.959 1.125e-11 ***
Likelihood ratio test#Df LogLik Df Chisq Pr(>Chisq) 1 7 -15.196 2 1 -46.675 -6 62.959 1.125e-11 ***
在最终模型中创建包含变量的数据框,并在NA中省略 。
过度离散是glm的deviance残差相对于自由度较大的情况。这些值显示在模型的摘要中。一个指导原则是,如果deviance残差与剩余自由度的比率超过1.5,则模型过度离散。过度离散表明模型不能很好地拟合数据:解释变量可能无法很好地描述因变量,或者可能无法为这些数据正确指定模型。如果存在过度离散,一种可能的解决方案是 在glm中使用quasibinomial family选项.
Null deviance: 93.351 on 69 degrees of freedomResidual deviance: 30.392 on 63 degrees of freedomdeviance / df.residual[1] 0.482417
使用逐步程序的替代或补充是将模型与拟合统计进行比较。我的compare.glm 函数将为glm模型显示AIC,AICc,BIC和伪R平方。使用的模型应该都拟合相同的数据。也就是说,如果数据集中的不同变量包含缺失值,则应该谨慎使用。如果您对使用哪种拟合统计数据没有任何偏好,您希望在最终模型中使用较少的术语,我可能会推荐AICc或BIC.
一系列模型可以与标准的anova 功能进行比较。模型应嵌套在先前模型中或anova函数列表中的下一个模型中; 和模型应该拟合相同的数据。在比较多个回归模型时,通常放宽p值为0.10或0.15.
在以下示例中,使用通过逐步过程选择的模型。请注意,虽然模型9最小化了AIC和AICc,但模型8最小化了BIC。anova结果表明模型8不是对模型7的显着改进。这些结果支持选择模型7,8或9中的任何一个.
compareGLM(model.1, model.2, model.3, model.4, model.5, model.6, model.7, model.8, model.9)$ModelsFormula 1 "Status ~ 1" 2 "Status ~ Release" 3 "Status ~ Release + Upland" 4 "Status ~ Release + Upland + Migr" 5 "Status ~ Release + Upland + Migr + Mass" 6 "Status ~ Release + Upland + Migr + Mass + Indiv" 7 "Status ~ Release + Upland + Migr + Mass + Indiv + Insect"8 "Status ~ Upland + Migr + Mass + Indiv + Insect" 9 "Status ~ Upland + Migr + Mass + Indiv + Insect + Wood" $Fit.criteriaRank Df.res AIC AICc BIC McFadden Cox.and.Snell Nagelkerke p.value1 1 66 94.34 94.53 98.75 0.0000 0.0000 0.0000 Inf2 2 65 62.13 62.51 68.74 0.3787 0.3999 0.5401 2.538e-093 3 64 56.02 56.67 64.84 0.4684 0.4683 0.6325 3.232e-104 4 63 51.63 52.61 62.65 0.5392 0.5167 0.6979 7.363e-115 5 62 50.64 52.04 63.87 0.5723 0.5377 0.7263 7.672e-116 6 61 49.07 50.97 64.50 0.6118 0.5618 0.7588 5.434e-117 7 60 46.42 48.90 64.05 0.6633 0.5912 0.7985 2.177e-118 6 61 44.71 46.61 60.14 0.6601 0.5894 0.7961 6.885e-129 7 60 44.03 46.51 61.67 0.6897 0.6055 0.8178 7.148e-12Analysis of Deviance TableModel 1: Status ~ 1Model 2: Status ~ ReleaseModel 3: Status ~ Release + UplandModel 4: Status ~ Release + Upland + MigrModel 5: Status ~ Release + Upland + Migr + MassModel 6: Status ~ Release + Upland + Migr + Mass + IndivModel 7: Status ~ Release + Upland + Migr + Mass + Indiv + InsectModel 8: Status ~ Upland + Migr + Mass + Indiv + InsectModel 9: Status ~ Upland + Migr + Mass + Indiv + Insect + WoodResid. Df Resid. Dev Df Deviance Pr(>Chi) 1 66 90.343 2 65 56.130 1 34.213 4.94e-09 ***3 64 48.024 1 8.106 0.004412 **4 63 41.631 1 6.393 0.011458 * 5 62 38.643 1 2.988 0.083872 . 6 61 35.070 1 3.573 0.058721 . 7 60 30.415 1 4.655 0.030970 * 8 61 30.710 -1 -0.295 0.587066 9 60 28.031 1 2.679 0.101686
到此这篇关于R语言多元Logistic逻辑回归应用的文章就介绍到这了,更多相关R语言多元逻辑回归内容请搜索我以前的文章或继续浏览下面的相关文章希望大家以后多多支持我! 。
原文链接:https://blog.csdn.net/qq_19600291/article/details/82791313 。
最后此篇关于R语言多元Logistic逻辑回归应用实例的文章就讲到这里了,如果你想了解更多关于R语言多元Logistic逻辑回归应用实例的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
至少在某些 ML 系列语言中,您可以定义可以执行模式匹配的记录,例如http://learnyouahaskell.com/making-our-own-types-and-typeclasses -
这可能是其他人已经看到的一个问题,但我正在尝试寻找一种专为(或支持)并发编程而设计的语言,该语言可以在 .net 平台上运行。 我一直在 erlang 中进行辅助开发,以了解该语言,并且喜欢建立一个稳
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be
我正在寻找一种进程间通信工具,可以在相同或不同系统上运行的语言和/或环境之间使用。例如,它应该允许在 Java、C# 和/或 C++ 组件之间发送信号,并且还应该支持某种排队机制。唯一明显与环境和语言
我有一些以不同语言返回的文本。现在,客户端返回的文本格式为(en-us,又名美国英语): Stuff here to keep. -- Delete Here -- all of this below
问题:我希望在 R 中找到类似 findInterval 的函数,它为输入提供一个标量和一个表示区间起点的向量,并返回标量落入的区间的索引。例如在 R 中: findInterval(x = 2.6,
我是安卓新手。我正在尝试进行简单的登录 Activity ,但当我单击“登录”按钮时出现运行时错误。我认为我没有正确获取数据。我已经检查过,SQLite 中有一个与该 PK 相对应的数据。 日志猫。
大家好,感谢您帮助我。 我用 C# 制作了这个计算器,但遇到了一个问题。 当我添加像 5+5+5 这样的东西时,它给了我正确的结果,但是当我想减去两个以上的数字并且还想除或乘以两个以上的数字时,我没有
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 4 年前。 Improve th
这就是我所拥有的 #include #include void print(int a[], int size); void sort (int a[], int size); v
你好,我正在寻找我哪里做错了? #include #include int main(int argc, char *argv[]) { int account_on_the_ban
嘿,当我开始向数组输入数据时,我的代码崩溃了。该程序应该将数字读入数组,然后将新数字插入数组中,最后按升序排列所有内容。我不确定它出了什么问题。有人有建议吗? 这是我的代码 #include #in
我已经盯着这个问题好几个星期了,但我一无所获!它不起作用,我知道那么多,但我不知道为什么或出了什么问题。我确实知道开发人员针对我突出显示的行吐出了“错误:预期表达式”,但这实际上只是冰山一角。如果有人
我正在编写一个点对点聊天程序。在此程序中,客户端和服务器功能写入一个唯一的文件中。首先我想问一下我程序中的机制是否正确? I fork() two processes, one for client
基本上我需要找到一种方法来发现段落是否以句点 (.) 结束。 此时我已经可以计算给定文本的段落数,但我没有想出任何东西来检查它是否在句点内结束。 任何帮助都会帮助我,谢谢 char ch; FI
我的函数 save_words 接收 Armazena 和大小。 Armazena 是一个包含段落的动态数组,size 是数组的大小。在这个函数中,我想将单词放入其他称为单词的动态数组中。当我运行它时
我有一个结构 struct Human { char *name; struct location *location; int
我正在尝试缩进以下代码的字符串输出,但由于某种原因,我的变量不断从文件中提取,并且具有不同长度的噪声或空间(我不确定)。 这是我的代码: #include #include int main (v
我想让用户选择一个选项。所以我声明了一个名为 Choice 的变量,我希望它输入一个只能是 'M' 的 char 、'C'、'O' 或 'P'。 这是我的代码: char Choice; printf
我正在寻找一种解决方案,将定义和变量的值连接到数组中。我已经尝试过像这样使用 memcpy 但它不起作用: #define ADDRESS {0x00, 0x00, 0x00, 0x00, 0x0
我是一名优秀的程序员,十分优秀!