![](/img/trans.png)
[英]What is wrong with my syntax in lme4::lmer() for a split-split plot design with unbalanced repeated measures?
[英]R- analyzing repeated measures unbalanced design with lme4?
對於我的實驗,我在季節結束時修剪了植物並測量了它們的反應,例如產生的葉片質量。 我同時控制了剪切強度和剪切時間,並越過了這兩種處理方法。 我還包括對照修剪治療,產生了5種不同的修剪治療組合。 每次處理有12株植物,在過去的兩年中,我總共跟蹤了60株植物。 也就是說,我在第一年收集了這60株植物的測量值,並在第二年再次收集了相同的植物的測量值。
單獨分析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
軟件包進行多重比較。
沒有內在的錯
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
)(我假設這是可行的,但是如果例如,您可能需要進一步簡化模型數據中缺少時間和強度的組合) cmv$int <- with(cmv,interaction(timing,intensity,year,drop=TRUE))
(但是您將無法分離主要效果和互動)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.