knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
EBMAhelper is a wrapper around EBMAforecast (CRAN, GitHub) that provides some convenience functions more akin to R's conventional model-related functions:
ebma()
to create and fit an EBMA ensemble model; wraps EBMAforecast::makeForecastData
and EBMAforecast::calibrateEnsemble
predict
method for the class "ebma" object returned by ebma()
and a standalone predict()
(TODO) method to aggregate new forecasts.
library("devtools") install_github("andybega/EBMAhelper")
A EBMA ensemble can be fitted like this:
suppressMessages({ library("EBMAforecast") library("EBMAhelper") }) data("presidentialForecast") head(presidentialForecast) str(presidentialForecast) fitted_ensemble <- ebma(y = presidentialForecast[ ,7], x = presidentialForecast[ ,c(1:6)], model_type = "normal") summary(fitted_ensemble)
To do the same with EBMAforecast
is slightly more verbose and does not follow R's model fitting conventions. The following code is adapted from the package demo:
data("presidentialForecast") full.forecasts <- presidentialForecast[, c(1:6)] full.observed <- presidentialForecast[, 7] this.ForecastData <- makeForecastData( .predCalibration=full.forecasts[1:12,], .outcomeCalibration=full.observed[1:12], .predTest=full.forecasts[13:15,], .outcomeTest=full.observed[13:15], .modelNames=c("Campbell", "Lewis-Beck","EWT2C2","Fair","Hibbs","Abramowitz")) thisEnsemble <- calibrateEnsemble(this.ForecastData, model="normal", useModelParams=FALSE, tol = 0.000000001, const = 0) summary(thisEnsemble)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.