This is a question regarding clustering, especially in regard to the user-written command reghdfe (available on ssc; I am running Stata 12.1 on a Mac). I'm attempting to run a regression with -reghdfe- with an equal number of independent variables and clusters and I'm getting an error. When I use -reg- or -areg- there is not an error. My understanding is that this kind of regression is not fundamentally unsound (right?), but then I don't know why I'm getting an error with -reghdfe-. Any help is appreciated. My code is below:
Code:
set seed 1212 global o = 200 //number of observations global s = 20 //number of states set obs $o *assign a state and year to every observation gen state = floor((_n-1)/($o/$s))+1 gen year = _n - floor((_n-1)/($o/$s))*($o/$s) * state-specific linear time trend levelsof(state), local(sl) foreach s in `sl' { gen year_`s' = 0 replace year_`s' = year if state == `s' } * generate an independent variable qui gen indvar = state*year/100 + runiform()/100 qui gen depvar = indvar + state*year/100 + runiform()/100 * these run and give the same results reg depvar indvar i.(year state) year_*, vce(cluster state) areg depvar indvar i.year year_*, absorb(state) vce(cluster state) * this does not run: error message is "insufficient observations (N_clust=20, K=20)" reghdfe depvar indvar year_*, absorb(state year) vce(cluster state)
Comment