[R] Help in Coding

Faheem Jan |@heemj@n93 @end|ng |rom y@hoo@com
Wed Oct 14 05:42:08 CEST 2020


Good morning dear administrators,
Please help me to code this code in R.
I working in the multivariate time series data, know my objective is that to one year forecast of the hourly time series data, using first five as a training set and the remaining one year as validation. For this  I transform the the data into functional data through Fourier basis functional, apply functional principle components as dimensional reduction explaining a specific amount of variation   , using the corresponding  functional principle components scores. I use the VAR model on those FPCscores for forecasting one day ahead forecast, know my problem is that i choose four Fpc,s which give only four value in a single day, I want the forecast for 24 hours not only 4, and then i want to transform it back to the original functional data. for the understanding i am sharing my code (1) transform of the multivariate time series data in functional data(2) the functional principle components and the corresponding scores(3) I use functional final prediction error for the selection of the parameters on the VAR model(4) Using VAR for the analysis and forecasting .(1) nb = 23 # 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(2) ffpe = fFPE(fdata1, Pmax=10)  d.hat = ffpe[1] #order of the model  p.hat = ffpe[2] #lag of the model
(3) n = ncol(fdata1$coef)  D = nrow(fdata1$coef)  #center the data  mu = mean.fd(fdata1)  data = center.fd(fdata1)  #fPCA  fpca = pca.fd(data,nharm=D)  scores = fpca$scores[,1:d.hat](4) # 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
after this iIneed help first how i transform this into original Functional data and to obtain the for for each 24 hours (mean one day forecast) and to how to generalize the result for one year.

	[[alternative HTML version deleted]]



More information about the R-help mailing list