Announcement

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

  • Weighted random effects IV model (unbalanced panel)

    I have a model involving instrumental variables that I wish to estimate using random effects on an unbalanced panel, whilst applying analytical weights in Stata. Xtivreg does not allow for use of analytical weights and I have tried a number of approaches without success. Suggestions welcome!

    1. Pre-weight data and run xtivreg (weighting along the lines of http://www.stata.com/support/faqs/st...ar-regression/). Because this requires creating a variable for the constant term, it is necessary to then suppress the default constant term, but this is not possible within xtivreg or xtreg, re.

    2. Expand the dataset. This seems to work well for point estimates but not for standard errors and I would like to obtain the 'correct' SEs.

    3. I think it should be possible to transform the data (GLS) to reproduce the results of random effects IV models using ivreg2, which is then compatible with analytical weights. Using GLS I have only managed to successfully replicate xtreg, re with a balanced panel, and have not been able to replicate xtivreg with a balanced or unbalanced panel.

    Many thanks,

    James

  • #2
    You'll increase your chances of a a useful answer if you follow the FAQ on asking questions - provide Stata code in code delimiters, Stata output, and sample data.

    Look at user written xtivreg2. It allows weights (and has more options that xtivreg).

    Comment


    • #3
      Hi Phil,

      More code in version below. Thanks for the suggestion! As regards using xtivreg2, unfortunately this cannot be used for random effects.

      I have a model involving instrumental variables that I wish to estimate using random effects on an unbalanced panel, whilst applying analytical weights in Stata. Xtivreg does not allow for use of analytical weights and I have tried a number of approaches without success. Suggestions welcome!

      In an ideal world I'd run the following, but the use of weights is not allowed:

      xtivreg y x1 x2 (x1= z1) [w=weightvar], re first

      1. Pre-weight data and run xtivreg (weighting along the lines of http://www.stata.com/support/faqs/st...ar-regression/). Because this requires creating a variable for the constant term, it is necessary to then suppress the default constant term, but this is not possible within xtivreg or xtreg, re.

      gen double a = weightvar^0.5

      foreach x of varlist y x1 x2 z1 {
      cap drop a`x'
      gen double a`x' = a*`x'
      }

      cap drop acons
      gen double acons = a
      xtivreg ay ax1 ax2 (ax1 = az1) acons, nocons re first // Unfortunately nocons option cannot be specified using xtivreg

      2. Expand the dataset. This seems to work well for point estimates but not for standard errors and I would like to obtain the 'correct' SEs. I would also like to obtain the 'correct' first stage underidentification test f-stat.

      expand weightvar
      xtivreg y x1 x2 (x1= z1), re first

      3. I think it should be possible to transform the data (GLS) to reproduce the results of random effects IV models using ivreg2, which is then compatible with analytical weights. Using GLS I have only managed to successfully replicate xtreg, re with a balanced panel, and have not been able to replicate xtivreg with a balanced or unbalanced panel.

      I used the following code and failed to replicate the initial regression output:

      tsset i t
      xtreg y x1 x2, re
      scalar sig_e = e(sigma_e)
      scalar sig_u = e(sigma_u)
      bysort i: egen T = count(x1) if e(sample)
      gen double g = 1 - (e(sigma_e)^2/(e(sigma_e)^2+T*e(sigma_u)^2))^0.5

      foreach x of varlist y x1 x2 {
      cap drop `x'av
      bysort i: egen double `x'av = mean(`x')
      }

      foreach x of varlist y x1 x2 {
      cap drop g`x'
      gen double g`x' = `x' - g*`x'av
      }

      cap drop gcons
      gen double gcons = 1- g
      reg gy gx1 gx2 gcons, nocons

      Many thanks,

      James

      Comment

      Working...
      X