pair t test complete.cases(x, y) 中的错误:并非所有参数都具有相同的长度
pair t test Error in complete.cases(x, y) : not all arguments have the same length
抱歉,我问的是愚蠢的问题...
我有一个简单的数据集,想要配对 T.test,因为测量来自相同的对象
这是我的代码:
t.test(Diarrhea ~ Max_by_90_H2SPos_12, data = noch4, paired=T)
它给了我错误:
Error in complete.cases(x, y) : not all arguments have the same length
这2个变量没有缺失值,我不明白。
这是我的数据:
table(noch4$Max_by_90_H2SPos_12)
0 1
180 57
str(noch4$Diarrhea)
num [1:237] 27 60 44 1 43 28 57 11 2 58 ...
str(noch4$Max_by_90_H2SPos_12)
num [1:237] 0 0 0 0 0 0 0 0 0 0 ...
感谢您的帮助。
问题是您正在尝试对配对样本使用 t 检验,因此您必须在测量前后拥有相同数量的受试者,在其输出中您会看到它有 180 个类型 0 和57代表1,0和1的数量应该是一样的。
noch4 = data.frame(Diarrhea = as.numeric(rpois(237,50)), Max_by_90_H2SPos_12 = as.numeric(c(rep(0,180),rep(1,57))))
table(noch4$Max_by_90_H2SPos_12)
str(noch4$Diarrhea)
str(noch4$Max_by_90_H2SPos_12)
t.test(Diarrhea ~ Max_by_90_H2SPos_12, data = noch4, paired=T)
请注意我如何进行筛选以获得相同数量的主题
noch = noch4[124:237,]
table(noch$Max_by_90_H2SPos_12)
0 1
57 57
t.test(Diarrhea ~ Max_by_90_H2SPos_12, data = noch, paired=T)
Paired t-test
data: Diarrhea by Max_by_90_H2SPos_12
t = 0.99629, df = 56, p-value = 0.3234
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-1.134814 3.380428
sample estimates:
mean of the differences
1.122807
合乎逻辑的事情是,如果你有例如 200 个 sujestos 并测量变量 Diarrhea,(preTest)然后我应用一些试剂和 re-measured 变量 Diarrhea(postTest),受试者的数量是200,即不换。
抱歉,我问的是愚蠢的问题...
我有一个简单的数据集,想要配对 T.test,因为测量来自相同的对象
这是我的代码:
t.test(Diarrhea ~ Max_by_90_H2SPos_12, data = noch4, paired=T)
它给了我错误:
Error in complete.cases(x, y) : not all arguments have the same length
这2个变量没有缺失值,我不明白。
这是我的数据:
table(noch4$Max_by_90_H2SPos_12)
0 1
180 57
str(noch4$Diarrhea)
num [1:237] 27 60 44 1 43 28 57 11 2 58 ...
str(noch4$Max_by_90_H2SPos_12)
num [1:237] 0 0 0 0 0 0 0 0 0 0 ...
感谢您的帮助。
问题是您正在尝试对配对样本使用 t 检验,因此您必须在测量前后拥有相同数量的受试者,在其输出中您会看到它有 180 个类型 0 和57代表1,0和1的数量应该是一样的。
noch4 = data.frame(Diarrhea = as.numeric(rpois(237,50)), Max_by_90_H2SPos_12 = as.numeric(c(rep(0,180),rep(1,57))))
table(noch4$Max_by_90_H2SPos_12)
str(noch4$Diarrhea)
str(noch4$Max_by_90_H2SPos_12)
t.test(Diarrhea ~ Max_by_90_H2SPos_12, data = noch4, paired=T)
请注意我如何进行筛选以获得相同数量的主题
noch = noch4[124:237,]
table(noch$Max_by_90_H2SPos_12)
0 1
57 57
t.test(Diarrhea ~ Max_by_90_H2SPos_12, data = noch, paired=T)
Paired t-test
data: Diarrhea by Max_by_90_H2SPos_12
t = 0.99629, df = 56, p-value = 0.3234
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-1.134814 3.380428
sample estimates:
mean of the differences
1.122807
合乎逻辑的事情是,如果你有例如 200 个 sujestos 并测量变量 Diarrhea,(preTest)然后我应用一些试剂和 re-measured 变量 Diarrhea(postTest),受试者的数量是200,即不换。