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
Combining plots using qchiHi, I've generated two variables, let's call them y1 and y2, and I want to generate a quantile-quan…
Construct parents' education from the censusHi, I have a problem on constructing parents' education from the census data. The original variable…
Update to -dstat- (and -moremata-) available from SSCAn update to the dstat package is available from SSC. dstat is a general command to estimate summary…
A question of storing and showing estimation resultsI run a loop of quantile regressions as follows: global ylist DvWEM forvalues i = 0.05(0.1)0.95 { q…
density plot y-axis (density) larger than 1Dear all, I am plotting three kdensity graphs in one graph. The variable "x" is for all the same (a…
Subscribe to:
Post Comments (Atom)
0 Response to ignore insufficient observations and run the loop without breaking
Post a Comment