Announcement

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

  • Stata margins command (atmeans) for one standard deviation change

    Hi everyone,

    I am currently writing my Bachelor thesis and need some help with the margins command. In particular, I estimate the following model:

    Code:
     reg y v FI c.v#c.FI X
    where my dependent variable y is ranged between 0 and 1, v is the main variable (between 1950 and 2017), FI is also ranged between 0 and 1 and X captured the covariates. In order to analyse the interaction term, I want to compute marginal effects at means. I would like to draw three scenarios:

    1. v increases by one standard deviation and FI equals to 0
    2. FI increases by one standard deviation and v equals to zero
    3. Both variables increase by one standard deviation.

    The remaining covariates should be at their mean (atmeans).

    How can I solve this using the margins command?

    Thanks,
    Jake





  • #2
    Code:
    . sysuse nlsw88, clear
    (NLSW, 1988 extract)
    
    . reg wage c.grade##c.ttl_exp i.south i.union
    
          Source |       SS           df       MS      Number of obs   =     1,876
    -------------+----------------------------------   F(5, 1870)      =    162.30
           Model |  9866.09489         5  1973.21898   Prob > F        =    0.0000
        Residual |  22735.3797     1,870   12.157957   R-squared       =    0.3026
    -------------+----------------------------------   Adj R-squared   =    0.3008
           Total |  32601.4745     1,875  17.3874531   Root MSE        =    3.4868
    
    -----------------------------------------------------------------------------------
                 wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ------------------+----------------------------------------------------------------
                grade |   .2745394    .095182     2.88   0.004     .0878653    .4612134
              ttl_exp |  -.0517401   .0916611    -0.56   0.573    -.2315089    .1280287
                      |
    c.grade#c.ttl_exp |   .0251362   .0071125     3.53   0.000      .011187    .0390855
                      |
              1.south |  -1.014563   .1653533    -6.14   0.000    -1.338859   -.6902662
                      |
                union |
               union  |   .8154901   .1900031     4.29   0.000     .4428497    1.188131
                _cons |   .5527386   1.208343     0.46   0.647    -1.817104    2.922581
    -----------------------------------------------------------------------------------
    
    .
    . sum grade
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
           grade |      2,244    13.09893    2.521246          0         18
    
    . local gr1 = r(mean)
    
    . local gr2 = r(mean) + r(sd)
    
    . sum ttl_exp
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
         ttl_exp |      2,246    12.53498    4.610208   .1153846   28.88461
    
    . local exp1 = r(mean)
    
    . local exp2 = r(mean) + r(sd)
    
    . margins, at(grade=(`gr1' `gr2') ttl_exp=(`exp1' `exp2') south = 0 union=0)
    
    Adjusted predictions                            Number of obs     =      1,876
    Model VCE    : OLS
    
    Expression   : Linear prediction, predict()
    
    1._at        : grade           =    13.09893
                   ttl_exp         =    12.53498
                   south           =           0
                   union           =           0
    
    2._at        : grade           =    13.09893
                   ttl_exp         =    17.14518
                   south           =           0
                   union           =           0
    
    3._at        : grade           =    15.62018
                   ttl_exp         =    12.53498
                   south           =           0
                   union           =           0
    
    4._at        : grade           =    15.62018
                   ttl_exp         =    17.14518
                   south           =           0
                   union           =           0
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             _at |
              1  |   7.627585   .1215531    62.75   0.000     7.389191    7.865979
              2  |   8.906998   .1452138    61.34   0.000       8.6222    9.191796
              3  |   9.114166   .1440408    63.27   0.000     8.831668    9.396663
              4  |   10.68575   .1766729    60.48   0.000     10.33925    11.03224
    ------------------------------------------------------------------------------
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Hi Maarten,

      thank you so much for your respond. It works!

      Best,
      Jake

      Comment


      • #4
        Hi Maarten,

        I run the same code as you describe but I get a error "invalid numlist has too few elements". Do you know how to solve it?

        Comment

        Working...
        X