![](/img/trans.png)
[英]R - Gamma distribution - Linear Mixed-Effects Model - lmer/glmer errors
[英]How to test if linear mixed effects model (lmer) is greater than 1 in R?
在下面的虛擬數據中,我想測試A和B的oviposition index
是否與1顯着不同。如果我理解正確,summary(mod)說每個物種是否與0顯着不同。如何更改默認值測試它是否與1不同? 在這里,我希望物種B
與 1 顯着不同,因為置信區間不包括 1
set.seed(111)
oviposition.index <- rnorm(20, 2, 1.3)
species <- rep(c("A","B"), each = 10)
month <- rep(c("Jan", "Feb"), times = 10)
plot <- rep(c("1", "2"), times = 10)
df <- data.frame(oviposition.index, species, month, plot)
mod <- lmer(oviposition.index ~ species + (1|month/plot), df)
summary(mod)
ggplot(df, aes(x = species, y = oviposition.index, color = species)) + geom_point() + geom_hline(yintercept = 1) + stat_summary(fun.data=mean_cl_boot, geom="errorbar", width=0.2, colour="black") + stat_summary(fun = mean, color = "black", geom ="point", size = 3,show.legend = FALSE)
奈特的評論
lmer(oviposition.index ~ 0 + species + (1|month/plot), df)
通過指定您想要對每個物種進行單獨估計而不是對物種 A 的估計 + 對差異的估計,讓您走到了一半,但是如果您想針對 index = 1 的零假設進行測試,您只需從響應中減去 1 :
lmer(oviposition.index - 1 ~ 0 + species + (1|month/plot), df)
您也可以添加一個偏移量(即,將+offset(rep(1, nrow(df)))
到您的模型中),但它對於線性模型來說太過分了(這對於調整零點並不那么容易的 GLM 很有用)。
我要添加一個警告,在這里很容易走上一條糟糕的道路:你可能有充分的理由分別測試每個物種的重要性,但繼續(可能是自然的)得出結論“物種 B 有一個 OI與 1 顯着不同,而物種 A 沒有,因此它們不同”是一個錯誤。 正如 Andrew Gelman 所說,“顯着性和非顯着性之間的差異在統計上並不顯着”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.