Hi,
I'm new to Stata and have a regression of firm weekly return on market weekly returns: reg frim_r M_lag2 M_lag1 M_r M_lead1 M_lead2
I would like to estimate the regression by year and keep residuals for each year, so I tried the following code but ended with no observations r(2000).
Could someone please show me the right way to keep residuals by year?
Code:
gen residuals=.
levelsof year, local(level)
foreach i of local level {
reg frim_r M_lag2 M_lag1 M_r M_lead1 M_lead2 if year ==`i'
predict _res, res
replace residuals=_res if year ==`i'
drop _res
}
Kind Regards
Related Posts with Predict residuals by year
Herfindahl-Hirschman Index for banksHello, I have a problem creating Herfindahl-Hirschman Index for my data I tried scc install hhi but…
Looping a regression command sequentially by observation and storing each model.Hi all, Apologies if this is very simple or has been asked before. I have searched through many top…
combine multiple lines of codes into one command!Hey Statalist, I want to find a way in which I can combine multiple lines of codes into one single …
Importing csvHi, I have an easy problem, but unfortunately I could not solve it. When I want to import data fro…
removing text from string variable with date formatHello, I have a string variable that looks like this: 13-03-2014(Late visited). How can I remove som…
Subscribe to:
Post Comments (Atom)
0 Response to Predict residuals by year
Post a Comment