stata如何处理结构方程模型(SEM)中具有缺失值的协变量

原文链接:http://tecdat.cn/?p=6349

 

本周我正和一位朋友讨论如何在结构方程模型(SEM)软件中处理具有缺失值的协变量。我的朋友认为某些包中某些SEM的实现能够使用所谓的“完全信息最大可能性”自动适应协变量中的缺失。在下文中,我将描述我后来探索Stata的sem命令如何处理协变量中的缺失。

 

为了研究如何处理丢失的协变量,我将考虑最简单的情况,其中我们有一个结果Y和一个协变量X,Y遵循给定X的简单线性回归模型。首先我们将模拟一个大数据集,所以我们知道真正的参数值:

gen x = rnormal()
gen y = x + rnormal()

这里真正的截距参数为0,真实斜率参数为1.残差误差为方差1。接下来,让我们设置一些缺少的协变量值。为此,我们将使用缺失机制,其中缺失的概率取决于(完全观察到的)结果Y.这意味着缺失机制将满足所谓的随机假设缺失。具体来说,我们将根据逻辑回归模型计算观察X的概率,其中Y作为唯一的协变量进入:

gen rxb = -2 + 2 * y
gen r =(runiform()<rpr) 
现在我们可以应用Stata的sem命令来适应SEM:
(7270 observations with missing values excluded)

Endogenous variables

Observed:  y

Exogenous variables

Observed:  x

Fitting target model:

Iteration 0:   log likelihood = -6732.1256  
Iteration 1:   log likelihood = -6732.1256  

Structural equation model                       Number of obs      =      2730
Estimation method  = ml
Log likelihood     = -6732.1256

------------------------------------------------------------------------------
             |                 OIM
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural   |
  y <-       |
           x |   .6179208   .0179671    34.39   0.000      .582706    .6531355
       _cons |    .999025   .0200306    49.88   0.000     .9597658    1.038284
-------------+----------------------------------------------------------------
     var(e.y)|   .6472101   .0175178                      .6137707    .6824714
------------------------------------------------------------------------------
LR test of model vs. saturated: chi2(0)   =      0.00, Prob > chi2 =      .
 

在没有缺失值的情况下,sem命令默认使用最大似然来估计模型参数。

但是sem还有另一个选项,它将使我们能够使用来自所有10,000条记录的观察数据来拟合模型。从命令行,我们可以通过以下方式选择它:

 

*output cut

Structural equation model                       Number of obs      =     10000
Estimation method  = mlmv
Log likelihood     = -20549.731

------------------------------------------------------------------------------
             |                 OIM
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural   |
  y <-       |
           x |   .9804851   .0156235    62.76   0.000     .9498637    1.011107
       _cons |  -.0145543    .025363    -0.57   0.566    -.0642649    .0351562
-------------+----------------------------------------------------------------
      mean(x)|   .0032305   .0257089     0.13   0.900     -.047158    .0536189
-------------+----------------------------------------------------------------
     var(e.y)|    1.02696   .0324877                      .9652191     1.09265
       var(x)|   .9847265   .0314871                       .924907    1.048415
------------------------------------------------------------------------------
LR test of model vs. saturated: chi2(0)   =      0.00, Prob > chi2 =      .

估计现在是无偏的。

因此,我们获得无偏估计(对于此数据生成设置),因为Stata的sem命令(在此正确)假设Y和X的联合正态性,并且缺失满足MAR假设。

非正态X
让我们现在重新运行模拟,但现在让X在一个*度上遵循卡方分布,通过平方rnormal()绘制:

clear
set seed 6812312
set obs 10000
gen x=(rnormal())^2
gen y=x+rnormal()

gen rxb=-2+*y
gen rpr=(rxb)/(1+exp(rxb))
gen r=(() rpr)
 x=. if r==0

使用缺少值选项运行sem,我们获得:

 

*output cut

Structural equation model                       Number of obs      =     10000
Estimation method  = mlmv
Log likelihood     = -25316.281

------------------------------------------------------------------------------
             |                 OIM
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural   |
  y <-       |
           x |   .8281994   .0066085   125.32   0.000      .815247    .8411518
       _cons |   .4792567   .0161389    29.70   0.000      .447625    .5108883
-------------+----------------------------------------------------------------
      mean(x)|   .5842649   .0224815    25.99   0.000     .5402019    .6283279
-------------+----------------------------------------------------------------
     var(e.y)|   .7537745   .0157842                      .7234643    .7853546
       var(x)|   3.073801   .0551011                       2.96768    3.183717
------------------------------------------------------------------------------
LR test of model vs. saturated: chi2(0)   =      0.00, Prob > chi2 =      .

现在我们再次有偏差估计,因为Y和X的联合常态假设不再成立。因此,如果我们使用此选项,当我们缺少协变量时,我们会发现联合正态假设是至关重要的。

完全随机缺失


让我们最后一次运行模拟,再次使用X卡方形分布,但现在X随机完全丢失(MCAR):

 

gen x=(rnormal())^2
gen y=x+rnormal()
replace x=if (()<0.5)

*output cut

Structural equation model                       Number of obs      =     10000
Estimation method  = mlmv
Log likelihood     = -25495.152

------------------------------------------------------------------------------
             |                 OIM
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural   |
  y <-       |
           x |   .9985166   .0093366   106.95   0.000     .9802173    1.016816
       _cons |  -.0092478   .0158659    -0.58   0.560    -.0403445    .0218488
-------------+----------------------------------------------------------------
      mean(x)|   .9738369   .0158113    61.59   0.000     .9428474    1.004826
-------------+----------------------------------------------------------------
     var(e.y)|   1.033884    .020162                      .9951133    1.074166
       var(x)|    1.83369   .0330307                       1.77008    1.899585
------------------------------------------------------------------------------
LR test of model vs. saturated: chi2(0)   =      0.00, Prob > chi2 =      .

尽管联合正态性假设被违反,现在我们再次进行无偏估计。我认为这是因为当数据是MCAR时,即使违反了正态性假设,也可以一致地估计均值和协方差结构.

上一篇:SEOer转型SEM,该如何转型,给SEOer的四个建议


下一篇:SEO和SEM的区别与联系有哪些?SEM和SEO是什么?