[R] Help in R code

Martin Møller Skarbiniks Pedersen tr@xp|@yer @end|ng |rom gm@||@com
Sun Oct 18 13:37:22 CEST 2020


I think you first should read and understand this:
https://stackoverflow.com/help/minimal-reproducible-example
and
https://stackoverflow.com/help/how-to-ask

On Sun, Oct 18, 2020, 11:57 Faheem Jan via R-help <r-help using r-project.org>
wrote:

> Good morning,  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 scores 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 I need help first how to 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]]
>
> ______________________________________________
> 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list