forecastLM: Forecast trainML Model

Description Usage Arguments Examples

View source: R/forecast_functions.R

Description

Forecast trainML models

Usage

1
forecastLM(model, newdata = NULL, h, pi = c(0.95, 0.8))

Arguments

model

A trainLM object

newdata

A tsibble object, must be used when the input model was trained with external inputs (i.e., the 'x' argument of the trainML function was used). This input must follow the following structure:

- Use the same time intervals (monthly, daily, hourly, etc.) structure and timestamp class (e.g., yearquarter, yearmonth, POSIXct, etc.) as the original input

- The number of observations must align with the forecasting horizon (the 'h' argument)

- The timestamp of the first observation must be the consecutive observation of the last observation of the original series

h

An integer, define the forecast horizon

pi

A vector with numeric values between 0 and 1, define the level of the confidence of the prediction intervals of the forecast. By default calculate the 80% and 95% prediction intervals

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(ny_gas)

head(ny_gas)

# Training a model
md <- trainLM(input = ny_gas,
              y = "y",
              trend = list(linear = TRUE),
              seasonal = "month",
              lags = c(1, 12))

# Forecasting the future observations
fc <- forecastLM(model = md,
                 h = 60)

# Plotting the forecast
plot_fc(fc)

RamiKrispin/forecastLM documentation built on April 4, 2020, 1:48 a.m.