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]

Re: st: missing factor variables in table of estimates


From   [email protected] (Jeff Pitblado, StataCorp LP)
To   [email protected]
Subject   Re: st: missing factor variables in table of estimates
Date   Wed, 22 Feb 2012 11:40:40 -0600

Lloyd Dumont <[email protected]> is having trouble with -estimates table-:

> I am having trouble recovering estimates from two-way multiplicative
> interactions created using Stata 11's facility for factor variables.
>  
> Here is an exampleâ?¦
>
> code:
> .  xtreg Y X1, fe 
> .  estimates store M1
> .  xtreg Y c.X2##c.X1 c.X3##c.X1, fe 
> .  estimates store M2
> .  estimates table M1 M2, stats(N N_g r2_o)
> star(.05 .01 .001) keep(c.X2##c.X1 c.X3##c.X1) b(%9.2f) stfmt(%9.2fc)
> style(oneline)
>  
> generates:
> --------------------------------------------
>     Variable |      M1             M2       
> -------------+------------------------------
>           X2 |                    -4.12**   
>           X1 |     -1.12***   (omitted)     
>              |
>    c.X2#c.X1 |                    10.46**   
>              |
>           X3 |                     5.65**   
>           X1 |     -1.12***   (omitted)     
>              |
>    c.X3#c.X1 |                   -14.66***  
> -------------+------------------------------
>            N |      3137           3137     
>          N_g |     31.00          31.00     
>         r2_o |      0.00           0.00     
> --------------------------------------------
>        legend: * p<.05; ** p<.01; ***
> p<.001
>  
> There are a few problems here.  First, looking down column M1, what can I do
> to prevent the estimate for X1 from displaying twice?  Second, in M2, no
> estimate displays for the main effect of X1.  In fact, it is omitted twice.
>
> So, how can one display estimates for ALL of the following variables, and
> have them display just once?
>
> X1
> X2
> X2
> * X1
> X3
> X3
> * X1

It looks like there are duplicate predictors in Lloyd's second model.

	.  xtreg Y c.X2##c.X1 c.X3##c.X1, fe 

In this specification, X1 will show up twice in the varlist since this notation will expand to

	.  xtreg Y X2 X1 c.X2#c.X1 X3 X1 c.X3#c.X1, fe 

Lloyd can use parens to simplify the specification, and remove the duplicates.
One option is

	.  xtreg Y c.(X2 X3)##c.X1, fe 

which expands to

	.  xtreg Y X2 X3 X1 c.X2#c.X1 c.X3#c.X1, fe 

The only other difficulty is that -estimates table- will need Lloyd to be
explicit in which coefficients to keep for the table because the '##' notation
isn't always going to work.  We hope to fix this in a future update to
Stata 12.

Here is a working example (Stata 11 and Stata 12) using the 'nlswork' dataset,
I renamed some variables to line up with Lloyd's example so that Lloyd can cut
and past the Stata code into a do-file.

***** BEGIN:
webuse nlswork
xtset idcode
rename ln_w Y
rename tenure X1
rename age X2
rename ttl_exp X3

* Lloyd's revised example
xtreg Y X1, fe
estimates store M1
xtreg Y c.X1##c.(X2 X3), fe
estimates store M2

estimates table M1 M2,                                  ///
        stats(N N_g r2_o)                               ///
        star(.05 .01 .001)                              ///
        keep(c.X1 c.X2 c.X3 c.X1#c.X2 c.X1#c.X3)        ///
        b(%9.2f)                                        ///
        stfmt(%9.2fc)                                   ///
        style(oneline)
***** END:

The output from -estimates table- is

***** BEGIN:
--------------------------------------------
    Variable |      M1             M2       
-------------+------------------------------
          X1 |      0.03***        0.07***  
          X2 |                    -0.01***  
          X3 |                     0.04***  
             |
   c.X1#c.X2 |                    -0.00***  
             |
   c.X1#c.X3 |                    -0.00***  
-------------+------------------------------
           N |     28101          28101     
         N_g |  4,699.00       4,699.00     
        r2_o |      0.14           0.20     
--------------------------------------------
       legend: * p<.05; ** p<.01; *** p<.001
***** END:

--Jeff
[email protected]
*
*   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