Description Usage Arguments Value Author(s) Examples
This is the core function of the package. It computes multiple forecasts by the technique of Cross-Validation. The decision about the best models are based on tests as linearity, trend and fit accuracy.
1 | cvforecast(tsdata, tsControl = cvForecastControl(), fcMethod = NULL, ...)
|
tsdata |
data.frame type date-value, ts, mts or xts time series objects |
tsControl |
generic contol with several args for the modelling process. See
|
fcMethod |
accept the forecast method fefined by the user. This argument can be a string or a list, eg. fcMethod = "fc_ets" or a list as fcMethod = list("fc_ets", "fc_hws"). If NULL, decision is made automatically. |
... |
other arguments |
A list of class 'cvforecast' containing several objetcts from the forecasting process. It includes: betso models (less tahn 6), crossValidation statistics for all models, accuracy of all models, the control, etc. As below.
LOPES, J. E.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #Define cross validation parameters
myControl <- cvForecastControl(
minObs = 14,
stepSize = 10,
maxHorizon = 30,
summaryFunc=tsSummary,
cvMethod="MAPE",
tsfrequency='day',
OutlierClean=FALSE,
dateformat='%d/%m/%Y %H:%M:%S')
#Paralell execution improves the processing time
#require(doParallel)
#cl <- makeCluster(4, type='SOCK')
#registerDoParallel(cl)
#Load data
require(plyr)
data(datasample, package="cvforecast")
dadosd <- ConvertData(datasample[,1:6], dateformat='%d/%m/%Y %H:%M:%S', tsfrequency = "day", OutType="ts")
table(sapply(dadosd, class))
dim(dadosd)
#Looping example
FF <- llply(dadosd[,1:2], function(X) {
fit <- try(cvforecast(X, myControl))
if(class(fit) != "try-error") {
#plot(fit)
return(fit)
} else NA
}, .progress = "time")
table(sapply(FF, class))
plot(FF[[1]])
sapply(FF, names)
#stopCluster(cl)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.