[R] Help in R code

Faheem Jan |@heemj@n93 @end|ng |rom y@hoo@com
Sun Oct 4 18:25:12 CEST 2020

Hello , i am working in the functional time series using themultivariate time series data(hourly time series data). Sir  i am usingFAR model more than one order for which no statistical package is available inR, so for this i convert my data into functional form and obtained thefunctional principle component and from those FPCA i extract theircorresponding  FPCscores. Know i use the VAR model on those FPCscores forthe forecasting of each 24 hours through the VAR model, but the VAR give me theforecasted value for all 23hours  when i put phat=23, but whenever i putphat=24 i.e want to predict each 24 hours its give the results in the form ofNA. the code is given below


fdata<- function(mat){

  nb = 27 # number of basis functions for the data

  fbf = create.fourier.basis(rangeval=c(0,1), nbasis=nb) #basis for data


  fdata1=Data2fd(args,y=t(mat),fbf) # functions generatedfrom discretized y



prediction.ffpe = function(fdata1){

  n = ncol(fdata1$coef)

  D = nrow(fdata1$coef)

  #center the data

  #mu = mean.fd(fdata1)

  data = center.fd(fdata1)

  #ffpe = fFPE(fdata1, Pmax=10)

  #p.hat = ffpe[2] #order of the model




  fpca = pca.fd(data,nharm=D, centerfns=TRUE)

  scores = fpca$scores[,0: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=1,type="const")$fcst




kindly guide me that how can i solve out my problem or whaterror i doing. THANKS

	[[alternative HTML version deleted]]

More information about the R-help mailing list