Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • multiple margins post or estpost margins

    Hello Statalisters,

    i'm investigating the effect of wealth on charitable donations. For this i'am running a heckman-regression on donations, a dummy for donations yes/no, wealth and a number of control- and selection-variables.

    Now, i'd like to report margins or some other effects and i'd prefer to retrieve the margins via esttab/estout, first because it's simple, secondly because it looks good.

    As far as my understanding goes, esttab retrieves the parameters values, summary-statistics, etc, stata stores in eststo. Margins usually does not store it's results there (or anywhere permanently, as far as i know), except if one uses the post-option or the estpost margins command.

    The problem is that by specifying these options i seem to override all the input from my heckman-estimation, so that i can not use margins, post consecutively but rather only ones after the heckman-estimation. At least, regardless of the command i use (estpost margins or margins, post) when i want to use it a second time without reestimating the heckman, i get the following error-message:

    margins cannot work with its own posted results
    r(322);
    Now my question: is there any way of using multiple, consecutive margin-commands, store the results and retrieve them via esttab (or something which is as convenient)?

    This is my code:

    Code:
    * prepare locals
    #delimit ;
    local wealth = c.wealth_norm##(c.wealth_norm#c.wealth_norm);
    local control = ib5.wealth_perc ib0.soc_eng_2011 ib0.child_dum ib4.age_gr ib4.gross_gr
                     ib1.sex ib3.casmin_comp ib1.migback ib3.hlf0261 ib0.unempl ib1.loc1989;
    local income = c.netinc_norm##(c.netinc_norm#c.netinc_norm);
    local inherit = c.inherit_norm##(c.inherit_norm#c.inherit_norm);
    local selection = ib0.married ib0.retired ib0.inherit_dum;
    
    #delimit cr
    
            svy:heckman lgivings ib0.hvid `wealth' `income' `inherit' ///
                         `control' `weight', ///
                     select(givings_dum = ib0.hvid `wealth' `income' `inherit' ///
                            `control' `selection')
            eststo heckman
    
            * effect of employing people on donations *
            estpost margins hlf0261, pred(ycon)
            eststo marginhlfdon
            
    *** The last command is not working, stata returns error-message as described ***
    
            * effect of employing people on probability to donate donations *
            estpost margins hlf0261, pred(psel)
            eststo marginhlfprob
    My results.
    Click image for larger version

Name:	Regress.png
Views:	1
Size:	389.2 KB
ID:	1331196





    To get the results, i used estimates replay, where no information on svy is given:

    Number of Strata: 1
    Number of PSUs: 2121

    Many thanks in advance,

    Caspar
    Last edited by Caspar Aumueller; 17 Mar 2016, 05:26. Reason: Picture, tags

  • #2
    Lots of user-written commands here, for which you should explain where they come from. The general outline is

    Code:
    // run heckman model
    heckman [...]
    
    // save results
    estimates store heckman_results
    
    // run margins and save results 
    margins [...] , post
    estimates store margins_1
    
    // bring back heckman results
    estimates restore heckman_results
    
    // run next margins
    margins [...] , post
    [...]
    Best
    Daniel

    Comment


    • #3
      All right, that was easy. I'm sorry, obviously i didn't do my research profound enough.

      I suppose with "lots of" you refer to esttab/estout/eststore/estpost? They are all from the same package estout, which is available via ssc install estout.

      Examples can be found here (also accessible via h estout, upper right corner): http://repec.org/bocode/e/estout/index.html

      Thank you very much!





      Comment

      Working...
      X