I have a panel dataset, and I am running the following program in STATA 11.2:
capture program drop tstep
program define tstep
args years obp slg fld age age2 exp exp2 newteam aqual1 aqual2 aqual3 aqual4 season status cat club
{
tempvar Tobp Tslg Robp Rslg absAobp absAslg
xtreg obp L.obp LL.obp age exp, fe
predict `Tobp'
gen `Robp'=`Tobp'-obp
xtreg slg L.slg LL.slg age exp, fe
predict `Tslg'
gen `Rslg'=`Tslg'-slg
gen `absAobp'=abs(`Robp')
gen `absAslg'=abs(`Rslg')
xi: regress years `absAobp' `absAslg' $varlist
}
end
It is a two-step process that uses two generated regressors, "absAobp" and "absAslg", in the second stage, hence my need for bootstrapping my standard errors. I've already used xtset and the panel variable is called "agent". The panel is unbalanced, but the year and agent uniquely identify each observation (yes, I've tested this using both xtdescribe and duplicates list).
In order to bootstrap my program, I use the following command:
gen newid=agent
bootstrap, reps(50) cluster(agent) idcluster(newid): tstep years $varlist
$varlist is a global variable list to cut down on typing time. "newid" and my year variable uniquely identify my panel data after its been bootstrapped, and I've made sure by using the following to test:
bsample, cl(agent) idcl(newid)
list year agent newid, sepby(newid)
I also used duplicates list to make damn sure.
When I try to run the above bootstrap command, I receive the error message "repeated time values within panel". By the way, if I don't bootstrap, the program runs just fine.
Many thanks for the help!
capture program drop tstep
program define tstep
args years obp slg fld age age2 exp exp2 newteam aqual1 aqual2 aqual3 aqual4 season status cat club
{
tempvar Tobp Tslg Robp Rslg absAobp absAslg
xtreg obp L.obp LL.obp age exp, fe
predict `Tobp'
gen `Robp'=`Tobp'-obp
xtreg slg L.slg LL.slg age exp, fe
predict `Tslg'
gen `Rslg'=`Tslg'-slg
gen `absAobp'=abs(`Robp')
gen `absAslg'=abs(`Rslg')
xi: regress years `absAobp' `absAslg' $varlist
}
end
It is a two-step process that uses two generated regressors, "absAobp" and "absAslg", in the second stage, hence my need for bootstrapping my standard errors. I've already used xtset and the panel variable is called "agent". The panel is unbalanced, but the year and agent uniquely identify each observation (yes, I've tested this using both xtdescribe and duplicates list).
In order to bootstrap my program, I use the following command:
gen newid=agent
bootstrap, reps(50) cluster(agent) idcluster(newid): tstep years $varlist
$varlist is a global variable list to cut down on typing time. "newid" and my year variable uniquely identify my panel data after its been bootstrapped, and I've made sure by using the following to test:
bsample, cl(agent) idcl(newid)
list year agent newid, sepby(newid)
I also used duplicates list to make damn sure.
When I try to run the above bootstrap command, I receive the error message "repeated time values within panel". By the way, if I don't bootstrap, the program runs just fine.
Many thanks for the help!
Comment