【发布时间】:2018-11-29 15:39:56
【问题描述】:
我正在尝试对混合效应模型进行协方差分析。 我的数据集如下
> str(try)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 864 obs. of 7 variables:
$ Site : chr "BISC1" "BISC1" "BISC1" "BISC1" ...
$ SET : Factor w/ 3 levels "SET1","SET2",..: 1 1 1 1 1 1 1 1 1 1 ...
$ ARM : chr "A_0001" "A_0001" "A_0001" "A_0001" ...
$ Pin : num 1 2 3 4 5 6 7 8 9 1 ...
$ SETarmpin : chr "SET1_A_0001_1" "SET1_A_0001_2" "SET1_A_0001_3"
"SET1_A_0001_4" ...
$ Days : num 145 145 145 145 145 145 145 145 145 145 ...
$ AbsPinDiff: num -1 -4 7 -12 -5 0 -5 -1 0 -22 ...
> dput(head(try))
structure(list(Site = c("BISC1", "BISC1", "BISC1", "BISC1", "BISC1",
"BISC1"), SET = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("SET1",
"SET2", "SET3"), class = "factor"), ARM = c("A_0001", "A_0001",
"A_0001", "A_0001", "A_0001", "A_0001"), Pin = c(1, 2, 3, 4,
5, 6), SETarmpin = c("SET1_A_0001_1", "SET1_A_0001_2", "SET1_A_0001_3",
"SET1_A_0001_4", "SET1_A_0001_5", "SET1_A_0001_6"), Days = c(145,
145, 145, 145, 145, 145), AbsPinDiff = c(-1, -4, 7, -12, -5,
0)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
))
我的混合效果模型如下:
trymodel<-lme(AbsPinDiff~Days+SET, random = ~1|SETarmpin,
correlation = corAR1(form=~Days|SETarmpin),
data = try, na.action = na.exclude, method="REML")
我正在使用“car”包中的 Anova 函数。然而,当我在上述模型上运行该函数时,我收到以下错误消息:
> Anova(trymodel4)
Error in terms.formula(object, data = data) :
'data' argument is of the wrong type
我有点困惑,因为据我推测,Anova 函数没有“数据”参数。
【问题讨论】:
-
您的文字图片isn't very helpful。它无法大声朗读或复制到编辑器中,并且索引不是很好,这意味着有相同问题的其他用户不太可能在这里找到答案。请edit您的帖子直接合并相关文本(最好使用复制+粘贴以避免转录错误)。
-
@TobySpeight 感谢您的建议!这个修改是不是看起来更舒服一点?
-
你会想要输入你的数据..stackoverflow.com/questions/5963269/…
-
@NickDylla 我将 dput() 函数与 head() 函数结合使用。这种编辑更可取吗?我非常感谢您的建议
-
不幸的是,我们不能仅使用
head()进行复制(尽管有时它提供了足够的信息来澄清问题)。你能告诉我们summary(trymodel4)吗?
标签: r statistics anova mixed-models