Functional data analysis

I am working on the functional time series, i am trying to extend the "Functional Autoregressive model of order one to high order " by transforming " functional version" into "vector autoregressive model" then i predict the result through function "prediction.ffpe" apply to my data matrix "mat2" and trying to obtained the prediction for the whole year using the "for loop" then i got the following error. Can any body help me that how to solve this error.

prediction.ffpe = function(fdata1){
  n = ncol(fdata1$coef)
  D = nrow(fdata1$coef)
  #center the data
  #mu = mean(fdata1)
  data = center.fd(fdata1)
  fpca = pca.fd(data, nharm=D, centerfns=TRUE)
  scores = fpca$scores[,1:d.hat]
  # to avoid warnings from vars predict function below
  colnames(scores) <- as.character(seq(1:d.hat))
  VAR.pre= predict(VAR(scores, p.hat), n.ahead=365, type="const")$fcst

for(i in 1:365){
  mat2 <- fdata(list[[i]])
  pred.ff1[i,]<- prediction.ffpe(mat2)

i got the error "Error in pred.ff1[i, ] <- prediction.ffpe(mat2) :
incorrect number of subscripts on matrix"


In order for us to help you with your question, please provide us a minimal reproducible example where you provide a minimal (dummy) dataset and code that can recreate the issue. Once we have that, we can go from there. For help on creating a Reprex, see this guide:

Good luck!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.