这里有一些快速让你开始的东西。由于您的时间点很少,我会使用线性模型。我假设 OM 的绝对差异在这里是明智的,即样本以某种有意义的方式归一化。您可能需要使用相对值(在这种情况下甚至可能需要 GLMM?)。
library(data.table)
DT <- fread("Untitled spreadsheet.csv")
setnames(DT, make.names(names(DT)))
DT[, DiffOM := OM.at.collection..g. - Original.OM..T0...g.]
DT <- DT[-1]
library(ggplot2)
p <- ggplot(DT, aes(x = Day.of.collection, y = DiffOM, color = Plot)) +
geom_point() +
facet_wrap(~ Sample.type, ncol = 1)
print(p)
有些人建议只在有大量组可用的情况下才拟合随机效应,但如果结果拟合看起来合理,我通常也相信只有少数组的模型。当然,在这种情况下,您不应该过于相信随机效应的方差估计。或者,您可以将Plot
其视为固定效应,但您的模型将需要另外两个参数。然而,通常我们对情节差异不太感兴趣,更喜欢关注治疗效果。YMMV。
library(lmerTest)
fit1 <- lmer(DiffOM ~ Day.of.collection * Sample.type + (1 | Plot), data = DT)
fit2 <- lmer(DiffOM ~ Day.of.collection * Sample.type + (Day.of.collection | Plot), data = DT)
lme4:::anova.merMod(fit1, fit2)
#random slope doesn't really improve the model
fit3 <- lmer(DiffOM ~ Day.of.collection * Sample.type + (Sample.type | Plot), data = DT)
lme4:::anova.merMod(fit1, fit3)
#including the Sample type doesn't either
summary(fit1)
#apparently the interactions are far from significant
fit1a <- lmer(DiffOM ~ Day.of.collection + Sample.type + (1 | Plot), data = DT)
lme4:::anova.merMod(fit1, fit1a)
plot(fit1a)
#seems more or less okay with possibly exception of small degradation
#you could try a variance structure as implemented in package nlme
anova(fit1a)
#Analysis of Variance Table of type III with Satterthwaite
#approximation for degrees of freedom
# Sum Sq Mean Sq NumDF DenDF F.value Pr(>F)
#Day.of.collection 3909.4 3909.4 1 102 222.145 < 2.2e-16 ***
#Sample.type 452.4 226.2 2 102 12.853 1.051e-05 ***
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
显然,采样前的降解率在样本类型之间是不同的(根据样本类型查看不同的截距),这意味着非线性速率(正如我们所期望的那样)。差异的线性模型意味着恒定的绝对降解率。
summary(fit1a)
newdat <- expand.grid(Day.of.collection = seq(28, 84, by = 1),
Plot = c("A", "B", "C"),
Sample.type = c("X", "Y", "Z"))
newdat$pred <- predict(fit1a, newdata = newdat)
newdat$pred0 <- predict(fit1a, newdata = newdat, re.form = NA)
p +
geom_line(data = newdat, aes(y = pred, size = "subjects")) +
geom_line(data = newdat, aes(y = pred0, size = "population", color = NULL)) +
scale_size_manual(name = "Level",
values = c("subjects" = 0.5, "population" = 1.5))