Announcement

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

  • ivpoisson control function (with multiplicative error)

    Hi:

    Suppose:

    clear
    webuse website
    ivpoisson cfunction visits ad female (time = phone frfam)

    How could I manually reproduce the point estimates from the ivpoisson estimator after having obtained the residuals from the first stage? That is,

    reg time phone frfam ad female
    predict residuals, residuals

    Thanks.
    John.

  • #2
    -ivpoisson cfunction- uses one-step -gmm- to estimate coefficients. Below is a replica of -ivpoisson cfunction-.

    Code:
    webuse website, clear
    ivpoisson cfunction visits ad female (time = phone frfam), winit(identity)
    
    Step 1
    Iteration 0:   GMM criterion Q(b) =  .03944785  
    Iteration 1:   GMM criterion Q(b) =   .0002822  
    Iteration 2:   GMM criterion Q(b) =  2.421e-08  
    Iteration 3:   GMM criterion Q(b) =  1.757e-17  
    
    note: model is exactly identified
    
    Exponential mean model with endogenous regressors
    
    Number of parameters =  10                         Number of obs  =        500
    Number of moments    =  10
    Initial weight matrix: Identity
    GMM weight matrix:     Robust
    
    ------------------------------------------------------------------------------
                 |               Robust
          visits |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    visits       |
              ad |    .142332   .0127635    11.15   0.000     .1173161     .167348
          female |   .0014383   .0436521     0.03   0.974    -.0841183    .0869949
            time |   .0683575   .0182084     3.75   0.000     .0326697    .1040452
           _cons |   .9422102   .0541605    17.40   0.000     .8360576    1.048363
    -------------+----------------------------------------------------------------
    time         |
              ad |   .1655074   .0546634     3.03   0.002     .0583691    .2726457
          female |   -.052156   .2011019    -0.26   0.795    -.4463084    .3419964
           phone |   .2908914   .0748883     3.88   0.000     .1441131    .4376696
           frfam |   .2756408   .0651957     4.23   0.000     .1478597     .403422
           _cons |   .9347438   .2602415     3.59   0.000     .4246798    1.444808
    -------------+----------------------------------------------------------------
         /c_time |   .0796761   .0215887     3.69   0.000     .0373631    .1219891
    ------------------------------------------------------------------------------
    Instrumented:  time
    Instruments:   ad female phone frfam
    
    reg time ad female phone frfam
    
          Source |       SS           df       MS      Number of obs   =       500
    -------------+----------------------------------   F(4, 495)       =     49.66
           Model |  1007.50594         4  251.876486   Prob > F        =    0.0000
        Residual |  2510.78671       495  5.07229639   R-squared       =    0.2864
    -------------+----------------------------------   Adj R-squared   =    0.2806
           Total |  3518.29265       499  7.05068668   Root MSE        =    2.2522
    
    ------------------------------------------------------------------------------
            time |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
              ad |   .1655074   .0599471     2.76   0.006     .0477252    .2832896
          female |   -.052156   .2015858    -0.26   0.796    -.4482253    .3439133
           phone |   .2908914   .0622642     4.67   0.000     .1685567     .413226
           frfam |   .2756408   .0602579     4.57   0.000     .1572481    .3940335
           _cons |   .9347438   .2216227     4.22   0.000     .4993065    1.370181
    ------------------------------------------------------------------------------
    
    predict v, r
    gmm (eq1: visits / exp({visits: ad female time _cons}+{c_time}*(time-{time: ad female phone frfam _cons})) - 1) ///
        (eq2: time - {time:ad}*ad - {time:female}*female - {time:phone}*phone - {time:frfam}*frfam - {time:_cons}), ///
        instruments(eq1: ad female time v) ///
        instruments(eq2: ad female phone frfam) onestep winit(identity)
    
    Step 1
    Iteration 0:   GMM criterion Q(b) =  1161.5345  (not concave)
    Iteration 1:   GMM criterion Q(b) =  119.23133  
    Iteration 2:   GMM criterion Q(b) =  4.0049842  
    Iteration 3:   GMM criterion Q(b) =  .06717307  
    Iteration 4:   GMM criterion Q(b) =  .00018589  
    Iteration 5:   GMM criterion Q(b) =  3.015e-09  
    Iteration 6:   GMM criterion Q(b) =  1.107e-18  
    
    note: model is exactly identified
    
    GMM estimation 
    
    Number of parameters =  10
    Number of moments    =  10
    Initial weight matrix: Identity                   Number of obs   =        500
    
    ------------------------------------------------------------------------------
                 |               Robust
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    visits       |
              ad |    .142332   .0127635    11.15   0.000     .1173161     .167348
          female |   .0014383   .0436521     0.03   0.974    -.0841183    .0869949
            time |   .0683575   .0182084     3.75   0.000     .0326697    .1040452
           _cons |   .9422102   .0541605    17.40   0.000     .8360576    1.048363
    -------------+----------------------------------------------------------------
    c_time       |
           _cons |   .0796761   .0215887     3.69   0.000     .0373631    .1219891
    -------------+----------------------------------------------------------------
    time         |
              ad |   .1655074   .0546634     3.03   0.002     .0583691    .2726457
          female |   -.052156   .2011019    -0.26   0.795    -.4463084    .3419964
           phone |   .2908914   .0748883     3.88   0.000     .1441131    .4376696
           frfam |   .2756408   .0651957     4.23   0.000     .1478597     .403422
           _cons |   .9347438   .2602415     3.59   0.000     .4246798    1.444808
    ------------------------------------------------------------------------------
    Instruments for equation eq1: ad female time v _cons
    Instruments for equation eq2: ad female phone frfam _cons

    Comment


    • #3
      Perfect! Thank you much.

      Out of curiosity, how would we run the above with additive errors?

      Comment


      • #4
        -ivpoisson cfunction- doesn't support additive errors. Actually, additive errors do not make much sense to a poisson-distributed outcome. See discussions at https://www.statalist.org/forums/for...ive-iv-poisson.

        Comment


        • #5
          Right. I have seen that post before. In practice have you seen much of a difference in estimates when using multiplicative or additive errors with gmm? Any studies on this--simulations in particular?

          Comment


          • #6
            I'm unfamiliar with such literature. But if we apply control function to additive errors anyway, the -gmm- code would be

            Code:
            reg time ad female phone frfam
            predict v, r
            gmm (eq1: visits - exp({visits: ad female time _cons}+{c_time}*(time-{time: ad female phone frfam _cons}))) ///
                (eq2: time - {time:ad}*ad - {time:female}*female - {time:phone}*phone - {time:frfam}*frfam - {time:_cons}), ///
                instruments(eq1: ad female time v) ///
                instruments(eq2: ad female phone frfam) onestep winit(identity)
            Whose results may substantially differ from those with multiplicative errors, but may be quite similar to an alternative approach below.

            Code:
            reg time ad female phone frfam
            predict v, r
            poisson visits ad female time v, vce(robust)

            Comment


            • #7
              Right. That is the approach I used initially too with a basic augmented regression:

              Code:
              reg time ad female phone frfam
              predict v,r
              poisson visits ad female time v, vce(robust)
              As discussed here in section 17.5.1: Cameron, A. C., & Trivedi, P. K. (2005). Microeconometrics: Methods and applications. New York: Cambridge University Press.

              Thank you for your help!
              Last edited by John Antonakis; 21 Nov 2021, 03:40. Reason: Fixed code

              Comment


              • #8
                Oops--just referred to this post. The reference is wrong. It is section 17.5.1 in Cameron, A. C., & Trivedi, P. K. 2009. Microeconometrics Using Stata. College Station, Tex.: Stata Press.

                Comment

                Working...
                X