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: RE: problem with factor variable and margins.


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: problem with factor variable and margins.
Date   Wed, 17 Mar 2010 10:50:41 +0100

<>

So "1.nainc" is not in there. Is there any message after the -margins, post-
command to indicate that it got dropped?


HTH
Martin


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Rich Steinberg
Sent: Mittwoch, 17. März 2010 01:52
To: [email protected]
Subject: Re: st: RE: problem with factor variable and margins.

Martin -- thanks for quick reply.
Here's what I get when I follow your directions.  Note that it makes no 
mention of the "n" indicators.
e(b)[1,24]
 

0b.            1.
        linc2005      ainc2005    welinc2005     trinc2005  
pdv_tot~2005      home2005     owlth2005         zlinc         zlinc
y1     .00361868     .00423484    -.02269471    -.00096762     
.00184778      .0001901     .00027922             0    -316.88901

              0b.            1.           0b.            1.           
0b.            1.           0b.            1.           0b.
           zainc         zainc       zwelinc       zwelinc        
ztrinc        ztrinc          zinh          zinh         zhome
y1             0    -390.58658             0     22.671088             
0     68.796578             0     -93.26363             0

               1.           0b.            
1.                                         
           zhome        zowlth        zowlth    nainc_ainc    
nhome_home  nowlth_owlth
y1    -411.67932             0    -870.19597     .00711539     
.00115194     .00159752

.


Martin Weiss wrote:
> <>
>
> What does 
>
> *************
> mat l e(b)
> *************
>
> after the -margins,post- line give you?
>
>
> HTH
> Martin
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Rich Steinberg
> Sent: Dienstag, 16. März 2010 23:50
> To: [email protected]
> Subject: st: problem with factor variable and margins.
>
> Running a tobit, then getting average marginal effects (dy/dx) using the 
> margins command.  I ask it to compute the margins for some continuous 
> variables and 2 kinds of factor variables.  Results are only reported 
> for one of the two kinds of factor variables even though raw tobit 
> coefficients are computed for both kinds and no error messages appear.  
> I "post" the margins results to do some testing, and all is well for 
> testing continuous variables and one kind of factor variable (using 
> "test"), but I get an error message for any tests involving the other 
> kind of factor variable indicating it is "not found".  Is it me or 
> stata, I say hesitantly, realizing that every time in the past that I 
> thought I found a bug it turned out to be a stupid error on my part.
>
> Specifically, we have all sorts of income and wealth covariates and some 
> indicators created from them:  variables beginning with 'z' are 
> indicators that =1 if the corresponding income source =0, 0 otherwise.  
> I have no problem with the z variables.  Variables beginning with n are 
> indicators that = 1 if the corresponding income source takes a negative 
> value, 0 otherwise.  Here are the relevant command lines, with a few 
> comments inserted:
>
> tobit Atotgiv $income i.zlinc i.zainc i.zwelinc i.ztrinc i.zinh i.zhome 
> i.zowlth i.nainc nainc_ainc i.nhome nhome_home i.nowlth nowlth_owlth 
> $control, ll(24.99) vce(cluster fid1968)
> *runs fine, produces coefficients for the three 'n' factor variables: 
> i.nainc, i.nhome, and i.nowlth
>  margins, predict(ystar(0,.)) dydx( linc2005 ainc2005 welinc2005 
> trinc2005 pdv_totinh2005 home2005 owlth2005 zlinc zainc nainc nainc_ainc 
> zwelinc ztrinc zinh zhome nhome nhome_home zowlth nowlth nowlth_owlth)
post
> *produces the following translation and table, where the 'n' factor 
> variables disappear
> Average marginal effects                          Number of obs   
> =       4790
> Model VCE    : Robust
>
> Expression   : E(Atotgiv*|Atotgiv>0), predict(ystar(0,.))
> dy/dx w.r.t. : linc2005 ainc2005 welinc2005 trinc2005 pdv_totinh2005 
> home2005 owlth2005 1.zlinc
>                1.zainc 1.zwelinc 1.ztrinc 1.zinh 1.zhome 1.zowlth 
> nainc_ainc nhome_home nowlth_owlth
>
>        
>     Delta-method
>     dy/dx   Std. Err.      z    P>z     [95% Conf. Interval]
>        
> linc2005    .0036341   .0018126     2.00    0.045     .0000814    .0071867
> ainc2005    .0042529   .0054043     0.79    0.431    -.0063394    .0148451
> welinc2005    -.0227912   .0274355    -0.83    0.406    -.0765638    
> .0309814
> trinc2005    -.0009717   .0044668    -0.22    0.828    -.0097265
.007783
> pdv_tot~2005    .0018556   .0016007     1.16    0.246    -.0012817     
> .004993
> home2005    .0001909   .0004784     0.40    0.690    -.0007468    .0011286
> owlth2005    .0002804   .0001727     1.62    0.104    -.0000581
.0006189
> 1.zlinc    -318.2919   220.6601    -1.44    0.149    -750.7777     114.194
> 1.zainc    -392.2745   79.73669    -4.92    0.000    -548.5555   -235.9935
> 1.zwelinc    22.76784   236.5038     0.10    0.923    -440.7712
486.3069
> 1.ztrinc    69.08922   71.11036     0.97    0.331    -70.28453     208.463
> 1.zinh    -93.65764   124.6813    -0.75    0.453    -338.0284    150.7131
> 1.zhome    -413.516    85.3139    -4.85    0.000    -580.7282   -246.3038
> 1.zowlth    -874.5375   135.0824    -6.47    0.000    -1139.294
-609.7809
> nainc_ainc    .0071456   .0273387     0.26    0.794    -.0464373
.0607286
> nhome_home    .0011568   .0057747     0.20    0.841    -.0101613
.012475
> nowlth_owlth    .0016043   .0015222     1.05    0.292    -.0013791    
> .0045878
>        
> Note: dy/dx for    factor levels is the discrete    change from the base 
> level.
>
> *And then I do many tests, including the following that work and don't
work:
> test (ainc)(1.zainc)
>
>  ( 1)  ainc2005 = 0
>  ( 2)  1.zainc = 0
>
>            chi2(  2) =   28.57
>          Prob > chi2 =    0.0000
> test (1.nainc) (nainc_ainc)
> 1.nainc not found
> r(111);
>
>
>
>   
*
*   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/


*
*   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