简体   繁体   English

如何引导混合 model 的 R 平方?

[英]How to bootstrap R-squared of a mixed model?

I'm trying to obtain bootstrapped R^2 for a mixed effect model.我正在尝试为混合效果 model 获得自举 R^2。 As there is already only a workaround to obtain the conditional and marginal R^2, I tried to bootstrap these statistic based on an example given by statmethods for bootstrapping a single statistic.由于已经只有一种解决方法来获得条件和边际 R^2,因此我尝试根据statmethods给出的用于引导单个统计信息的示例来引导这些统计信息。 The code works but the bias and standard error are always zero.该代码有效,但偏差和标准误差始终为零。

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

Shouldn't the conditional and marginal R^2 also change when I bootstrap a model?当我引导 model 时,条件和边际 R^2 不应该也改变吗? And is there any other way to obtain bootstrapped conditional and marginal R^2?还有其他方法可以获得自举条件和边际 R^2 吗?

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])
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM