Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thiyangt/fformpp

FFORMPP: Feature-based FORecast Model Performance Prediction
https://github.com/thiyangt/fformpp

Last synced: 8 days ago
JSON representation

FFORMPP: Feature-based FORecast Model Performance Prediction

Awesome Lists containing this project

README

        

---
output: github_document
---

[![Project Status: Active ? The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![Build Status](https://travis-ci.org/thiyangt/fformpp.svg?branch=master)](https://travis-ci.org/thiyangt/fformpp.svg?branch=masterr)

[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)

```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# fformpp

## Installation

The linked packages [flutils](https://github.com/feng-li/flutils) and [movingknots](https://github.com/feng-li/movingknots) should be installed prior to the installation of fformpp.

```r
# install.packages("devtools")
devtools::install_github("thiyangt/fformpp")
library(fformpp)
```

## Usage

### Following example illustrates how package functionalities work

**Load packages**

```{r}
library(methods)
library(MASS)
library(Matrix)
library(mvtnorm)
library(flutils)
library(fformpp)
library(seer)
library(parallel) #getDefaultCluster
```

**Load example dataset**

```r
data(features.df)
data(forecast.error)
features_mat <- as.matrix(features.df)
forecast.error <- as.matrix(forecast.error)
```

**Fit surface regression model**

```r
## This will take time. This model is saved in the package. The fitted model is saved into the package for easy references.
n <- dim(forecast.error)[1]
p <- dim(forecast.error)[2]

fformpp.model <- fit_fformpp(feamat=features_mat, accmat=forecast.error,
sknots=2, aknots=2,
fix.s=0, fix.a=0, fix.shrinkage=1:p, fix.covariance=0,
fix.coefficients=0, n.iter=100,
knot.moving.algorithm="Random-Walk",
ptype=c("identity", "identity", "identity"),
prior.knots=n)

```

**Predict forecast error on new data**

```{r}
data("fformpp.model")
data("forecast.error.m1")
data("features.df.m1")
predict.m1 <- predict_fformpp(fformpp.model, features.df.m1, c("ets", "arima", "rw", "rwd", "wn", "theta", "nn"), log=FALSE, final.estimate=median)
head(predict.m1)
```

**Generate forecast from the model with minimum forecast error**

```{r}
library(Mcomp)
yearlym1 <- subset(M1, "yearly")
data("fcast_m1")
min.fcasterror <- individual_forecast(predicted=predict.m1,
accmat=cal_MASE,
real.error=forecast.error.m1,
tslist=yearlym1,
forecast_list = fcast_m1,
h=6)
min.fcasterror
```

**Generate combination forecasts**

```{r}
library(Mcomp)
yearlym1 <- subset(M1, "yearly")
data("fcast_m1")
min.fcasterror.comb <- combination_forecast(predicted=predict.m1[1:2,],
ncomp=2,
accmat=cal_MASE,
real.error=forecast.error.m1,
tslist=yearlym1,
forecast_list = fcast_m1,
h=6, weights=FALSE, measure="mean")
min.fcasterror.comb
```