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]] ______________________________________________ [hidden email] 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. |
1) If you get help on this mailing list, it will generally be from someone like yourself... not an "administrator".
2) You desperately need to learn how to send your emails to this list in plain text format... See [1] to see how WE see your html-formatted email run through a blender. Sending in plain text is a setting in your email client... there are way too many client software packages out there for us to be able to help you figure that out. 3) Read the Posting Guide mentioned at the bottom of every email on this mailing list. One of the items you should note is that homework help is off-topic here. (We don't know what help would break the ethics rules of your educational institution, and they by definition have avenues for student assistance.) 4) This is not a "do my work for me" service. If you want non-homework help, post a reproducible example using plain text so we can quickly get an R session setup with your problem data and (broken?) code. [2][3][4] [1] https://stat.ethz.ch/pipermail/r-help/2020-October/469056.html [2] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example [3] http://adv-r.had.co.nz/Reproducibility.html [4] https://cran.r-project.org/web/packages/reprex/index.html (read the vignette) On October 13, 2020 8:42:08 PM PDT, Faheem Jan via R-help <[hidden email]> wrote: > >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]] > >______________________________________________ >[hidden email] 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. -- Sent from my phone. Please excuse my brevity. ______________________________________________ [hidden email] 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. |
Free forum by Nabble | Edit this page |