This function uses the component model forecasts and dependent variable observations provided by the user to create an object of class ForecastData, which can then be used to calibrate and fit the ensemble. Individual slots of the ForecastData object can be accessed and changed using the get and set functions respectively. Missing predictions are allowed in the calibration set.
A matrix with the number of rows being the number of observations in the calibration period and a column with calibration period predictions for each model.
.predTest
A vector with the number of rows being the number of observations in the test period and a column with test period predictions for each model.
.outcomeCalibration
A vector with the true values of the dependent variable for each observation in the calibration period.
.outcomeTest
A vector with the true values of the dependent variable for each observation in the test period.
.modelNames
A vector of length p with the names of the component models.
...
Additional arguments not implemented
Additionally, the functions show and print can be used to display data objects of class 'ForecastData'.
show displays only 1 digit and takes the following parameters:
x
A data object of class 'ForecastData'
print let's the use specify the number of digits printed and takes the arguments:
digits
User specified number of digits to be displayed.
object
A data object of class 'ForecastData'
Value
A data object of the class 'ForecastData' with the following slots:
predCalibration
An array containing the predictions of all component models for all observations in the calibration period.
predTest
An array containing the predictions of all component models for all observations in the test period.
outcomeCalibration
A vector containing the true values of the dependent variable for all observations in the calibration period.
outcomeTest
A vector containing the true values of the dependent variable for all observations in the test period.
modelNames
A character vector containing the names of all component models. If no model names are specified, names will be assigned automatically.
Montgomery, Jacob M., Florian M. Hollenbach and Michael D. Ward. (2015). Calibrating ensemble forecasting models with sparse data in the social sciences. International Journal of Forecasting. In Press.
Montgomery, Jacob M., Florian M. Hollenbach and Michael D. Ward. (2012). Improving Predictions Using Ensemble Bayesian Model Averaging. Political Analysis. 20: 271-291.
See Also
ensembleBMA
Examples
data(calibrationSample)
## Not run: data(testSample)
this.ForecastData <- makeForecastData(.predCalibration=calibrationSample[,c("LMER", "SAE", "GLM")],
.outcomeCalibration=calibrationSample[,"Insurgency"],.predTest=testSample[,c("LMER", "SAE", "GLM")],
.outcomeTest=testSample[,"Insurgency"], .modelNames=c("LMER", "SAE", "GLM"))
### to acces individual slots in the ForecastData object
getPredCalibration(this.ForecastData)
getOutcomeCalibration(this.ForecastData)
getPredTest(this.ForecastData)
getOutcomeTest(this.ForecastData)
getModelNames(this.ForecastData)
### to assign individual slots, use set functions
setPredCalibration(this.ForecastData)<-calibrationSample[,c("LMER", "SAE", "GLM")]
setOutcomeCalibration(this.ForecastData)<-calibrationSample[,"Insurgency"]
setPredTest(this.ForecastData)<-testSample[,c("LMER", "SAE", "GLM")]
setOutcomeTest(this.ForecastData)<-testSample[,"Insurgency"]
setModelNames(this.ForecastData)<-c("LMER", "SAE", "GLM")
## End(Not run)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(EBMAforecast)
Loading required package: separationplot
Loading required package: plyr
Loading required package: Hmisc
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2
Attaching package: 'Hmisc'
The following objects are masked from 'package:plyr':
is.discrete, summarize
The following objects are masked from 'package:base':
format.pval, round.POSIXt, trunc.POSIXt, units
Loading required package: abind
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/EBMAforecast/makeForecastData.Rd_%03d_medium.png", width=480, height=480)
> ### Name: makeForecastData
> ### Title: Build a ensemble forecasting data object
> ### Aliases: ForecastData-generic ForecastData-method makeForecastData
> ### makeForecastData,ANY-method makeForecastData-method,
> ### print,ForecastData-method print-method, setModelNames<-,
> ### setOutcomeCalibration, setOutcomeTest<-, setPredCalibration,
> ### setPredTest, show,ForecastData-method show-method
>
> ### ** Examples
>
> data(calibrationSample)
>
> ## Not run:
> ##D data(testSample)
> ##D this.ForecastData <- makeForecastData(.predCalibration=calibrationSample[,c("LMER", "SAE", "GLM")],
> ##D .outcomeCalibration=calibrationSample[,"Insurgency"],.predTest=testSample[,c("LMER", "SAE", "GLM")],
> ##D .outcomeTest=testSample[,"Insurgency"], .modelNames=c("LMER", "SAE", "GLM"))
> ##D
> ##D ### to acces individual slots in the ForecastData object
> ##D getPredCalibration(this.ForecastData)
> ##D getOutcomeCalibration(this.ForecastData)
> ##D getPredTest(this.ForecastData)
> ##D getOutcomeTest(this.ForecastData)
> ##D getModelNames(this.ForecastData)
> ##D
> ##D ### to assign individual slots, use set functions
> ##D
> ##D setPredCalibration(this.ForecastData)<-calibrationSample[,c("LMER", "SAE", "GLM")]
> ##D setOutcomeCalibration(this.ForecastData)<-calibrationSample[,"Insurgency"]
> ##D setPredTest(this.ForecastData)<-testSample[,c("LMER", "SAE", "GLM")]
> ##D setOutcomeTest(this.ForecastData)<-testSample[,"Insurgency"]
> ##D setModelNames(this.ForecastData)<-c("LMER", "SAE", "GLM")
> ## End(Not run)
>
>
>
>
>
>
> dev.off()
null device
1
>