R/predict.foreccomb_res.R
predict.foreccomb_res.Rd
prediction
method for class ‘foreccomb_res’. Uses the previously created forecast combination
result to predict the combination for a newly provided prediction dataset.
# S3 method for foreccomb_res
predict(object, newpreds, newobs = NULL, simplify = TRUE, byrow = FALSE, ...)
An object of class 'foreccomb'. Contains training set (actual values + matrix of model forecasts) and optionally a test set.
A matrix or multivariate time series; contains individual model forecasts if a test set is used (optional). Does not
require specification of newobs
-- in the case in which a forecaster only wants to train the forecast combination method
with a training set and apply it to future individual model forecasts, only newpreds
is required, not newobs
.
A vector or univariate time series; contains ‘actual values’ if a test set is used (optional).
logical. The default (TRUE
) returns the predictions separately. If set to (FALSE
) the predictions are incorporated
into the foreccomb_res object, that is, the object is equal to the one that would have been obtained, if the new prediction set would have
been provided when the forecast combination method was trained originally.
logical. The default (FALSE
) assumes that each column of the forecast matrices (prediction_matrix
and -- if
specified -- newpreds
) contains forecasts from one forecast model; if each row of the matrices contains forecasts from
one forecast model, set to TRUE
.
potential further arguments (require by generic)
obs <- rnorm(100)
preds <- matrix(rnorm(1000, 1), 100, 10)
train_o<-obs[1:80]
train_p<-preds[1:80,]
test_o<-obs[81:100]
test_p<-preds[81:100,]
data<-foreccomb(train_o, train_p)
fit<-comb_BG(data)
predict(fit, test_p)
#> Time Series:
#> Start = 1
#> End = 20
#> Frequency = 1
#> [1] 0.6783830 0.5455408 0.8885312 0.8898982 0.6554237 0.8747893 1.3802368
#> [8] 1.2603138 0.9543416 1.1157954 1.0691121 0.5769513 1.1898955 0.5653080
#> [15] 1.2396253 0.8944000 1.5533536 0.7959007 0.7516111 1.1413354