[R] help in R code

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Sat Oct 3 01:58:08 CEST 2020


Hi Faheem,
This is a complete guess, but the hours of the day may range from 0 to
23 not 1 to 24. So you may be asking for an out of range hour.

Jim

On Fri, Oct 2, 2020 at 10:00 PM Faheem Jan via R-help
<r-help using r-project.org> wrote:
>
>
> 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]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list