Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 单因素重复测量不平衡数据的方差分析_R_Anova - Fatal编程技术网

R 单因素重复测量不平衡数据的方差分析

R 单因素重复测量不平衡数据的方差分析,r,anova,R,Anova,我是R的新手,我已经阅读了这些论坛(为R提供帮助)一段时间了,但这是我第一次发帖。在谷歌搜索了这里的每个错误之后,我仍然无法找出并修复我的错误 我试图用不同样本量进行单向重复测量方差分析。这是我正在使用的数据和代码的玩具版本。(如果重要的话,我的真实数据有12个存储箱,每个存储箱中最多有14到20个值。) 以下是我得到的错误: Error in qr.qty(qr.e, resp) : invalid to change the storage mode of a factor In ad

我是R的新手,我已经阅读了这些论坛(为R提供帮助)一段时间了,但这是我第一次发帖。在谷歌搜索了这里的每个错误之后,我仍然无法找出并修复我的错误

我试图用不同样本量进行单向重复测量方差分析。这是我正在使用的数据和代码的玩具版本。(如果重要的话,我的真实数据有12个存储箱,每个存储箱中最多有14到20个值。)

以下是我得到的错误:

Error in qr.qty(qr.e, resp) : 
  invalid to change the storage mode of a factor
In addition: Warning messages:
1: In model.response(mf, "numeric") :
  using type = "numeric" with a factor response will be ignored
2: In Ops.factor(y, z$residuals) : - not meaningful for factors
3: In aov(probability ~ bin + Error(subject/bin), data = dataFrame) :
  Error() model is singular

抱歉这么复杂(假设它是复杂的;对我来说是复杂的)。感谢您的时间。

对于不平衡重复测量设计,可能最容易 使用
lme
(来自
nlme
软件包):

##这应该与上面构建的数据相同,只是
##这是一种更简洁的方法。

datList对于不平衡重复测量设计,可能最容易 使用
lme
(来自
nlme
软件包):

##这应该与上面构建的数据相同,只是
##这是一种更简洁的方法。

datList在重复测量方差分析中,每个受试者在每种情况下都必须精确出现一次,因此样本量不能不相等。你需要把不属于每个箱子的主题放下来。或者,根据您的数据可能是什么样子,添加0个概率箱。您还需要设置由错误指示的变量类型。。。首先,感谢你的建议。根据这一点,我认为不相等的样本大小适合于此分析。另外,对于这些类型,我尝试过使用as.numeric确保因变量列是数值的(我还尝试了其他各种方法),但似乎都不起作用。类型应该是什么?在重复测量ANOVA中,每个受试者必须在每个条件下准确出现一次,这样你就不能有不相等的样本量。你需要把不属于每个箱子的主题放下来。或者,根据您的数据可能是什么样子,添加0个概率箱。您还需要设置由错误指示的变量类型。。。首先,感谢你的建议。根据这一点,我认为不相等的样本大小适合于此分析。另外,对于这些类型,我尝试过使用as.numeric确保因变量列是数值的(我还尝试了其他各种方法),但似乎都不起作用。应该是什么类型的?谢谢!我根据我的数据修改了您的代码,您是对的,我不确定如何解释这些结果。我将学习伦敦金属交易所()。再次感谢非常感谢。我根据我的数据修改了您的代码,您是对的,我不确定如何解释这些结果。我将学习伦敦金属交易所()。再次感谢
Error in qr.qty(qr.e, resp) : 
  invalid to change the storage mode of a factor
In addition: Warning messages:
1: In model.response(mf, "numeric") :
  using type = "numeric" with a factor response will be ignored
2: In Ops.factor(y, z$residuals) : - not meaningful for factors
3: In aov(probability ~ bin + Error(subject/bin), data = dataFrame) :
  Error() model is singular
## this should be the same as the data you constructed above, just 
## a slightly more compact way to do it.
datList <- list(
   bin1=c(0.37,0.00,0.00,0.16,0.00,0.00,0.08,0.06),
   bin2=c(0.33,0.21,0.000,1.00,0.00,0.00,0.00,0.00,0.09,0.10,0.04),
   bin3=c(0.07,0.41,0.07,0.00,0.10,0.00,0.30,0.25,0.08,0.15,0.32,0.18))
subject=c("S2","S3","S5","S7","S8","S9","S11","S12",
          "S1","S2","S3","S4","S7","S9","S10","S11","S12","S13","S14",
          "S1","S2","S3","S5","S7","S8","S9","S10","S11","S12","S13","S14")
d <- data.frame(probability=do.call(c,datList),
                bin=paste0("bin",rep(1:3,sapply(datList,length))),
                subject)

library(nlme)
m1 <- lme(probability~bin,random=~1|subject/bin,data=d)
summary(m1)