我有一组线性混合模型,并创建了一个平均模型。我想绘制模型适合两个级别的因子,包括在平均模型中。一个简单的例子:
library(lme4)
library(MuMIn)
mtcars2 <- mtcars
mtcars2$vs <- factor(mtcars2$vs)
gl <- lmer(mpg ~ am + disp + hp + qsec + (1 | cyl), mtcars2,
REML = FALSE, na.action = 'na.fail')
d <- dredge(gl)
av <- model.avg(d, subset = cumsum(weight) <= 0.95)
summary(av)
Call: model.avg(object = d, subset = cumsum(weight) <= 0.95) Component model call: lme4::lmer(formula = mpg ~ <7 unique rhs>, data = mtcars2, REML = FALSE, na.action = na.fail) Component models: df logLik AICc delta weight 13 5 -77.81 167.92 0.00 0.37 123 6 -76.34 168.05 0.13 0.35 134 6 -77.54 170.43 2.51 0.11 1234 7 -76.25 171.16 3.24 0.07 23 5 -79.85 172.00 4.08 0.05 2 4 -81.63 172.75 4.83 0.03 124 6 -78.99 173.34 5.42 0.02 Term codes: am disp hp qsec 1 2 3 4 Model-averaged coefficients: (full average) Estimate Std. Error Adjusted SE z value Pr(>|z|) (Intercept) 25.457505 6.467643 6.648016 3.829 0.000129 *** am 4.103425 1.861593 1.898182 2.162 0.030636 * hp -0.043829 0.017926 0.018265 2.400 0.016415 * disp -0.009419 0.011834 0.011983 0.786 0.431821 qsec 0.081973 0.284147 0.292015 0.281 0.778929 (conditional average) Estimate Std. Error Adjusted SE z value Pr(>|z|) (Intercept) 25.45751 6.46764 6.64802 3.829 0.000129 *** am 4.46519 1.46823 1.51835 2.941 0.003273 ** hp -0.04651 0.01471 0.01515 3.070 0.002140 ** disp -0.01793 0.01068 0.01099 1.632 0.102634 qsec 0.40421 0.51757 0.53873 0.750 0.453075 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Relative variable importance: hp am disp qsec Importance: 0.94 0.92 0.53 0.20 N containing models: 5 5 5 3
我想绘制完整平均模型估计的am
的效果。
通常情况下,我会使用lsmeans::lsmeans(gl, ~am)
或lmerTest::lsmeansLT(gl, 'am')
,并为两组及其置信区间绘制最小二乘平均值。
我如何为普通模型做同样的事情?