Announcement

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

  • IV estimation with HDFE and weakivtest

    Hello everyone,

    I'm estimating an IV regression with HD FE using the -ivreghdfe- command.
    The problem is, I'm interested in getting the weak-instrument test by Montile Olea and Pfluger (2013), using the function called -weakivtest- which works with the -ivreg2- outcome. It was supposed that -ivreghdfe- is a wrapper of -ivreg2-, so I thought it gonna work fine. But it didn't work...

    Code:
    . ivreghdfe depvar x1 x2 (hendovar = z1 z2), absorb(year fips) first cluster(fips)
    . weakivtest
    The message says that -weakivtest- works only after the -ivreg2- command.
    I wonder if someone has implemented the test manually. Writing a small program or something like that. Because if I run my current model with -ivreg2-, it will take several hours to run due to the amount of FEs I have... And I have to run several models too, so -ivreg2- is just not feasible for my project.
    Many thanks in advance.

  • #2
    Ariel: I'll assume you have a small number of years and a balanced panel. If it's not balanced, you need to drop all incomplete cases before implementing the following. It could be done more elegantly in a loop, but it should give you the right idea.

    Code:
    egen ybar = mean(y), by(fips)
    egen x1bar = mean(x1), by(fips)
    egen x2bar = mean(x2), by(fips)
    egen hendovarbar = mean(hendovar), by(fips)
    egen z1bar = mean(x1), by(fips)
    egen z2bar = mean(z2), by(fips)
    gen yd = y - ybar
    gen x1d = x1 - x1bar
    gen x2d = x2 - x2bar
    gen hendovard = hendovar - hendovarbar
    gen z1d = z1 - z1bar
    gen z2d = z2 - z2bar
    ivregress 2sls yd x1d x2d i.year (hendovard = z1d z2d), first vce(cluster fips)
    weakivtest

    Comment


    • #3
      Originally posted by Jeff Wooldridge View Post
      Ariel: I'll assume you have a small number of years and a balanced panel. If it's not balanced, you need to drop all incomplete cases before implementing the following. It could be done more elegantly in a loop, but it should give you the right idea.

      Code:
      egen ybar = mean(y), by(fips)
      egen x1bar = mean(x1), by(fips)
      egen x2bar = mean(x2), by(fips)
      egen hendovarbar = mean(hendovar), by(fips)
      egen z1bar = mean(x1), by(fips)
      egen z2bar = mean(z2), by(fips)
      gen yd = y - ybar
      gen x1d = x1 - x1bar
      gen x2d = x2 - x2bar
      gen hendovard = hendovar - hendovarbar
      gen z1d = z1 - z1bar
      gen z2d = z2 - z2bar
      ivregress 2sls yd x1d x2d i.year (hendovard = z1d z2d), first vce(cluster fips)
      weakivtest
      Thank you so much, Dr. Wooldridge. I have 8 years of observations. I'm using individual-level data but with YEAR and COUNTY fixed effects. So my data could be balanced (or I can make it if it isn't already). If the dataset is balanced at the year and county level, will your approach work anyway, with individual-level observations?

      Comment


      • #4
        Sorry for the late reply. That should work. Can you verify that you get the same estimates using the "by hand" method and ivreghdfe?

        Comment

        Working...
        X