Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. slideFunc<- function(data, window, step){
  2.  
  3. total<- length(data)
  4. spots<- seq(from=1, to=(total-window), by=step)
  5. result<- vector(length=length(spots))
  6.  
  7.  
  8. order.matrix<-matrix(0,nrow = 3, ncol = 6 * 2 * 6)
  9. aic.vec<- numeric(6 * 2 * 6)
  10. k<-1
  11. for(i in 1:length(spots)){
  12. for(p in 0:5) for(d in 0:1) for(q in 0:5){
  13. order.matrix[,k]<-c(p,d,q)
  14. aic.vec[k]<- AIC(arima(data[spots[i]:(spots[i]+window)], order=c(p,d,q)))
  15. k<-k+1
  16. }
  17. ind<- order(aic.vec,decreasing=F)
  18. aic.vec<- aic.vec[ind]
  19. order.matrix<- order.matrix[,ind]
  20. order.matrix<- t(order.matrix)
  21. result<- cbind(order.matrix,aic.vec)
  22. colnames(result)<- c("p","d","q","AIC")
  23. }
  24. return(result)}
  25.  
  26. slideFunc(y,50,1)
  27.  
  28. Error in `[<-`(`*tmp*`, , k, value = c(0L, 0L, 0L)) :
  29. subscript out of bounds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement