Skip to content

rolling regression

6 messages · Darius H, R. Michael Weylandt

#
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 at hotmail.com> wrote:
1 day later
5 days later
#
Not having played with portfolio.opim() much, I can't guarantee this
will fix it, but if it requires a matrix rather than a vector and you
are sure about the rest of the syntax, this might do the trick:

asset_forecast[i, , drop = FALSE]

This is because:

R> x = matrix(1:9, 3)
R> is.matrix(x[,1])
FALSE
R> is.matrix(x[,1,drop=FALSE])
TRUE

Michael
On Mon, Oct 10, 2011 at 9:33 PM, Darius H <xenon99 at hotmail.com> wrote: