【问题标题】:How to bootstrap R-squared of a mixed model?如何引导混合模型的 R 平方?
【发布时间】:2020-02-12 05:57:02
【问题描述】:

我正在尝试为混合效应模型获取自举 R^2。由于已经只有一种解决方法来获得条件和边际 R^2,因此我尝试根据 statmethods 给出的示例引导这些统计信息,以引导单个统计信息。代码有效,但偏差和标准误差始终为零。

library(lme4)
library(boot)
data(Dyestuff, package = "lme4")
model <- lmer(Yield ~ 1|Batch, data=Dyestuff)
summary(model)
r.squaredGLMM(model)

rsq <- function(formula, data, indices) {
  d <- data[indices,] 
  model.fit <- lmer(Yield ~ 1|Batch, data=Dyestuff)
  fit.r.squared <- r.squaredGLMM(model.fit)
  return(summary(fit.r.squared[,2]))
}

set.seed(101)
results <- boot(data=Dyestuff, statistic=rsq,
                R=1000, formula=Yield ~ 1|Batch)

results


Bootstrap Statistics :
     original  bias    std. error
t1* 0.4184874       0           0
t2* 0.4184874       0           0
t3* 0.4184874       0           0
t4* 0.4184874       0           0
t5* 0.4184874       0           0
t6* 0.4184874       0           0

当我引导模型时,条件和边际 R^2 是否也应该改变?还有其他方法可以获得自举条件和边际 R^2 吗?

【问题讨论】:

    标签: r lme4 mixed-models statistics-bootstrap


    【解决方案1】:
    rsq <- function(formula, data, indices) {
      d <- data[indices,] 
      model.fit <- lmer(Yield ~ 1|Batch, data = d)
      fit.r.squared <- r.squaredGLMM(model.fit)
      return(fit.r.squared[,2])
    }
    

    【讨论】:

    • 您也可以引导边际 R²(但它始终为 0)。只需删除[,2]
    • 如何获得条件 R² 的置信区间?我尝试了命令boot.ci(results, type="bca"),但它只显示了边际 R² 的结果。此外,当我尝试使用条件 R² 不为 0 的示例时。
    猜你喜欢
    • 2022-06-29
    • 1970-01-01
    • 2018-01-01
    • 2017-02-01
    • 2020-06-12
    • 1970-01-01
    • 2021-02-15
    • 2021-10-05
    • 2013-08-28
    相关资源
    最近更新 更多