[R] help in R code

Faheem Jan |@heemj@n93 @end|ng |rom y@hoo@com
Fri Oct 2 13:57:38 CEST 2020


Hello , i am working in the functional time series using the multivariate time series data(hourly time series data). Sir  i am using FAR model more than one order for which no statistical package is available in R, so for this i convert my data into functional form and obtained the functional principle component and from those FPCA i extract their corresponding  FPCscores. Know i use the VAR model on those FPCscores for the forecasting of each 24 hours through the VAR model, but the VAR give me the forecasted value for all 23hours  when i put phat=23, but whenever i put phat=24 i.e want to predict each 24 hours its give the results in the form of NA. 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  args=seq(0,1,length=24)  fdata1=Data2fd(args,y=t(mat),fbf) # functions generated from discretized y  return(fdata1)}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  d.hat=23  p.hat=6  #fPCA  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 what error i doing. THANKS

	[[alternative HTML version deleted]]



More information about the R-help mailing list