Hi, I would like to calculate cumulative security residual return, which is residual in a regression of a firm's monthly stock return(variable"ret") on the market monthly returns (variable "vwretd") over the 12-month period ( estimation_window) before the date of filing of the financial statement (event_window). I have prepared my data and am working on the regression loop. my codes are shown below:
gen predicted_return=.
egen id=group(company_id)
forvalues i=1(1)N { /*note: replace N with the highest value of id */
reg ret vwretd if id==`i' & estimation_window==1
predict p if id==`i'
replace predicted_return = p if id==`i' & event_window==1
drop p
}
initially, it worked well, but when it comes to id==15, it showed the following error and stopped running the loop:
(option xb assumed; fitted values)
(8,074,563 missing values generated)
(0 real changes made)
insufficient observations
(option xb assumed; fitted values)
(8,074,563 missing values generated)
(0 real changes made)
I search the forum and tried to fix the problem by using the codes below but it does work. Can I get some help?
forvalues i=1(1)N { /*note: replace N with the highest value of id */
capture noisily reg ret vwretd if id==`i' & estimation_window==1
capture noisily predict p if id==`i'
capture noisly replace predicted_return = p if id==`i' & event_window==1
capture noisly drop p
}
Related Posts with ignore insufficient observations and run the loop without breaking
Estimation via SURE model(Seemingly Unrelated Equation Models) dependent variable delta_cash short term debt long term debt intercept working ca…
Testing statistical difference in coefficients after ppml estimation of gravity modelDear all, I am running a PPML regression for a trade gravity model using bilateral trade flows and …
Creating Variable - years since an eventHi there, I have a panel dataset and wish to do a regression analysis that involves a variable, "Ye…
re-generate time varying variable when collapsing from daily panel data to monthly panel dataDear Statalist Members, Hi, I'm trying to convert my daily panel data to monthly panel data using c…
Adding day of the week variable to a GARCH(1,1)Hi all, I'm still relatively new to Stata so could use some help. I'm trying to do a GARCH regressi…
Subscribe to:
Post Comments (Atom)
0 Response to ignore insufficient observations and run the loop without breaking
Post a Comment