
Hi Michael, 

Many thanks for your reply. 

I am handicapped in 2 different areas; firstly R and most importantly statistical concepts! 

May
 I ask you to expand on the 2nd paragraph of your reply below. I was 
originally using dynlm but then changed back to lm to avoid 
complication.

Also, what do you mean by: "You probably need to use a time series model that has forecasting built into it..."

Many thanks,
Darius

> From: michael.weylandt@gmail.com
> Date: Mon, 3 Oct 2011 13:16:47 -0400
> Subject: Re: [R] rolling regression
> To: xenon99@hotmail.com
> CC: r-help@r-project.org
> 
> It seems you don't really know how predict works. If you don't supply
> new data, it will only return the least squares fit to the old data,
> which is the large data block you saw. Check the first example given
> in ?predict to see how this works for new (out of sample) data.
> 
> More importantly, use of lm() gives a model for contemporaneous
> fitting of your data to cash_ret. You probably need to use a time
> series model that has forecasting built into it (unless you can
> somehow your independent variables before your dependent variables)
> 
> Michael Weylandt
> 
> On Sun, Oct 2, 2011 at 11:41 PM, Darius H <xenon99@hotmail.com> wrote:
> >
> > Dear all,
> >
> > I have spent the last few days on a seemingly simple and previously documented rolling regression.
> >
> > I have a 60 year data set organized in a ts matrix.
> > The matrix has 5 columns; cash_ret, epy1, ism1, spread1, unemp1
> >
> > I have been able to come up with the following based on previous help threads. It seems to work fine.
> > The trouble is I get regression coefficients but need the immediate next period forecast.
> >
> > cash_fit= rollapply(cash_data, width=60,
> >
> > function(x) coef(lm(cash_ret~epy1+ism1+spread1+unemp1, data = as.data.frame(x))),
> >
> > by.column=FALSE, align="right"); cash_fit
> >
> >
> > I tried to replace "coef" above to "predict" but I get a whole bunch of results too big to be displayed. I would be grateful
> > if someone could guide me on how to get the next period forecast after each regression.
> >
> > If there is a possibility of getting the significance of each regressor and the standard error in addition to R-sq
> > without having to spend the next week, that would be helpful as well.
> >
> > Many thanks,
> > Darius
> >
> >
> >
> >
> >
> >        [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
 		 	   		  
	[[alternative HTML version deleted]]

