R-用lme4分析重复测量不平衡设计?

时间:2016-08-25 02:48:12

标签: r mixed-models

对于我的实验,我剪掉了植物并测量了它们的反应,例如在季节结束时产生的叶片质量。我操纵剪裁强度和剪裁时间并且越过这两种处理。我还包括对照修剪处理,产生5种不同的修剪处理组合。每次处理12株植物,共有60株植物,我在两年的时间内跟踪了这些植物。也就是说,我在第1年收集了这60个植物的测量结果,并在第2年收集了相同的植物。

分别分析5种不同的治疗方法是最简单的。然而,我想获得时间和强度及其相互作用的影响,但由于控制处理与时间或强度没有完全交叉,这使得我的实验设计不平衡且统计上棘手。为了使这一点复杂化,我想将年份的影响也包括在我的模型中。

理想情况下,我可以使用lme4来做到这一点,这使得随后使用lsmeans包进行多重比较。

当我尝试运行我的模型时

     m1<-lmer(log(plant.leaf.g+1)~timing*intensity*year+(1|id), data=cmv) #not significant

我遇到警告“固定效应模型矩阵排名不足,因此下降8列/系数”。

有没有人知道我可以让这种不平衡的混合模型与lme4一起使用?

这是我的数据的一个子集,其中“从不”在时间和“零”强度下任意取代“控制”处理:

id  year    timing  intensity   treatment   plant.leaf.g
91  2015    early   low early-low   315.944
92  2015    never   zero    control 99.28
93  2015    late    high    late-high   663.936
94  2015    early   low early-low   25.488
95  2015    early   high    early-high  453.57
96  2015    late    low late-low    90.804
97  2015    never   zero    control 1312.098
98  2015    late    high    late-high   959.82
99  2015    late    low late-low    28.014
100 2015    late    high    late-high   178.56
91  2014    early   low early-low   289.14
92  2014    never   zero    control 61.774
93  2014    late    high    late-high   639.936
94  2014    early   low early-low   138.39
95  2014    early   high    early-high  168.216
96  2014    late    low late-low    51.008
97  2014    never   zero    control 966.112
98  2014    late    high    late-high   279.048
99  2014    late    low late-low    23.936
100 2014    late    high    late-high   169.344

cmv<-structure(list(id = c(91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 
99L, 100L, 101L, 102L, 103L, 105L, 106L, 107L, 108L, 109L, 110L, 
91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 99L, 100L, 101L, 102L, 
103L, 104L, 105L, 106L, 107L, 108L, 109L, 110L), year = c(2015L, 
2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 
2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 
2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 
2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 
2014L, 2014L), timing = structure(c(1L, 3L, 2L, 1L, 1L, 2L, 3L, 
2L, 2L, 2L, 2L, 1L, 1L, 2L, 3L, 1L, 1L, 3L, 2L, 1L, 3L, 2L, 1L, 
1L, 2L, 3L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 3L, 1L, 1L, 3L, 2L
), .Label = c("early", "late", "never"), class = "factor"), intensity =     structure(c(2L, 
3L, 1L, 2L, 1L, 2L, 3L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 3L, 2L, 1L, 
3L, 1L, 2L, 3L, 1L, 2L, 1L, 2L, 3L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 
2L, 3L, 2L, 1L, 3L, 1L), .Label = c("high", "low", "zero"), class = "factor"), 
treatment = structure(c(3L, 1L, 4L, 3L, 2L, 5L, 1L, 4L, 5L, 
4L, 5L, 2L, 2L, 5L, 1L, 3L, 2L, 1L, 4L, 3L, 1L, 4L, 3L, 2L, 
5L, 1L, 4L, 5L, 4L, 5L, 2L, 2L, 5L, 5L, 1L, 3L, 2L, 1L, 4L
), .Label = c("control", "early-high", "early-low", "late-high", 
"late-low"), class = "factor"), plant.stem.g = c(315.944, 
99.28, 663.936, 25.488, 453.57, 90.804, 1312.098, 959.82, 
28.014, 178.56, 158.12, 387.528, 288.75, 327.348, 770.44, 
835.05, 457.188, 942.002, 229.194, 289.14, 61.774, 639.936, 
138.39, 168.216, 51.008, 966.112, 279.048, 23.936, 169.344, 
154.14, 703.04, 836.4, 511.92, 463.524, 245.226, 267.41, 
439.392, 714.85, 68.012)), .Names = c("id", "year", "timing", 
"intensity", "treatment", "plant.stem.g"), class = "data.frame", row.names =     c(NA, 
-39L))

注意:我已经m1=aov(plant.leaf.g~intensity*timing*year+Error(id), data=cmv)运行,但我读到我应该使用car包中的Anova type =“3”函数来获取我的p值,但我还没有能够使用Error(id)术语执行此操作。我也无法与TukeyHSD函数或multcomp包进行多重比较。

1 个答案:

答案 0 :(得分:0)

没有任何本质上的错误
 m1<-lmer(log(plant.leaf.g+1)~timing*intensity*year+(1|id), 
          data=cmv)

(除了用零标记日志转换数据很棘手;你确定加1是正确的吗?只有叶子质量是无单位的才有意义。你可以考虑添加min(plant.leaf.g[plant.leaf.g>0])/2代替...... )

出现警告(错误),因为您的数据集中没有时间,强度和年份的所有组合,但您要求R估算每个组合的参数。一些合理的选择是:

  • 忽略警告(无论如何,在比较每个因素的整体效果时,你可能会得到合理的答案)
  • 降低模型的复杂性,特别是通过消除三向交互(即使用(timing+intensity+year)^2)(我假设这会起作用,但你可能需要进一步简化模型,例如那里是数据中缺少的时间和强度的组合)
  • 构建来自3向交互的单向ANOVA,例如cmv$int <- with(cmv,interaction(timing,intensity,year,drop=TRUE))(但之后你将无法分离主要效果和互动)