我已经查看了与我类似的其他几个问题,并且one most relevant没有得到解答,而其他问题都归结为缺少数据和数据长度。
我试图在经过一段时间的干扰之后模拟构图的陌生感。我在离散的时间点采样:0,3,6和9个月。我对时间对恢复的固定影响感兴趣,但是在每个点,季节和其他环境变量都发生了变化,导致0,3,6和9个月之间的变异性不同,这反映在正常线性模型中的残差中。
为了合并随机方差,同时还包括固定效果,我使用nlme运行此模型:
mod1 <- lme(Resp ~ Temp + Time, random = (~1 | Dummy),
weights = varIdent(form = ~1 | Time.f), data = recovery)
Resp是我的不同之处;温度是干扰强度(温度),时间是0,3,6或9个月;虚拟是一个虚拟的随机拦截(这里只是一个填充&#34的向量; D&#34;);和Time.f是时间转换为一个因子。我有60个数据点,每个采样时间有15个。
这很好。我想提取条件R2值,所以在lme4中使用lmer函数尝试了它:
mod2 <- lmer(Resp ~ Temp + Time + (1 | Dummy), weights = varIdent(form = ~1 | Time.f), data = recovery)
要运行lmer,虚拟变量至少需要两个类别,因此我将第一个值更改为&#34; C&#34;为了试图运行它(见下面的数据)。我收到错误:
model.frame.default中的错误(data = recovery,weights = varIdent(form = ~1 | :变量长度不同(找到&#39;(权重)&#39;)
我是方差结构的新手,我不确定这个模型的基本结构是否存在问题。在this问题中,Alain Zuur暗示将varIdent与二项式模型一起使用是不正确的,但我将其作为高斯运算(虽然我也被认为是Gamma)。
这是我的数据:
recovery <- data.frame(Resp = c(0.451342292, 0.518351745, 0.469268304,
0.472750101, 0.498935251, 0.508081111, 0.490904624, 0.446764424, 0.536142651,
0.707955998, 0.403299657, 0.495046237, 0.630677117, 0.630420366, 0.511555117,
0.460977339, 0.313873121, 0.442930551, 0.504933216, 0.266894217, 0.461051448,
0.406211728, 0.500511806, 0.561122944, 0.490329006, 0.565621645, 0.612263178,
0.380895252, 0.358544132, 0.40361619, 0.296853964, 0.364686954, 0.299307408,
0.349446067, 0.288854758, 0.292265106, 0.37207794, 0.300760264, 0.387906769,
0.376203541, 0.433080559, 0.371204216, 0.341724067, 0.357920013, 0.396109361,
0.372228087, 0.282725524, 0.317789872, 0.244435419, 0.277035603, 0.272620508,
0.378162153, 0.267645891, 0.306363131, 0.353826191, 0.230613947, 0.445865256,
0.321665269, 0.324131469, 0.266275828), Temp = c(25.4, 22.9, 22.5, 20.5, 29,
25.2, 40.5, 23.9, 28.1, 33.2, 43, 34.5, 38.5, 42.4, 31.3, 27, 28.6, 22.4, 24.2,
21.4, 22.6, 36.6, 28.8, 24.9, 28.6, 41.2, 21.5, 33, 39.8, 30.8, 22.2, 29.5,
25.9, 26.6, 22.8, 27.7, 24.9, 22.9, 27.6, 29, 26.7, 29.4, 43.5, 28.8, 23.1,
26.1, 25.7, 23.4, 29.4, 29.6, 23.7, 26.6, 31.7, 28.3, 28.5, 20.5, 23, 35.3,
42.5, 26.8), Time = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9), Dummy = c("C", "D", "D", "D",
"D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D",
"D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D",
"D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D", "D",
"D", "D", "D", "D", "D", "D", "D", "D"), Time.f = c("a", "a", "a", "a", "a",
"a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b",
"b", "b", "b", "b", "b", "b", "b", "b", "b", "c", "c", "c", "c", "c", "c",
"c", "c", "c", "c", "c", "c", "c", "c", "c", "d", "d", "d", "d", "d", "d", "d",
"d", "d", "d", "d", "d", "d", "d", "d"))
就像我说的,我是新手并发布。任何建议或建议都会很精彩!