一次对多个变量进行 Wilcox 检验以找出哪些变量适合在模型中使用

问题描述

我对 R 非常陌生,我试图找到一个内置数据集来展示我的意思,但我失败了,所以我会尽力解释。

我有一个包含七个连续数值变量(身体测量值)和两个分类变量(年龄 - “成人”和“未成熟”,以及物种 - “RT”、“SS”和“CH”)的数据集。我想知道对于七个不同的连续数值变量,三个物种之间的成年和未成熟动物之间是否存在显着差异。每一行都是一个单独的动物。

到目前为止,我能想到的唯一方法是为三个物种中的每一个创建单独的数据框,并对年龄与每个连续变量进行单独的 Wilcox 测试(数据不是正态分布的)。这很费时间,我想知道是否有更快的方法。

我希望我已经解释得足够多,有人可以提供帮助。谢谢。

*** 编辑*** 一些成功! 我尝试使用以下代码,其中 rt 是“RT”动物物种的单独数据框,但是有没有办法标记结果,以便您在阅读结果时知道哪些变量是重要的?

for (i in 6:12) {
  boxplot(rt[,i] ~ rt$Age,main = names(rt[i]),xlab = "Age",ylab = names(rt[i]),col = "pink")
  print(wilcox.test(rt[,i] ~ rt$Age)) }

结果:

>   Wilcoxon rank sum test with continuity correction
> 
> data:  rt[,i] by rt$Age W = 29024,p-value = 0.1545 alternative
> hypothesis: true location shift is not equal to 0
> 
> 
>   Wilcoxon rank sum test with continuity correction
> 
> data:  rt[,i] by rt$Age W = 33859,p-value = 8.053e-06 alternative
> hypothesis: true location shift is not equal to 0
> 
> 
>   Wilcoxon rank sum test with continuity correction
> 
> data:  rt[,i] by rt$Age W = 31686,p-value = 0.001948 alternative
> hypothesis: true location shift is not equal to 0
> 
> 
>   Wilcoxon rank sum test with continuity correction
> 
> data:  rt[,i] by rt$Age W = 28442,p-value = 0.2903 alternative
> hypothesis: true location shift is not equal to 0
> 
> 
>   Wilcoxon rank sum test with continuity correction
> 
> data:  rt[,i] by rt$Age W = 14554,p-value = 1.61e-14 alternative
> hypothesis: true location shift is not equal to 0
> 
> 
>   Wilcoxon rank sum test with continuity correction
> 
> data:  rt[,i] by rt$Age W = 5011,p-value = 1.479e-08 alternative
> hypothesis: true location shift is not equal to 0
> 
> 
>   Wilcoxon rank sum test with continuity correction
> 
> data:  rt[,i] by rt$Age W = 10322,p-value = 0.0131 alternative
> hypothesis: true location shift is not equal to 0

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...