【问题标题】:How to test if linear mixed effects model (lmer) is greater than 1 in R?如何测试 R 中的线性混合效应模型(lmer)是否大于 1?
【发布时间】:2021-09-26 04:30:18
【问题描述】:

在下面的虚拟数据中,我想测试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)

标签: r ggplot2 lm lme4 mixed-models


【解决方案1】:

内特的评论

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 所说,“显着和非显着之间的差异在统计上并不显着”。

【讨论】:

    猜你喜欢
    • 2021-12-29
    • 1970-01-01
    • 2021-12-30
    • 1970-01-01
    • 2017-04-03
    • 1970-01-01
    • 2021-07-22
    • 2018-04-04
    • 1970-01-01
    相关资源
    最近更新 更多