Announcement

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

  • margins after ivprobit: a bug?

    Dear all,
    I suspect there is a bug in the command margins when used after ivprobit.
    Or, perhaps, I've just missed something....
    Anyway the problem occurs with Stata 14.1 and not with Stata 14...


    Look at the following code:

    clear
    sysuse auto.dta

    ivprobit foreign (weight = length) headroom price
    predict xb,xb

    margins, dydx(weight) predict(pr) atmeans

    sum xb
    display "Marginal effect : " _b[weight]*normalden(r(mean)) /* here I compute the marginal effect manually and I get a different marginal effect */



    * Check on probit

    dprobit foreign weight headroom price
    predict xb2,xb
    sum xb2
    display "Marginal effect : " _b[weight]*normalden(r(mean)) /* note that I get the same marginal effects */


    probit foreign weight headroom price
    margins, dydx(weight) predict(pr) atmeans /* so it's here */


    Any guess on what's wrong?
    Many thanks in advance

    Lorenzo
    Last edited by Lorenzo Rocco; 06 May 2016, 08:56.

  • #2
    If you use version control, you get the same results as in earlier Stata:

    Code:
    . version 13.1: margins, dydx(weight) predict(pr) atmeans
    
    Conditional marginal effects                    Number of obs     =         74
    Model VCE    : OIM
    
    Expression   : Prob of positive outcome when rho=0, predict(pr)
    dy/dx w.r.t. : weight
    at           : weight          =    3019.459 (mean)
                   headroom        =    2.993243 (mean)
                   price           =    6165.257 (mean)
                   length          =    187.9324 (mean)
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          weight |  -.0003723   .0002152    -1.73   0.084    -.0007941    .0000495
    ------------------------------------------------------------------------------
    Now, the question is, what is right and what is wrong? According to -help whatsnew-, the Oct 29, 2015 update did this:

    7. predict with option pr after ivprobit has been improved to compute probability estimates that account for endogeneity. The old behavior is preserved under version control.

    This means that the results of margins, estat classification, lroc, and lsens after ivprobit also have been improved to account for endogeneity.
    So, I am guessing the current results are correct, but I am not sure how one "corrects for endogeneity" so I don't know how to confirm by hand.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    Stata Version: 17.0 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://www3.nd.edu/~rwilliam

    Comment


    • #3
      Lorenzo,

      In Stata 14.1 there was an improvement made to ivprobit postestimation predict, pr estimating the conditional probabilities of a positive outcome of the dependent variable. As recommended by Skeels and Taylor (2015) the computation now includes the instrumented variable equation in the computation. This is the definition of mi in the Methods and formulas section of [R] ivprobit.

      Listed below is your do code modified to include the computations that reproduce the 14.1 marginal effects.

      Code:
      sysuse auto.dta
      
      ivprobit foreign (weight = length) headroom price
      predict xb,xb
      
      margins, dydx(weight) predict(pr) atmeans
      
      version 14: margins, dydx(weight) predict(pr) atmeans
      
      sum xb
      display "Marginal effect : " _b[weight]*normalden(r(mean))
      
      scalar rho = tanh([athrho2_1]_b[_cons])
      scalar sigma = exp([lnsigma2]_b[_cons])
      
      di rho
      di sigma
      
      mat b = e(b)
      mat score double xp = b, eq(weight)
      scalar rs = scalar(rho)/scalar(sigma)
      scalar sr = sqrt(1-scalar(rho)^2)
      
      gen double m = (xb+scalar(rs)*(weight-xp))/scalar(sr)
      sum m
      
      display "Marginal effect : " ///
          ((_b[weight]+scalar(rs))/scalar(sr))*normalden(r(mean))
      I hope this helps.


      References:
      Skeels, C.L. and L.W. Taylor (2015) Prediction in linear index models with endogenous regressors, The Stata Journal (15), 627-644

      Comment


      • #4
        Thank you Richard & Richard for your quick and detailed answers. They fully answers my question
        Best
        Lorenzo

        Comment


        • #5
          Dear Richard (Gates), Dear all,

          thank you very much for the code which is helpful to disentangle the difference between the margins command after ivprobit in the newer vs. older versions of Stata. In my case, I have a high negative correlation (rho in your code) between the residuals of the first stage and the structural equation. Consequently, the marginal effect "correcting for endogeneity" becomes considerably smaller in comparison to the simple marginal effect of the old Stata version (see code below, my Stata version 14.2).

          Code:
          . ivprobit xenophob (inequal = standard) age male, vce(robust) nolog
          Probit model with endogenous regressors         Number of obs     =        939
                                                          Wald chi2(3)      =      10.95
          Log pseudolikelihood = -1412.8872               Prob > chi2       =     0.0120
          --------------------------------------------------------------------------------------------
                                     |               Robust
                                     |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
          ---------------------------+----------------------------------------------------------------
                             inequal |    .774823   .3302386     2.35   0.019     .1275672    1.422079
                                 age |   .0029153   .0024547     1.19   0.235    -.0018959    .0077264
                                male |   .1665353   .0805488     2.07   0.039     .0086625    .3244081
                               _cons |  -1.356366   .4690679    -2.89   0.004    -2.275722   -.4370099
          ---------------------------+----------------------------------------------------------------
           corr(e.inequal,e.xenophob)|  -.3913516   .1905433                     -.6933585    .0275976
                        sd(e.inequal)|   .5517135    .017141                      .5191203    .5863532
          --------------------------------------------------------------------------------------------
          
          . margins, dydx(inequal) predict(pr)
          ------------------------------------------------------------------------------
                       |            Delta-method
                       |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
               inequal |   .0278264   .1401031     0.20   0.843    -.2467705    .3024233
          ------------------------------------------------------------------------------
          
          . version 14: margins, dydx(inequal) predict(pr)
          ------------------------------------------------------------------------------
                       |            Delta-method
                       |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
               inequal |   .2795939   .1008357     2.77   0.006     .0819596    .4772282
          ------------------------------------------------------------------------------


          My first question concerns the reason (intuition) of the correction: Is it that unobserved factors drive the endogenous regressor (inequal) as well as the dependent variable of the structural equation (xenophob) that are canceled out by the IV strategy? Does the correction try to take into account the effect of these unobserved factors? However, I guess, that a causal interpretation of marginal effects in a strict sense should ignore those unobserved factors. Am I right here?

          A second question: Why the correction for endogeneity is implemented in the case of ivprobit but not in the ivreg command?

          Many thanks in advance
          Lutz

          Comment

          Working...
          X