3

xtlogitコマンドでマルチレベル回帰を実行した後、Stata 12 で変数のマージンを計算しようとしました。しかし、margins回帰を実行した直後にコマンドを使用したにもかかわらず、変数が共変量のリストに見つからないというエラーが表示されました。これが私のコードの簡略版です:

. use http://url.com/file.dta, clear
. xtset country
. xtlogit dv iv1 iv2 iv3 iv4 iv5
. margins iv1, at(iv2==(0(1)6))
'iv1' not found in list of covariates
r(322);

margins興味深いことに、コマンドの後にカンマが必要な形式でコマンドを使用しても、Stata はエラーを表示しません。たとえば、次の 2 行のコードは問題なく動作します。

margins, at(iv2=(0(1)6)) over(iv1)
margins, dydx(iv1) at(iv2=(0(1)6))

2013 年 3 月のこの前の投稿を見ましたが、この問題を解決する方法がまだわかりません: Stata エラー: 共変量のリストに見つかりません

4

1 に答える 1

1

公開データ セットでエラーを再現できますか? これが私の試みです(因子変数の解が一番下にあります):

. use http://www.stata-press.com/data/r13/union
(NLS Women 14-24 in 1968)

. xtlogit union age grade not_smsa south##c.year

Fitting comparison model:

Iteration 0:   log likelihood =  -13864.23  
Iteration 1:   log likelihood = -13547.326  
Iteration 2:   log likelihood = -13542.493  
Iteration 3:   log likelihood =  -13542.49  
Iteration 4:   log likelihood =  -13542.49  

Fitting full model:

tau =  0.0     log likelihood =  -13542.49
tau =  0.1     log likelihood = -12923.751
tau =  0.2     log likelihood = -12417.651
tau =  0.3     log likelihood = -12001.665
tau =  0.4     log likelihood = -11655.586
tau =  0.5     log likelihood = -11366.441
tau =  0.6     log likelihood = -11128.749
tau =  0.7     log likelihood = -10946.399
tau =  0.8     log likelihood = -10844.833

Iteration 0:   log likelihood = -10946.488  
Iteration 1:   log likelihood =  -10557.39  
Iteration 2:   log likelihood = -10540.493  
Iteration 3:   log likelihood = -10540.274  
Iteration 4:   log likelihood = -10540.274  (backed up)
Iteration 5:   log likelihood = -10540.274  

Random-effects logistic regression              Number of obs      =     26200
Group variable: idcode                          Number of groups   =      4434

Random effects u_i ~ Gaussian                   Obs per group: min =         1
                                                               avg =       5.9
                                                               max =        12

Integration method: mvaghermite                 Integration points =        12

                                                Wald chi2(6)       =    227.46
Log likelihood  = -10540.274                    Prob > chi2        =    0.0000

------------------------------------------------------------------------------
       union |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |   .0156732   .0149895     1.05   0.296    -.0137056     .045052
       grade |   .0870851   .0176476     4.93   0.000     .0524965    .1216738
    not_smsa |  -.2511884   .0823508    -3.05   0.002    -.4125929   -.0897839
     1.south |  -2.839112   .6413116    -4.43   0.000    -4.096059   -1.582164
        year |  -.0068604   .0156575    -0.44   0.661    -.0375486    .0238277
             |
south#c.year |
          1  |   .0238506   .0079732     2.99   0.003     .0082235    .0394777
             |
       _cons |  -3.009365   .8414963    -3.58   0.000    -4.658667   -1.360062
-------------+----------------------------------------------------------------
    /lnsig2u |   1.749366   .0470017                      1.657245    1.841488
-------------+----------------------------------------------------------------
     sigma_u |   2.398116   .0563577                      2.290162    2.511158
         rho |   .6361098   .0108797                      .6145307    .6571548
------------------------------------------------------------------------------
Likelihood-ratio test of rho=0: chibar2(01) =  6004.43 Prob >= chibar2 = 0.000

. margins not_smsa, at(age=(10(5)20))
'not_smsa' not found in list of covariates
r(322);

. xtlogit union age grade i.not_smsa i.south##c.year

Fitting comparison model:

Iteration 0:   log likelihood =  -13864.23  
Iteration 1:   log likelihood = -13547.326  
Iteration 2:   log likelihood = -13542.493  
Iteration 3:   log likelihood =  -13542.49  
Iteration 4:   log likelihood =  -13542.49  

Fitting full model:

tau =  0.0     log likelihood =  -13542.49
tau =  0.1     log likelihood = -12923.751
tau =  0.2     log likelihood = -12417.651
tau =  0.3     log likelihood = -12001.665
tau =  0.4     log likelihood = -11655.586
tau =  0.5     log likelihood = -11366.441
tau =  0.6     log likelihood = -11128.749
tau =  0.7     log likelihood = -10946.399
tau =  0.8     log likelihood = -10844.833

Iteration 0:   log likelihood = -10946.488  
Iteration 1:   log likelihood =  -10557.39  
Iteration 2:   log likelihood = -10540.493  
Iteration 3:   log likelihood = -10540.274  
Iteration 4:   log likelihood = -10540.274  (backed up)
Iteration 5:   log likelihood = -10540.274  

Random-effects logistic regression              Number of obs      =     26200
Group variable: idcode                          Number of groups   =      4434

Random effects u_i ~ Gaussian                   Obs per group: min =         1
                                                               avg =       5.9
                                                               max =        12

Integration method: mvaghermite                 Integration points =        12

                                                Wald chi2(6)       =    227.46
Log likelihood  = -10540.274                    Prob > chi2        =    0.0000

------------------------------------------------------------------------------
       union |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |   .0156732   .0149895     1.05   0.296    -.0137056     .045052
       grade |   .0870851   .0176476     4.93   0.000     .0524965    .1216738
  1.not_smsa |  -.2511884   .0823508    -3.05   0.002    -.4125929   -.0897839
     1.south |  -2.839112   .6413116    -4.43   0.000    -4.096059   -1.582164
        year |  -.0068604   .0156575    -0.44   0.661    -.0375486    .0238277
             |
south#c.year |
          1  |   .0238506   .0079732     2.99   0.003     .0082235    .0394777
             |
       _cons |  -3.009365   .8414963    -3.58   0.000    -4.658667   -1.360062
-------------+----------------------------------------------------------------
    /lnsig2u |   1.749366   .0470017                      1.657245    1.841488
-------------+----------------------------------------------------------------
     sigma_u |   2.398116   .0563577                      2.290162    2.511158
         rho |   .6361098   .0108797                      .6145307    .6571548
------------------------------------------------------------------------------
Likelihood-ratio test of rho=0: chibar2(01) =  6004.43 Prob >= chibar2 = 0.000


. margins not_smsa, at(age=(10(5)20))

Predictive margins                                Number of obs   =      26200
Model VCE    : OIM

Expression   : Linear prediction, predict()

1._at        : age             =          10

2._at        : age             =          15

3._at        : age             =          20

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
_at#not_smsa |
        1 0  |  -2.674903   .3107206    -8.61   0.000    -3.283905   -2.065902
        1 1  |  -2.926092   .3148551    -9.29   0.000    -3.543196   -2.308987
        2 0  |  -2.596538   .2375601   -10.93   0.000    -3.062147   -2.130928
        2 1  |  -2.847726   .2432156   -11.71   0.000     -3.32442   -2.371032
        3 0  |  -2.518172   .1660016   -15.17   0.000    -2.843529   -2.192814
        3 1  |   -2.76936   .1743793   -15.88   0.000    -3.111137   -2.427583
------------------------------------------------------------------------------
于 2013-07-15T22:00:46.050 に答える