我正在使用lmerTest运行多级模型,其中员工嵌套在团队和部门中。我采用的是模型比较方法,因此我仅使用随机效果来构建模型。当我使用两个随机效应(团队成员和部门成员)来预测剧烈运动时,以下是结果:
library(lme4)
summary(m0_ev_io <- lmer(exer_vig ~ 1 + (1 | team_num) + (1 | dept_client), data = clean_data_0))
Linear mixed model fit by REML. t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: exer_vig ~ 1 + (1 | team_num) + (1 | dept_client)
Data: clean_data_0
REML criterion at convergence: 527.5
Scaled residuals:
Min 1Q Median 3Q Max
-1.6783 -0.6071 -0.2324 0.4233 2.1587
Random effects:
Groups Name Variance Std.Dev.
team_num (Intercept) 0.16687 0.4085
dept_client (Intercept) 0.03047 0.1746
Residual 1.14821 1.0715
Number of obs: 169, groups: team_num, 58; dept_client, 33
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 2.6743 0.1081 14.6284 24.74 2.4e-13 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
此模型以及所有后续模型运行良好,没有错误。但是,当我在精简运动中使用相同的数据运行相同的模型时,我得到一个奇异警告,突然部门成员之间没有差异:
summary(m0_el_io <- lmer(exer_lite ~ 1 + (1 | team_num) + (1 | dept_client), data = clean_data_0))
boundary (singular) fit: see ?isSingular
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: exer_lite ~ 1 + (1 | team_num) + (1 | dept_client)
Data: clean_data_0
REML criterion at convergence: 542
Scaled residuals:
Min 1Q Median 3Q Max
-1.6403 -0.5925 -0.3208 0.4440 2.0776
Random effects:
Groups Name Variance Std.Dev.
team_num (Intercept) 0.1471 0.3835
dept_client (Intercept) 0.0000 0.0000
Residual 1.3027 1.1414
Number of obs: 169, groups: team_num, 58; dept_client, 33
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 2.7160 0.1037 42.5453 26.2 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
convergence code: 0
boundary (singular) fit: see ?isSingular
除了因变量外,数据是相同的,所以我很困惑为什么会这样。我有信心这不是由于过拟合(例如在该线程(How to cope with a singular fit in a linear mixed model (lme4)?中),因为即使剧烈运动模型包含更多变量,它也不会发出奇异的警告。
您对发生这种情况的原因有什么想法,如何在不删除部门成员的情况下解决此问题?我已经尝试过其他站点的建议,包括将REML = FALSE和更改优化器[control = lmerControl(optimizer ='optimx',optCtrl = list(method ='L-BFGS-B')]],但没有任何效果。
谢谢!
编辑:这是数据示例。注意:team_num和dept_client是因素。
library(tidyverse)
clean_data_0 <- tibble(
exer_lite = c(5, 4, 4, 5, 2, 4, 3, 1, 2, 2, 5,3, 4, 5, 2, 2, 2, 5, 5, 2, 3, 3, 1, 2, 5),
exer_vig = c(4, 2, 4, 1, 2, 2, 3, 1, 2, 2, 5, 3, 3, 5, 2, 2, 3, 5, 5, 2, 3, 2, 1, 3, 5),
dept_client = factor(c(17, 17, 45, 45, 80, 100, 90, 14, 2, 80, 100, 90, 121, 121, 121, 2, 90, 90, 90, 2, 100, 14, 14, 76, 76)),
team_num = factor(c(509, 509, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 13, 13, 14, 14)),
id = c(1:25))