Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.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_Lme4_Anova - Fatal编程技术网

如何在R中建立重复测量方差分析模型

如何在R中建立重复测量方差分析模型,r,lme4,anova,R,Lme4,Anova,我正在测量两个物种之间特定样本的光合能力(产量)。在每个物种中,样品被分类为“漂白”或“非漂白”。我想进行重复测量方差分析,根据物种、漂白状态和时间点的交互作用确定产量是否不同。我认为使用lme4的线性混合模型是可行的,但我在这方面还是比较新的。下面是我运行过的3种不同的模型,但结果并不一致 Master <- structure(list(ColonyID = c("221", "222", "217", "218", "219", "220", "211", "212", "11",

我正在测量两个物种之间特定样本的光合能力(产量)。在每个物种中,样品被分类为“漂白”或“非漂白”。我想进行重复测量方差分析,根据物种、漂白状态和时间点的交互作用确定产量是否不同。我认为使用lme4的线性混合模型是可行的,但我在这方面还是比较新的。下面是我运行过的3种不同的模型,但结果并不一致

Master <- structure(list(ColonyID = c("221", "222", "217", "218", "219", 
"220", "211", "212", "11", "12", "209", "210", "203", "204", 
"201", "202", "19", "20", "3", "4", "43", "44", "45", "46", "243", 
"244", "247", "248", "239", "240", "26", "27", "41", "42", "237", 
"238", "229", "230", "35", "36", "221", "222", "217", "218", 
"219", "220", "211", "212", "11", "12", "209", "210", "203", 
"204", "201", "202", "19", "20", "3", "4", "43", "44", "45", 
"46", "243", "244", "247", "248", "239", "240", "26", "27", "41", 
"42", "237", "238", "229", "230", "35", "36"), Species = structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Montipora capitata", 
"Porites compressa"), class = "factor"), Bleach = structure(c(1L, 
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 
2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("Bleach", 
"Non-bleach"), class = "factor"), Yield = c(0.653, 0.654, 0.652, 
0.659, 0.586, 0.653, 0.524, 0.649, 0.556, 0.634, 0.579, 0.675, 
0.607, 0.63, 0.616, 0.622, 0.625, 0.582, 0.674, 0.62, 0.575, 
0.502, 0.57, 0.545, 0.552, 0.547, 0.544, 0.609, 0.518, 0.597, 
0.557, 0.488, 0.589, 0.525, 0.55, 0.608, 0.563, 0.484, 0.583, 
0.538, 0.563, 0.54, 0.584, 0.576, 0.557, 0.59, 0.506, 0.53, 0.663, 
0.645, 0.55, 0.634, 0.483, 0.585, 0.522, 0.584, 0.573, 0.504, 
0.515, 0.632, 0.532, 0.497, 0.534, 0.46, 0.482, 0.493, 0.501, 
0.494, 0.583, 0.401, 0.457, 0.441, 0.4, 0.419, 0.475, 0.49, 0.597, 
0.337, 0.468, 0.449), Timepoint = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L)), class = "data.frame", row.names = c(NA, 
-80L))

RM1 <- lmer(Yield ~ Bleach * Species * Timepoint + (1|ColonyID), data = Master)
anova(RM1)

RM2 <- aov(Yield ~ Bleach * Species * Timepoint + Error(ColonyID/(Bleach * Species)), data = Master)
summary(RM2)

RM3 <- aov(Yield ~ Bleach * Species * Timepoint, data = Master)
summary(RM3)

Master在RM2中,您只有交互

在RM3中,您没有指定重复测量

library(nlme)
library(lme4)

str(Master)
RM1a <- lmer(Yield ~ Bleach * Species * Timepoint + (1|ColonyID), data = Master)
summary((RM1a))


RM1 = lme(Yield ~ Bleach * Species * Timepoint,
              random = ~1|ColonyID,
              data=Master)

summary(RM1)


RM2 <- aov(Yield ~ Bleach * Species * Timepoint + Error(ColonyID/(Bleach * Species)), data = Master)
summary(RM2)
库(nlme)
图书馆(lme4)
str(硕士)

RM1a我没看到问题?谢谢!所以RM1和RM1a本质上是一样的?嘿,我不确定你想做什么,我只是强调一下为什么你有一些不同基本上,我想知道“漂白剂”、“物种”和“时间点”对光合能力(“产量”)是否有显着的个体或交互作用。然后,从边际原则来看,您需要在模型中包含主要效果(尽管无法单独解释)。