Announcement

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

  • #16
    Hello,

    I am doing an analysis of dark money in elections. My dependent variable (y) is the percentage of untraceable receipts raised by political organizations. My data range from 0 to 1, and roughly 2/3s are the observations are clumped at 0. Substantively, I believe fractional probit regression (or possibly fractional logit regression) is the appropriate statistical technique. I have used Stata to estimate a simple model that has three independent variables (two dummies, one interval).

    The results of the fractional probit regression indicate that two dummy variables (x1, x2) are statistically significant and the one interval variable level (x3) is not, which was pretty much expected.

    At this point, I would like to:

    1. Separately, calculate the average effect for each dummy variable on y, while setting the other dummy variable and the interval variable at their observed values (or if that is not possible at their means). Ie, what effect does changing from x1=1 to x1=0?

    2. Calculate the average effect of different combinations of the dummy variables on y, while holding x3 at the observed values (or mean).More specifically, What is the average value of y when x1=1 and x2=0?, What is the value of y when x1=1 and x2=1, etc.

    Can someone advise me on the syntax needed to perform these functions? I am a fairly new Stata user and new to the listserve. Thank you.

    Best,
    Paul Herrnson

    Comment


    • #17
      Hello Paul,

      Welcome to the forum. What you want is margins . I think you will fall in love with it (I am in love with it myself). margins is available after most of Stata's estimation commands and was designed to answer questions like the ones you just formulated.

      Below I simulate some data and omit the output from estimation to go directly into margins. First, I answer the effect on the outcome of changing the discrete variable from one level to another.

      Code:
      . clear
      
      . set obs 1000
      number of observations (_N) was 0, now 1,000
      
      . set seed 111
      
      . generate x1 = int(rbeta(2,3)*3)
      
      . generate x2 = rnormal()
      
      . generate x3 = rchi2(2) - 2
      
      . generate e  = rchi2(1)-1
      
      . generate xb = .5*(1 + x1 - x2 + x3)
      
      . generate y  = normal(xb + e)
      
      . quietly fracreg probit y i.x1 x2 x3
      
      . margins, dydx(x1)
      
      Average marginal effects                        Number of obs     =      1,000
      Model VCE    : Robust
      
      Expression   : Conditional mean of y, predict()
      dy/dx w.r.t. : 1.x1 2.x1
      
      ------------------------------------------------------------------------------
                   |            Delta-method
                   |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
                x1 |
                1  |    .126237     .01504     8.39   0.000     .0967591    .1557149
                2  |   .2207073   .0173295    12.74   0.000     .1867422    .2546725
      ------------------------------------------------------------------------------
      Note: dy/dx for factor levels is the discrete change from the base level.
      Here you see the effect on the conditional mean of x1 being on level 1 relative to the base category, which is 0 in this case, and of x1 being on level 2 relative to the base category. You could also have asked margins for this in terms of contrasts between levels by typing:

      Code:
      . margins r.x1
      
      Contrasts of predictive margins
      Model VCE    : Robust
      
      Expression   : Conditional mean of y, predict()
      
      ------------------------------------------------
                   |         df        chi2     P>chi2
      -------------+----------------------------------
                x1 |
         (1 vs 0)  |          1       70.45     0.0000
         (2 vs 0)  |          1      162.20     0.0000
            Joint  |          2      167.94     0.0000
      ------------------------------------------------
      
      --------------------------------------------------------------
                   |            Delta-method
                   |   Contrast   Std. Err.     [95% Conf. Interval]
      -------------+------------------------------------------------
                x1 |
         (1 vs 0)  |    .126237     .01504      .0967591    .1557149
         (2 vs 0)  |   .2207073   .0173295      .1867422    .2546725
      --------------------------------------------------------------
      What you are getting is an average were all the regressors are left at their original values while you explore the function evaluated at a fixed value of x1 relative to the base level. You can see this clearly if you compute it manually (note I get only point estimates and no standard errors) I would obtain:

      Code:
      . generate contrast1 =  normal(_b[_cons]+ _b[x2]*x2+ _b[x3]*x3+ _b[1.x1]) ///
      >                     - normal(_b[_cons]+ _b[x2]*x2+ _b[x3]*x3)
      
      . generate contrast2 =  normal(_b[_cons]+ _b[x2]*x2+ _b[x3]*x3+ _b[2.x1]) ///
      >                     - normal(_b[_cons]+ _b[x2]*x2+ _b[x3]*x3)       
      
      . summarize contrast*
      
          Variable |        Obs        Mean    Std. Dev.       Min        Max
      -------------+---------------------------------------------------------
         contrast1 |      1,000     .126237    .0428965   1.58e-10   .1622922
         contrast2 |      1,000    .2207073    .0822452   1.69e-10   .2922469
      If you wanted to evaluate the quantities at the mean values of the regressors you would type the option atmeans.

      Regarding your second question the answer once more is margins. Using the option at() you can evaluate (among other things) the effects that you want at different values of your covariates. For example, if I wanted to know what the effects of interest at x2 = 1.33 and x1=1 I would type:

      Code:
      . margins, at(x2 = 1.33 x1=1)
      
      Predictive margins                              Number of obs     =      1,000
      Model VCE    : Robust
      
      Expression   : Conditional mean of y, predict()
      at           : x1              =           1
                     x2              =        1.33
      
      ------------------------------------------------------------------------------
                   |            Delta-method
                   |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
             _cons |   .4852482   .0164763    29.45   0.000     .4529553    .5175412
      ------------------------------------------------------------------------------

      Comment


      • #18
        Dear Enrique,

        Thank you very much. This was very helpful. Yes, I love it!

        Am I correct in assuming that "quietly nbreg" allows you to use the same margins commands for negative binomial regression?

        Best wishes,
        Paul

        Comment


        • #19
          Hello Paul,

          quietly suppresses the output on your screen but what each command returns is still available for consumption of margins or any other subsequent routine. You can use quietly at the beginning of a command line or for a block of code typing:

          Code:
          quietly {
             ...
          }

          Comment


          • #20
            HI Enrique,

            Nice feature.

            Thank you,
            Paul

            Comment

            Working...
            X