Announcement

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

  • How to calculate the product of different xt(iv)reg estimates

    Dear Stata forum

    I would like to calculate the product of different estimates from two different xt(iv)reg estimates, such as the following:

    Code:
    ** import data and specify as panel data
    clear all
    webuse nlswork, clear
    tsset idcode year
    
    ** model 1
    xtivreg not_smsa age c.age#c.age (tenure = union south), fe vce(cluster idcode)
    estimates store model1
    
    ** model 2
    xtivreg ln_wage age c.age#c.age tenure (not_smsa= union south tenure), fe vce(cluster idcode)
    estimates store model2
    
    ** calculate the product of the estimate of tenure from model 1 and not_smsa model 2
    nlcom _b[model1_mean:tenure]*_b[model2_mean:not_smsa]
    I read similar questions on the Statalist forum suggesting to store the different estimates with the suest command before using the nlcom command to be able to calculate the product of the estimates. However, the suest command does not work for xt(iv)reg. Other suggested solutions were to run the xt(iv)reg manually with the regress command with unit dummies (i.e. the least-squares-dummy-variables-estimator). However, in my case I have a dataset of N=120,000 and so creating unit dummies is not possible (I got the error message r(103): too many variables specified).

    Does anyone know how I can solve this problem? Any suggestions would be greatly appreciated.

    Kind regards

    Eva

  • #2
    For linear models, joint estimation does not pose much of a challenge. However, I have never tried this for IV regression and I haven't thought through the consequence of having a single interacted first-stage in place of two first-stages. You can experiment using ivreghdfe from SSC following the advice in https://www.statalist.org/forums/for...rison-analysis relating to reghdfe. I do not have much time this week, but report if you are facing issues.

    Comment


    • #3
      Another (easier) method: See https://www.stata.com/support/faqs/s...ts-regression/ on demeaning the data using xtdata and then use cmp(SSC) which can simultaneously estimate multiple linear IV equations. I hope that in your actual application, one variable is not exogenous in one equation and endogenous in another as you illustrate in #1.

      Comment


      • #4
        This is not trivial to do.

        You can immediately calculate the product by saving the parameter estimates to scalars or locals, and then miltiplying them out.

        Code:
         ** model 1
        
        xtivreg not_smsa age c.age#c.age (tenure = union south), fe vce(cluster idcode) estimates store model1  
        
        sca Btenure = _b[tenure]
        
         ** model 2 xtivreg ln_wage age c.age#c.age tenure (not_smsa= union south tenure), fe vce(cluster idcode) estimates store model2  
        
        sca Bnot_smsa = _b[model2_mean:not_smsa]  
        
        dis Btenure*Bnot_smsa
        this will not give you standard errors and tests of statistical significance.

        To get this, you can wrap up the whole thing in a program, and bootstrap it.
        Last edited by Joro Kolev; 05 Jul 2022, 13:18.

        Comment


        • #5
          Dear Andrew Musau and Joro Kolev

          Thank you for your answers, I really appreciate your input. I tried all options and the options proposed in post #3 and #4 work perfectly for me, whereas the option in post #2 still gives the same error message after the suest command as when using xt(iv)reg.

          Thanks again for your help!

          Kind regards
          Eva

          Comment

          Working...
          X