hi everyone,
My target is to perform a rolling dfuller test on panel data. Something like asreg or asrol for each panel and date of my data.
My sample is composed of N stocks and every stock has a specific value (from 1 to N) for "ID" variable and stock returns information "R" in different time/date ranges.
My sample has missing values and time numerical variable is "obst"
I am looking for a help about a specific nested loop. I would want to perfom, for every date (obst) and for every stock (ID), a dfuller test on last 250 stock returns (R) observations.
Then, I want to record some statistics (DFts, CV1,...) of the test stored in r().
This is my code:
gen DFts=.
gen CV1=.
gen CV5=.
gen CV10=.
gen DFpv=.
gen tmin=.
gen tmax=.
qui su ID
forvalues i = 1/`r(max)' {
qui su obst if ID == `i'
replace tmin=`r(min)'+250
replace tmax=`r(max)'
forvalues t = tmin/tmax {
qui dfuller R if ID == `i' in -249/`t'
replace DFts=r(Zt) if ID==`i' & obst==`t'
replace CV1=r(cv_1) if ID==`i' & obst==`t'
replace CV5=r(cv_5) if ID==`i' & obst==`t'
replace CV10=r(cv_10) if ID==`i' & obst==`t'
replace DFpv=r(p) if ID==`i' & obst==`t'
}
}
this code yields an error message
"invalid syntax
r(198);"
I hope someone can help me.
thanks
My target is to perform a rolling dfuller test on panel data. Something like asreg or asrol for each panel and date of my data.
My sample is composed of N stocks and every stock has a specific value (from 1 to N) for "ID" variable and stock returns information "R" in different time/date ranges.
My sample has missing values and time numerical variable is "obst"
I am looking for a help about a specific nested loop. I would want to perfom, for every date (obst) and for every stock (ID), a dfuller test on last 250 stock returns (R) observations.
Then, I want to record some statistics (DFts, CV1,...) of the test stored in r().
This is my code:
gen DFts=.
gen CV1=.
gen CV5=.
gen CV10=.
gen DFpv=.
gen tmin=.
gen tmax=.
qui su ID
forvalues i = 1/`r(max)' {
qui su obst if ID == `i'
replace tmin=`r(min)'+250
replace tmax=`r(max)'
forvalues t = tmin/tmax {
qui dfuller R if ID == `i' in -249/`t'
replace DFts=r(Zt) if ID==`i' & obst==`t'
replace CV1=r(cv_1) if ID==`i' & obst==`t'
replace CV5=r(cv_5) if ID==`i' & obst==`t'
replace CV10=r(cv_10) if ID==`i' & obst==`t'
replace DFpv=r(p) if ID==`i' & obst==`t'
}
}
this code yields an error message
"invalid syntax
r(198);"
I hope someone can help me.
thanks
Comment