search for: rollregfun

Displaying 1 result from an estimated 1 matches for "rollregfun".

2012 Jan 24
1
problems with rollapply {zoo}
...realy short or has a strong slow pattern the regression result is not useful except to show that the code works) polyfit <- lm(Close ~ poly(rel_t,4),alpha) polyfit2 <- lm(Close ~ rel_t + I(rel_t^2) + I(rel_t^3) + I(rel_t^4), data=alpha) # This is the objective, where all the magic happens rollRegFun <- function(d,i) { # set up the relative time variable, so that the current record has rt = 0 d$rt <- seq(1-nrow(d),0) # apply the regression to fit a 4th degree polynomial in rt polyfit <- lm(Close ~ poly(rt,4),d) # get the coefficients p <- coef(polyfit) # get the roots o...