r语言 - 识别 lme4 模型中的异常值



我想识别 lmer 模型中的异常值(lme4包(。我对删除它们不感兴趣(LMERConvenienceFunctions包的作用( - 我只想看到列出的异常值。

我使用的模型示例:

model1<-lmer(Value~ Moisture + Planting + (day|plot), data=plants1)

如果您想以与LMERConvenienceFunctions相同的方式定义异常值(标准化 1 级残差> 0 的 2.5SD(,那么这将起作用:

res1 <- resid(model1, type = "pearson") # Extract standardized residuals
plants1[which(abs(res1) > 2.5),] # Get the rows which absolute residuals > 2.5

如果plants1中缺少数据,请确保在提取残差之前在lmer命令中设置na.action = 'na.exclude'。这将确保将缺少数据的观测值设置为NA,而不是省略它们。

最新更新