I am using tick data to convert it into minutes interval
test <- to.minutes(x, OHLC=TRUE)
colnames(test) <- c("Open","High","Low","Close")
test
2011-06-07 14:23:00  435  435  435  435   
2011-06-07 14:26:00  430  435  430  435   
2011-06-07 14:32:00  435  435  430  430   
2011-06-07 14:35:00  430  430  430  430 
str(test)
  An ‘xts’ object from 2011-03-10 to 2011-06-08 23:56:00 containing:
  Data: num [1:20426, 1:4] 350 360 375 375 370 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:4] "Open" "High" "Low" "Close"
  Indexed by objects of class: [POSIXct,POSIXt] TZ: 
  xts Attributes:  
 NULL
now I try to use rollapply as follows:
test1<-rollapply(test, width=20, FUN=function(x) {x$xt <-seq(1-nrow(x),0); lm(Close ~poly(xt,4),x)}, by.column=FALSE, align="right")
but that generates
    Error in eval(expr, envir, enclos) : object 'Close' not found
In addition: Warning message:
In x$xt <- seq(1 - nrow(x), 0) : Coercing LHS to a list
 
     
    