Hello,
I think I have found a bug with Stata's built in cluster jackknife. This bug seems to occur when the clustering variable is a string. Curiously, the string variable does not cause an issue for jackknife: reg y x, cluster, but fails for reg y x, cluster vce(jackknife).
I get the same error in both Stata 16 and Stata 17. Specifically, I get the error "no observations". The code below gives the same standard errors for the first three regressions, but fails on the fourth.
clear
set obs 1000
gen clusnum = ceil(_n/100)
gen clusname="."
replace clusname = "A" if clusnum==1
replace clusname = "B" if clusnum==2
replace clusname = "C" if clusnum==3
replace clusname = "D" if clusnum==4
replace clusname = "E" if clusnum==5
replace clusname = "F" if clusnum==6
replace clusname = "G" if clusnum==7
replace clusname = "H" if clusnum==8
replace clusname = "I" if clusnum==9
replace clusname = "J" if clusnum==10
gen y = rnormal()
gen x = rnormal()
gen w = rnormal()
/*jackknife with numeric clustering variable*/
reg y x w, cluster(clusnum) vce(jackknife)
jackknife: reg y x w, cluster(clusnum)
/*jackknife with string clustering variable*/
jackknife: reg y x w, cluster(clusname)
/*error - no observations*/
reg y x w, cluster(clusname) vce(jackknife)
Is this actually a bug, or am I missing something?
Cheers,
Matt
I think I have found a bug with Stata's built in cluster jackknife. This bug seems to occur when the clustering variable is a string. Curiously, the string variable does not cause an issue for jackknife: reg y x, cluster, but fails for reg y x, cluster vce(jackknife).
I get the same error in both Stata 16 and Stata 17. Specifically, I get the error "no observations". The code below gives the same standard errors for the first three regressions, but fails on the fourth.
clear
set obs 1000
gen clusnum = ceil(_n/100)
gen clusname="."
replace clusname = "A" if clusnum==1
replace clusname = "B" if clusnum==2
replace clusname = "C" if clusnum==3
replace clusname = "D" if clusnum==4
replace clusname = "E" if clusnum==5
replace clusname = "F" if clusnum==6
replace clusname = "G" if clusnum==7
replace clusname = "H" if clusnum==8
replace clusname = "I" if clusnum==9
replace clusname = "J" if clusnum==10
gen y = rnormal()
gen x = rnormal()
gen w = rnormal()
/*jackknife with numeric clustering variable*/
reg y x w, cluster(clusnum) vce(jackknife)
jackknife: reg y x w, cluster(clusnum)
/*jackknife with string clustering variable*/
jackknife: reg y x w, cluster(clusname)
/*error - no observations*/
reg y x w, cluster(clusname) vce(jackknife)
Is this actually a bug, or am I missing something?
Cheers,
Matt
Comment