Announcement

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

  • Two levels of fixed effects (or group controls) with matsize problems

    I have some data where people go to one group and then to another group-- let's say, doctors and then hospitals. I want to use fixed effects for these two groups separately, so I can get a "hospital" effect and a "doctor" effect. When I use xtset, it won't allow me to do "xtset hospital doctor" because these aren't unique (doctor isn't consistent for hospital). I've tried to xtset hospital and then add a categorical variable into the regression for doctor (i.doctor) but the matsize isn't sufficient. (There are too many hospitals and doctors). Does anyone know how I can have these separate hospital and doctor effect in my regression?

    Note that this is distinct from grouping doctor and hospital together and then using xtset on that new group number.

    Thanks in advance! Please let me know if I can clarify anything!

  • #2
    Well, if every doctor goes to just one hospital, then what you want to do is impossible and you may as well not waste any more time trying. The hospital fixed effect would be constant within doctor and it would be omitted from the analysis. For purposes of adjusting for omitted variable bias, it wouldn't be a problem as the doctor-level fixed effect would handle that automatically, but you would be unable to actually estimate hospital level effects.

    Assuming that each doctor can go to several hospitals and each hospital has several doctors, then it can be done. Take a look at Sergio Correa's -reghdfe-, available from SSC. It can absorb multi-dimensional fixed effects, although, again, you will not get estimates of those effects.

    However, it may be that any approach you use will trigger your matrix size problem. Try setting your matrix size, -help set matsize-, to the largest value your Stata version and flavor will allow. (Don't forget to set it back when you're done with this, because running with a large matrix size when you don't need it both wastes memory and slows things down considerably.) If even with the largest matrix size available you get the same problem, then I think you are just out of luck. In that case, though, it is likely that you have more data than you really need for any practical purpose and doing a random subsample of doctors and hospitals that your Stata can digest would be a sensible approach.

    Comment

    Working...
    X