首页 文章

R中lmer时间变量的标准误差

提问于
浏览
0

所以,我试图预测一些事情的变化(MS_TOT)随着时间的推移 . 我有我的时间变量(ExamStage:1,3,6和12个月)和我的药物使用变量(acstatus,因子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导致(0.5455 * 12)= 5.88随着时间的推移增加到MS_TOT . 但是,我的老板想要对这个数字进行一定的方差测量 - 我有估计的标准误差,btu如何在12个月的时间内得到它?

1 回答

  • 1

    您可能想要查找如何计算边际效应 . 例如,How to calculate the standard error of the marginal effects in interactions?

    你的陈述

    与acstatus0相比,acstatus2导致(0.5455 * 12)= 5.88随着时间的推移更大的增加到MS_TOT

    不完全正确,因为我们还需要包含 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])
    

相关问题