【问题标题】:Standard error for lmer time variables in RR中lmer时间变量的标准误差
【发布时间】:2016-09-22 08:43:25
【问题描述】:

所以,我试图预测某事(MS_TOT)随时间的变化。我有我的时间变量(ExamStage:1、3、6 和 12 个月)和我的药物使用变量(acstatus,一个因子 w 三个级别)。我认为药物使用会影响这种变化,作为 w 时间的相互作用,我将其放入我的 lmer 模型中(忽略其他变量):

    >model6<-lmer(MS_TOT~acstatus+ExamStage+acstatus*ExamStage+AIS.1+Level.1+F+    (ExamStage|id), E4)

这是输出:

> summary(model6)
Linear mixed model fit by REML 
t-tests use  Satterthwaite approximations to degrees of freedom ['lmerMod']
Formula: MS_TOT ~ acstatus + ExamStage + acstatus * ExamStage + AIS.1 +      Level.1 + F + (ExamStage | id)
   Data: E4

REML criterion at convergence: 9776.9

Scaled residuals: 
Min      1Q  Median      3Q     Max 
-4.8608 -0.3650 -0.0252  0.4319  3.3463 

Random effects:
 Groups   Name        Variance Std.Dev. Corr
 id       (Intercept) 150.346  12.2616      
          ExamStage     0.798   0.8933  0.09
 Residual              40.445   6.3597      
Number of obs: 1298, groups:  id, 451

Fixed effects:
                Estimate Std. Error       df t value Pr(>|t|)    
(Intercept)          19.8213     1.4241 496.8000  13.919  < 2e-16 ***
acstatus1            -1.5927     1.7913 417.6000  -0.889  0.37445    
acstatus2            -0.7399     1.8835 422.9000  -0.393  0.69465    
ExamStage             3.0816     0.2133 768.4000  14.446  < 2e-16 ***
AIS.1B                4.1984     2.1890 436.6000   1.918  0.05578 .  
AIS.1C               16.3097     1.9329 440.3000   8.438 4.44e-16 ***
AIS.1D               50.0334     1.5282 444.9000  32.740  < 2e-16 ***
Level.1TL            24.6689     1.3098 443.1000  18.833  < 2e-16 ***
F                    -0.1745     0.0158 703.9000 -11.045  < 2e-16 ***
acstatus1:ExamStage   0.2134     0.1891 211.0000   1.128  0.26053    
acstatus2:ExamStage   0.5455     0.2042 207.7000   2.671  0.00816 ** 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
        (Intr) acstt1 acstt2 ExmStg AIS.1B AIS.1C AIS.1D Lv.1TL F          ac1:ES
acstatus1   -0.215                                                               
acstatus2   -0.157  0.176                                                        
ExamStage   -0.260  0.009  0.018                                                 
AIS.1B      -0.382 -0.023 -0.008  0.005                                          
AIS.1C      -0.472 -0.035 -0.062  0.008  0.268                                   
AIS.1D      -0.648  0.014 -0.101  0.021  0.342  0.414                            
Level.1TL   -0.578 -0.009 -0.014  0.003  0.067  0.157  0.266                     
F            0.226  0.041  0.028 -0.888 -0.005 -0.007 -0.019 -0.002              
acstts1:ExS  0.054 -0.194 -0.050 -0.178 -0.003 -0.002 -0.007 -0.002 -0.069       
acstts2:ExS  0.047 -0.050 -0.192 -0.168  0.000  0.000 -0.001  0.001 -0.060  0.254

如您所见,acstatus2*Time 交互非常重要。所以,我说与 acstatus0 相比,acstatus2 会导致 MS_TOT 随时间增加 (0.5455*12)=5.88。但是,我的老板想要衡量这个数字的方差——我有估计的标准误差,但是我如何才能得到 12 个月内的估计值?

【问题讨论】:

    标签: r lme4


    【解决方案1】:

    您可能想了解如何计算边际效应。比如How to calculate the standard error of the marginal effects in interactions?

    你的陈述

    与 acstatus0 相比,acstatus2 导致 MS_TOT 随时间增加 (0.5455*12)=5.88

    并不完全正确,因为我们还需要包含acstatus2 的主要效果。 acstatus2 的边际效应是时间的函数,因此我们可以说 acstatus2MS_TOT 的 -0.7399 + 0.5455 * X 增加相关,其中X 代表月份。

    边际效应的方差Var(a + bX)Var(a) + X^2 * Var(b) + 2 * X * Cov(a, b)(在您的情况下X 为12)。我们可以从固定效应的方差-协方差矩阵中提取这些量——Var(a)Var(b)Cov(a, b)。要获得acstatus2 的边际效应的标准误差,您可以尝试类似

    variables <- c("acstatus2", "acstatus2:ExamStage")
    vcv <- vcov(model6)[variables, variables]
    sqrt(vcv[1, 1] + 12^2 * vcv[2, 2] + 2 * 12 * vcv[1, 2])
    

    【讨论】:

    • 非常感谢您的快速回复!你是对的,我没有包括 acstatus2 的主效应,因为我应该指定我只对时间交互效应和 12 个月期间的标准误差感兴趣。我相信你的回答也涵盖了这一点,但你能解释一下如何计算这个方差吗?
    • 如果你问什么是Var(12 * b),那么答案是12^2 * Var(b)。在标准错误术语中,您只需将 se 相乘。到 12 点。
    猜你喜欢
    • 1970-01-01
    • 2016-11-29
    • 2016-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-13
    • 2021-12-09
    相关资源
    最近更新 更多