https://github.com/andybega/ebmahelper
Regular S3 model fitting function and methods for EBMAforecast
https://github.com/andybega/ebmahelper
ebma ebma-forecast ensemble r stacking
Last synced: 5 months ago
JSON representation
Regular S3 model fitting function and methods for EBMAforecast
- Host: GitHub
- URL: https://github.com/andybega/ebmahelper
- Owner: andybega
- License: other
- Created: 2018-09-15T12:09:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-06T08:37:46.000Z (about 4 years ago)
- Last Synced: 2025-01-11T02:53:12.539Z (over 1 year ago)
- Topics: ebma, ebma-forecast, ensemble, r, stacking
- Language: R
- Size: 346 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output:
md_document:
variant: markdown_github
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# EBMAhelper
[](https://travis-ci.org/andybega/EBMAhelper)
[](https://cran.r-project.org/package=EBMAhelper)
[](https://codecov.io/github/andybega/EBMAhelper?branch=master)
EBMAhelper is a wrapper around EBMAforecast ([CRAN](https://cran.r-project.org/web/packages/EBMAforecast/index.html), [GitHub](https://github.com/jmontgomery/EBMAforecast)) 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.
## Installation
```{r installation, eval = FALSE}
library("devtools")
install_github("andybega/EBMAhelper")
```
## Example
A EBMA ensemble can be fitted like this:
```{r example}
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:
```{r}
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)
```