Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: margins for subset of model coefficients w/o constant term


From   "Feiveson, Alan H. (JSC-SK311)" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: margins for subset of model coefficients w/o constant term
Date   Thu, 9 Feb 2012 08:35:26 -0600

Hi - I thought I could use -margins- to get the equivalent of repeated calls to -lincom- for a subset of model coefficients without the constant term. The problem is I can't use "at" to make the constant term zero because the implied variable that _b[_cons] is multiplying is all ones. So I thought I would "trick" Stata by forming a variable of all ones and fitting the model with no constant. But then in some cases I get a "non-estimable" response or no standard errors. Yet the same combination in -lincom- works fine. Here's my example:


**** The original estimation ****

. xtmixed vo2max phase1  day1  ||isub: ,nolog

Mixed-effects ML regression                     Number of obs      =        55
Group variable: isub                            Number of groups   =         7

                                                Obs per group: min =         6
                                                               avg =       7.9
                                                               max =        10


                                                Wald chi2(2)       =     20.85
Log likelihood = -15.261456                     Prob > chi2        =    0.0000

------------------------------------------------------------------------------
      vo2max |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      phase1 |  -.4503613    .126299    -3.57   0.000    -.6979027   -.2028199
        day1 |   .0013801   .0010304     1.34   0.180    -.0006394    .0033996
       _cons |   2.820505   .2052827    13.74   0.000     2.418158    3.222851
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
isub: Identity               |
                   sd(_cons) |   .5272873   .1457558       .306728    .9064447
-----------------------------+------------------------------------------------
                sd(Residual) |   .2552611   .0260635      .2089645    .3118149
------------------------------------------------------------------------------
LR test vs. linear regression: chibar2(01) =    62.63 Prob >= chibar2 = 0.0000


**** Refit with "one" and no constant ****

. gen one = 1
. xtmixed vo2max phase1  day1  one,noc ||isub: ,nolog

Mixed-effects ML regression                     Number of obs      =        55
Group variable: isub                            Number of groups   =         7

                                                Obs per group: min =         6
                                                               avg =       7.9
                                                               max =        10


                                                Wald chi2(3)       =    194.90
Log likelihood = -15.261456                     Prob > chi2        =    0.0000

------------------------------------------------------------------------------
      vo2max |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      phase1 |  -.4503613    .126299    -3.57   0.000    -.6979027   -.2028199
        day1 |   .0013801   .0010304     1.34   0.180    -.0006394    .0033996
         one |   2.820505   .2052827    13.74   0.000     2.418158    3.222851
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
isub: Identity               |
                   sd(_cons) |   .5272873   .1457558       .306728    .9064447
-----------------------------+------------------------------------------------
                sd(Residual) |   .2552611   .0260635      .2089645    .3118149
------------------------------------------------------------------------------
LR test vs. linear regression: chibar2(01) =    62.63 Prob >= chibar2 = 0.0000


**** now try -margins- ****

. margins, at( phase1=1 day1= (50 100) one = 0)

Adjusted predictions                              Number of obs   =         55

Expression   : Linear prediction, fixed portion, predict()

1._at        : phase1          =           1
               day1            =          50
               one             =           0

2._at        : phase1          =           1
               day1            =         100
               one             =           0

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         _at |
          1  |  -.3813569          .        .       .            .           .
          2  |  -.3123525          .        .       .            .           .
------------------------------------------------------------------------------

**** -margins gives point estimates, but no standard errors; yet -lincom- is fine ****


. lincom _b[phase1]*1 + _b[day1]*50

 ( 1)  [vo2max]phase1 + 50*[vo2max]day1 = 0

------------------------------------------------------------------------------
      vo2max |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |  -.3813569   .0886184    -4.30   0.000    -.5550458    -.207668
------------------------------------------------------------------------------

. lincom _b[phase1]*1 + _b[day1]*100

 ( 1)  [vo2max]phase1 + 100*[vo2max]day1 = 0

------------------------------------------------------------------------------
      vo2max |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |  -.3123525   .0711577    -4.39   0.000    -.4518189    -.172886
------------------------------------------------------------------------------

In this example, I got point estimates, and no standard errors. In other more complicated models, I couldn't even get point estimates because the linear combinations I specified were considered "non-estimable" - yet they were clearly estimable with -lincom,-. For simpler models, (not shown) this method did work.

Any suggestions for


1) How to use -margins- to do what I want without the "ones" trick?
2) Why the "ones" trick doesn't always work.

Thanks


Al Feiveson




*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index