Title: | Forecasting Models for Tidy Time Series |
---|---|
Description: | Provides a collection of commonly used univariate and multivariate time series forecasting models including automatically selected exponential smoothing (ETS) and autoregressive integrated moving average (ARIMA) models. These models work within the 'fable' framework provided by the 'fabletools' package, which provides the tools to evaluate, visualise, and combine models in a workflow consistent with the tidyverse. |
Authors: | Mitchell O'Hara-Wild [aut, cre], Rob Hyndman [aut], Earo Wang [aut], Gabriel Caceres [ctb] (NNETAR implementation), Christoph Bergmeir [ctb] , Tim-Gunnar Hensel [ctb], Timothy Hyndman [ctb] |
Maintainer: | Mitchell O'Hara-Wild <[email protected]> |
License: | GPL-3 |
Version: | 0.4.1 |
Built: | 2024-11-06 09:29:24 UTC |
Source: | CRAN |
Searches through the vector of lag orders to find the best AR model which
has lowest AIC, AICc or BIC value. It is implemented using OLS, and behaves
comparably to stats::ar.ols()
.
AR(formula, ic = c("aicc", "aic", "bic"), ...)
AR(formula, ic = c("aicc", "aic", "bic"), ...)
formula |
Model specification (see "Specials" section). |
ic |
The information criterion used in selecting the model. |
... |
Further arguments for arima |
Exogenous regressors and common_xregs
can be specified in the model
formula.
A model specification.
The order
special is used to specify the lag order for the auto-regression.
order(p = 0:15, fixed = list())
p |
The order of the auto-regressive (AR) terms. If multiple values are provided, the one which minimises ic will be chosen. |
fixed |
A named list of fixed parameters for coefficients. The names identify the coefficient, beginning with ar , and then followed by the lag order. For example, fixed = list(ar1 = 0.3, ar3 = 0) .
|
Exogenous regressors can be included in an AR model without explicitly using the xreg()
special. Common exogenous regressor specials as specified in common_xregs
can also be used. These regressors are handled using stats::model.frame()
, and so interactions and other functionality behaves similarly to stats::lm()
.
The inclusion of a constant in the model follows the similar rules to stats::lm()
, where including 1
will add a constant and 0
or -1
will remove the constant. If left out, the inclusion of a constant will be determined by minimising ic
.
xreg(..., fixed = list())
... |
Bare expressions for the exogenous regressors (such as log(x) ) |
fixed |
A named list of fixed parameters for coefficients. The names identify the coefficient, and should match the name of the regressor. For example, fixed = list(constant = 20) .
|
Forecasting: Principles and Practices, Vector autoregressions (section 11.2)
luteinizing_hormones <- as_tsibble(lh) fit <- luteinizing_hormones %>% model(AR(value ~ order(3))) report(fit) fit %>% forecast() %>% autoplot(luteinizing_hormones)
luteinizing_hormones <- as_tsibble(lh) fit <- luteinizing_hormones %>% model(AR(value ~ order(3))) report(fit) fit %>% forecast() %>% autoplot(luteinizing_hormones)
Searches through the model space specified in the specials to identify the
best ARIMA model, with the lowest AIC, AICc or BIC value. It is implemented
using stats::arima()
and allows ARIMA models to be used in the fable
framework.
ARIMA( formula, ic = c("aicc", "aic", "bic"), selection_metric = function(x) x[[ic]], stepwise = TRUE, greedy = TRUE, approximation = NULL, order_constraint = p + q + P + Q <= 6 & (constant + d + D <= 2), unitroot_spec = unitroot_options(), trace = FALSE, ... )
ARIMA( formula, ic = c("aicc", "aic", "bic"), selection_metric = function(x) x[[ic]], stepwise = TRUE, greedy = TRUE, approximation = NULL, order_constraint = p + q + P + Q <= 6 & (constant + d + D <= 2), unitroot_spec = unitroot_options(), trace = FALSE, ... )
formula |
Model specification (see "Specials" section). |
ic |
The information criterion used in selecting the model. |
selection_metric |
A function used to compute a metric from an |
stepwise |
Should stepwise be used? (Stepwise can be much faster) |
greedy |
Should the stepwise search move to the next best option immediately? |
approximation |
Should CSS (conditional sum of squares) be used during model
selection? The default ( |
order_constraint |
A logical predicate on the orders of |
unitroot_spec |
A specification of unit root tests to use in the
selection of |
trace |
If |
... |
Further arguments for |
A model specification.
The fable ARIMA()
function uses an alternative parameterisation of
constants to stats::arima()
and forecast::Arima()
. While the
parameterisations are equivalent, the coefficients for the constant/mean
will differ.
In fable
, if there are no exogenous regressors, the parameterisation used
is:
In stats and forecast, an ARIMA model is parameterised as:
where is the mean of
and
.
If there are exogenous regressors, fable
uses the same parameterisation as
used in stats and forecast. That is, it fits a regression with ARIMA(p,d,q)
errors:
where is a vector of regression coefficients,
is
a vector of exogenous regressors at time
, and
is an
ARIMA(p,d,q) error process:
For details of the estimation algorithm, see the
arima
function in the stats package.
The specials define the space over which ARIMA
will search for the model that best fits the data. If the RHS of formula
is left blank, the default search space is given by pdq() + PDQ()
: that is, a model with candidate seasonal and nonseasonal terms, but no exogenous regressors. Note that a seasonal model requires at least 2 full seasons of data; if this is not available, ARIMA
will revert to a nonseasonal model with a warning.
To specify a model fully (avoid automatic selection), the intercept and pdq()/PDQ()
values must be specified. For example, formula = response ~ 1 + pdq(1, 1, 1) + PDQ(1, 0, 0)
.
The pdq
special is used to specify non-seasonal components of the model.
pdq(p = 0:5, d = 0:2, q = 0:5, p_init = 2, q_init = 2, fixed = list())
p |
The order of the non-seasonal auto-regressive (AR) terms. If multiple values are provided, the one which minimises ic will be chosen. |
d |
The order of integration for non-seasonal differencing. If multiple values are provided, one of the values will be selected via repeated KPSS tests. |
q |
The order of the non-seasonal moving average (MA) terms. If multiple values are provided, the one which minimises ic will be chosen. |
p_init |
If stepwise = TRUE , p_init provides the initial value for p for the stepwise search procedure. |
q_init |
If stepwise = TRUE , q_init provides the initial value for q for the stepwise search procedure. |
fixed |
A named list of fixed parameters for coefficients. The names identify the coefficient, beginning with either ar or ma , followed by the lag order. For example, fixed = list(ar1 = 0.3, ma2 = 0) .
|
The PDQ
special is used to specify seasonal components of the model. To force a non-seasonal fit, specify PDQ(0, 0, 0)
in the RHS of the model formula. Note that simply omitting PDQ
from the formula will not result in a non-seasonal fit.
PDQ(P = 0:2, D = 0:1, Q = 0:2, period = NULL, P_init = 1, Q_init = 1, fixed = list())
P |
The order of the seasonal auto-regressive (SAR) terms. If multiple values are provided, the one which minimises ic will be chosen. |
D |
The order of integration for seasonal differencing. If multiple values are provided, one of the values will be selected via repeated heuristic tests (based on strength of seasonality from an STL decomposition). |
Q |
The order of the seasonal moving average (SMA) terms. If multiple values are provided, the one which minimises ic will be chosen. |
period |
The periodic nature of the seasonality. This can be either a number indicating the number of observations in each seasonal period, or text to indicate the duration of the seasonal window (for example, annual seasonality would be "1 year"). |
P_init |
If stepwise = TRUE , P_init provides the initial value for P for the stepwise search procedure. |
Q_init |
If stepwise = TRUE , Q_init provides the initial value for Q for the stepwise search procedure. |
fixed |
A named list of fixed parameters for coefficients. The names identify the coefficient, beginning with either sar or sma , followed by the lag order. For example, fixed = list(sar1 = 0.1) .
|
Exogenous regressors can be included in an ARIMA model without explicitly using the xreg()
special. Common exogenous regressor specials as specified in common_xregs
can also be used. These regressors are handled using stats::model.frame()
, and so interactions and other functionality behaves similarly to stats::lm()
.
The inclusion of a constant in the model follows the similar rules to stats::lm()
, where including 1
will add a constant and 0
or -1
will remove the constant. If left out, the inclusion of a constant will be determined by minimising ic
.
xreg(..., fixed = list())
... |
Bare expressions for the exogenous regressors (such as log(x) ) |
fixed |
A named list of fixed parameters for coefficients. The names identify the coefficient, and should match the name of the regressor. For example, fixed = list(constant = 20) .
|
Forecasting: Principles and Practices, ARIMA models (chapter 9) Forecasting: Principles and Practices, Dynamic regression models (chapter 10)
# Manual ARIMA specification USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ 0 + pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% report() # Automatic ARIMA specification library(tsibble) library(dplyr) tsibbledata::global_economy %>% filter(Country == "Australia") %>% model(ARIMA(log(GDP) ~ Population))
# Manual ARIMA specification USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ 0 + pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% report() # Automatic ARIMA specification library(tsibble) library(dplyr) tsibbledata::global_economy %>% filter(Country == "Australia") %>% model(ARIMA(log(GDP) ~ Population))
Breusch-Godfrey test for higher-order serial correlation.
breusch_godfrey(x, ...) ## S3 method for class 'TSLM' breusch_godfrey(x, order = 1, type = c("Chisq", "F"), ...)
breusch_godfrey(x, ...) ## S3 method for class 'TSLM' breusch_godfrey(x, order = 1, type = c("Chisq", "F"), ...)
x |
A model object to be tested. |
... |
Further arguments for methods. |
order |
The maximum order of serial correlation to test for. |
type |
The type of test statistic to use. |
Extract estimated states from an ETS model.
## S3 method for class 'ETS' components(object, ...)
## S3 method for class 'ETS' components(object, ...)
object |
An estimated model. |
... |
Unused. |
A fabletools::dable()
containing estimated states.
as_tsibble(USAccDeaths) %>% model(ets = ETS(log(value) ~ season("A"))) %>% components()
as_tsibble(USAccDeaths) %>% model(ets = ETS(log(value) ~ season("A"))) %>% components()
Based on Croston's (1972) method for intermittent demand forecasting, also described in Shenstone and Hyndman (2005). Croston's method involves using simple exponential smoothing (SES) on the non-zero elements of the time series and a separate application of SES to the times between non-zero elements of the time series.
CROSTON( formula, opt_crit = c("mse", "mae"), type = c("croston", "sba", "sbj"), ... )
CROSTON( formula, opt_crit = c("mse", "mae"), type = c("croston", "sba", "sbj"), ... )
formula |
Model specification (see "Specials" section). |
opt_crit |
The optimisation criterion used to optimise the parameters. |
type |
Which variant of Croston's method to use. Defaults to |
... |
Not used. |
Note that forecast distributions are not computed as Croston's method has no underlying stochastic model. In a later update, we plan to support distributions via the equivalent stochastic models that underly Croston's method (Shenstone and Hyndman, 2005)
There are two variant methods available which apply multiplicative correction factors
to the forecasts that result from the original Croston's method. For the
Syntetos-Boylan approximation (type = "sba"
), this factor is ,
and for the Shale-Boylan-Johnston method (
type = "sbj"
), this factor is
, where
is the smoothing parameter for
the interval SES application.
A model specification.
The demand
special specifies parameters for the demand SES application.
demand(initial = NULL, param = NULL, param_range = c(0, 1))
initial |
The initial value for the demand application of SES. |
param |
The smoothing parameter for the demand application of SES. |
param_range |
If param = NULL , the range of values over which to search for the smoothing parameter.
|
The interval
special specifies parameters for the interval SES application.
interval(initial = NULL, param = NULL, param_range = c(0, 1))
initial |
The initial value for the interval application of SES. |
param |
The smoothing parameter for the interval application of SES. |
param_range |
If param = NULL , the range of values over which to search for the smoothing parameter.
|
Croston, J. (1972) "Forecasting and stock control for intermittent demands", Operational Research Quarterly, 23(3), 289-303.
Shenstone, L., and Hyndman, R.J. (2005) "Stochastic models underlying Croston's method for intermittent demand forecasting". Journal of Forecasting, 24, 389-402.
Kourentzes, N. (2014) "On intermittent demand model optimisation and selection". International Journal of Production Economics, 156, 180-190. doi:10.1016/j.ijpe.2014.06.007.
library(tsibble) sim_poisson <- tsibble( time = yearmonth("2012 Dec") + seq_len(24), count = rpois(24, lambda = 0.3), index = time ) sim_poisson %>% autoplot(count) sim_poisson %>% model(CROSTON(count)) %>% forecast(h = "2 years") %>% autoplot(sim_poisson)
library(tsibble) sim_poisson <- tsibble( time = yearmonth("2012 Dec") + seq_len(24), count = rpois(24, lambda = 0.3), index = time ) sim_poisson %>% autoplot(count) sim_poisson %>% model(CROSTON(count)) %>% forecast(h = "2 years") %>% autoplot(sim_poisson)
Returns ETS model specified by the formula.
ETS( formula, opt_crit = c("lik", "amse", "mse", "sigma", "mae"), nmse = 3, bounds = c("both", "usual", "admissible"), ic = c("aicc", "aic", "bic"), restrict = TRUE, ... )
ETS( formula, opt_crit = c("lik", "amse", "mse", "sigma", "mae"), nmse = 3, bounds = c("both", "usual", "admissible"), ic = c("aicc", "aic", "bic"), restrict = TRUE, ... )
formula |
Model specification (see "Specials" section). |
opt_crit |
The optimization criterion. Defaults to the log-likelihood
|
nmse |
If |
bounds |
Type of parameter space to impose: |
ic |
The information criterion used in selecting the model. |
restrict |
If TRUE (default), the models with infinite variance will not be allowed. These restricted model components are AMM, AAM, AMA, and MMA. |
... |
Other arguments |
Based on the classification of methods as described in Hyndman et al (2008).
The methodology is fully automatic. The model is chosen automatically if not specified. This methodology performed extremely well on the M3-competition data. (See Hyndman, et al, 2002, below.)
A model specification.
The specials define the methods and parameters for the components (error, trend, and seasonality) of an ETS model. If more than one method is specified, ETS
will consider all combinations of the specified models and select the model which best fits the data (minimising ic
). The method argument for each specials have reasonable defaults, so if a component is not specified an appropriate method will be chosen automatically.
There are a couple of limitations to note about ETS models:
It does not support exogenous regressors.
It does not support missing values. You can complete missing values in the data with imputed values (e.g. with tidyr::fill()
, or by fitting a different model type and then calling fabletools::interpolate()
) before fitting the model.
The error
special is used to specify the form of the error term.
error(method = c("A", "M"))
method |
The form of the error term: either additive ("A") or multiplicative ("M"). If the error is multiplicative, the data must be non-negative. All specified methods are tested on the data, and the one that gives the best fit (lowest ic ) will be kept.
|
The trend
special is used to specify the form of the trend term and associated parameters.
trend(method = c("N", "A", "Ad"), alpha = NULL, alpha_range = c(1e-04, 0.9999), beta = NULL, beta_range = c(1e-04, 0.9999), phi = NULL, phi_range = c(0.8, 0.98))
method |
The form of the trend term: either none ("N"), additive ("A"), multiplicative ("M") or damped variants ("Ad", "Md"). All specified methods are tested on the data, and the one that gives the best fit (lowest ic ) will be kept. |
alpha |
The value of the smoothing parameter for the level. If alpha = 0 , the level will not change over time. Conversely, if alpha = 1 the level will update similarly to a random walk process. |
alpha_range |
If alpha=NULL , alpha_range provides bounds for the optimised value of alpha . |
beta |
The value of the smoothing parameter for the slope. If beta = 0 , the slope will not change over time. Conversely, if beta = 1 the slope will have no memory of past slopes. |
beta_range |
If beta=NULL , beta_range provides bounds for the optimised value of beta . |
phi |
The value of the dampening parameter for the slope. If phi = 0 , the slope will be dampened immediately (no slope). Conversely, if phi = 1 the slope will not be dampened. |
phi_range |
If phi=NULL , phi_range provides bounds for the optimised value of phi .
|
The season
special is used to specify the form of the seasonal term and associated parameters. To specify a nonseasonal model you would include season(method = "N")
.
season(method = c("N", "A", "M"), period = NULL, gamma = NULL, gamma_range = c(1e-04, 0.9999))
method |
The form of the seasonal term: either none ("N"), additive ("A") or multiplicative ("M"). All specified methods are tested on the data, and the one that gives the best fit (lowest ic ) will be kept. |
period |
The periodic nature of the seasonality. This can be either a number indicating the number of observations in each seasonal period, or text to indicate the duration of the seasonal window (for example, annual seasonality would be "1 year"). |
gamma |
The value of the smoothing parameter for the seasonal pattern. If gamma = 0 , the seasonal pattern will not change over time. Conversely, if gamma = 1 the seasonality will have no memory of past seasonal periods. |
gamma_range |
If gamma=NULL , gamma_range provides bounds for the optimised value of gamma .
|
Hyndman, R.J., Koehler, A.B., Snyder, R.D., and Grose, S. (2002) "A state space framework for automatic forecasting using exponential smoothing methods", International J. Forecasting, 18(3), 439–454.
Hyndman, R.J., Akram, Md., and Archibald, B. (2008) "The admissible parameter space for exponential smoothing models". Annals of Statistical Mathematics, 60(2), 407–426.
Hyndman, R.J., Koehler, A.B., Ord, J.K., and Snyder, R.D. (2008) Forecasting with exponential smoothing: the state space approach, Springer-Verlag. http://www.exponentialsmoothing.net.
Forecasting: Principles and Practices, Exponential smoothing (chapter 8)
as_tsibble(USAccDeaths) %>% model(ETS(log(value) ~ season("A")))
as_tsibble(USAccDeaths) %>% model(ETS(log(value) ~ season("A")))
Extracts the fitted values.
## S3 method for class 'AR' fitted(object, ...)
## S3 method for class 'AR' fitted(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted values.
as_tsibble(lh) %>% model(AR(value ~ order(3))) %>% fitted()
as_tsibble(lh) %>% model(AR(value ~ order(3))) %>% fitted()
Extracts the fitted values.
## S3 method for class 'ARIMA' fitted(object, ...)
## S3 method for class 'ARIMA' fitted(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted values.
USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% fitted()
USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% fitted()
Extracts the fitted values.
## S3 method for class 'croston' fitted(object, ...)
## S3 method for class 'croston' fitted(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted values.
library(tsibble) sim_poisson <- tsibble( time = yearmonth("2012 Dec") + seq_len(24), count = rpois(24, lambda = 0.3), index = time ) sim_poisson %>% model(CROSTON(count)) %>% tidy()
library(tsibble) sim_poisson <- tsibble( time = yearmonth("2012 Dec") + seq_len(24), count = rpois(24, lambda = 0.3), index = time ) sim_poisson %>% model(CROSTON(count)) %>% tidy()
Extracts the fitted values.
## S3 method for class 'ETS' fitted(object, ...)
## S3 method for class 'ETS' fitted(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted values.
as_tsibble(USAccDeaths) %>% model(ets = ETS(log(value) ~ season("A"))) %>% fitted()
as_tsibble(USAccDeaths) %>% model(ets = ETS(log(value) ~ season("A"))) %>% fitted()
Extracts the fitted values.
## S3 method for class 'fable_theta' fitted(object, ...)
## S3 method for class 'fable_theta' fitted(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted values.
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% fitted()
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% fitted()
Extracts the fitted values.
## S3 method for class 'model_mean' fitted(object, ...)
## S3 method for class 'model_mean' fitted(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted values.
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% fitted()
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% fitted()
Extracts the fitted values.
## S3 method for class 'NNETAR' fitted(object, ...)
## S3 method for class 'NNETAR' fitted(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted values.
as_tsibble(airmiles) %>% model(nn = NNETAR(box_cox(value, 0.15))) %>% fitted()
as_tsibble(airmiles) %>% model(nn = NNETAR(box_cox(value, 0.15))) %>% fitted()
Extracts the fitted values.
## S3 method for class 'RW' fitted(object, ...)
## S3 method for class 'RW' fitted(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted values.
as_tsibble(Nile) %>% model(NAIVE(value)) %>% fitted() library(tsibbledata) aus_production %>% model(snaive = SNAIVE(Beer ~ lag("year"))) %>% fitted()
as_tsibble(Nile) %>% model(NAIVE(value)) %>% fitted() library(tsibbledata) aus_production %>% model(snaive = SNAIVE(Beer ~ lag("year"))) %>% fitted()
Extracts the fitted values.
## S3 method for class 'TSLM' fitted(object, ...)
## S3 method for class 'TSLM' fitted(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted values.
as_tsibble(USAccDeaths) %>% model(lm = TSLM(log(value) ~ trend() + season())) %>% fitted()
as_tsibble(USAccDeaths) %>% model(lm = TSLM(log(value) ~ trend() + season())) %>% fitted()
Extracts the fitted values.
## S3 method for class 'VAR' fitted(object, ...)
## S3 method for class 'VAR' fitted(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted values.
lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) lung_deaths %>% model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) %>% fitted()
lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) lung_deaths %>% model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) %>% fitted()
Produces forecasts from a trained model.
## S3 method for class 'AR' forecast( object, new_data = NULL, specials = NULL, bootstrap = FALSE, times = 5000, ... )
## S3 method for class 'AR' forecast( object, new_data = NULL, specials = NULL, bootstrap = FALSE, times = 5000, ... )
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
bootstrap |
If |
times |
The number of sample paths to use in estimating the forecast distribution when |
... |
Other arguments passed to methods |
A list of forecasts.
as_tsibble(lh) %>% model(AR(value ~ order(3))) %>% forecast()
as_tsibble(lh) %>% model(AR(value ~ order(3))) %>% forecast()
Produces forecasts from a trained model.
## S3 method for class 'ARIMA' forecast( object, new_data = NULL, specials = NULL, bootstrap = FALSE, times = 5000, ... )
## S3 method for class 'ARIMA' forecast( object, new_data = NULL, specials = NULL, bootstrap = FALSE, times = 5000, ... )
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
bootstrap |
If |
times |
The number of sample paths to use in estimating the forecast distribution when |
... |
Other arguments passed to methods |
A list of forecasts.
USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% forecast()
USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% forecast()
Produces forecasts from a trained model.
## S3 method for class 'croston' forecast(object, new_data, specials = NULL, ...)
## S3 method for class 'croston' forecast(object, new_data, specials = NULL, ...)
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
... |
Other arguments passed to methods |
A list of forecasts.
library(tsibble) sim_poisson <- tsibble( time = yearmonth("2012 Dec") + seq_len(24), count = rpois(24, lambda = 0.3), index = time ) sim_poisson %>% model(CROSTON(count)) %>% forecast()
library(tsibble) sim_poisson <- tsibble( time = yearmonth("2012 Dec") + seq_len(24), count = rpois(24, lambda = 0.3), index = time ) sim_poisson %>% model(CROSTON(count)) %>% forecast()
Produces forecasts from a trained model.
## S3 method for class 'ETS' forecast( object, new_data, specials = NULL, simulate = FALSE, bootstrap = FALSE, times = 5000, ... )
## S3 method for class 'ETS' forecast( object, new_data, specials = NULL, simulate = FALSE, bootstrap = FALSE, times = 5000, ... )
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
simulate |
If |
bootstrap |
If |
times |
The number of sample paths to use in estimating the forecast distribution if simulated intervals are used. |
... |
Other arguments passed to methods |
A list of forecasts.
as_tsibble(USAccDeaths) %>% model(ets = ETS(log(value) ~ season("A"))) %>% forecast()
as_tsibble(USAccDeaths) %>% model(ets = ETS(log(value) ~ season("A"))) %>% forecast()
Produces forecasts from a trained model.
## S3 method for class 'fable_theta' forecast( object, new_data, specials = NULL, bootstrap = FALSE, times = 5000, ... )
## S3 method for class 'fable_theta' forecast( object, new_data, specials = NULL, bootstrap = FALSE, times = 5000, ... )
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
bootstrap |
If |
times |
The number of sample paths to use in estimating the forecast distribution when |
... |
Other arguments passed to methods |
A list of forecasts.
USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% forecast()
USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% forecast()
Produces forecasts from a trained model.
## S3 method for class 'model_mean' forecast( object, new_data, specials = NULL, bootstrap = FALSE, times = 5000, ... )
## S3 method for class 'model_mean' forecast( object, new_data, specials = NULL, bootstrap = FALSE, times = 5000, ... )
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
bootstrap |
If |
times |
The number of sample paths to use in estimating the forecast distribution when |
... |
Other arguments passed to methods |
A list of forecasts.
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% forecast()
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% forecast()
Produces forecasts from a trained model.
## S3 method for class 'NNETAR' forecast( object, new_data, specials = NULL, simulate = TRUE, bootstrap = FALSE, times = 5000, ... )
## S3 method for class 'NNETAR' forecast( object, new_data, specials = NULL, simulate = TRUE, bootstrap = FALSE, times = 5000, ... )
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
simulate |
If |
bootstrap |
If |
times |
The number of sample paths to use in producing the forecast distribution. Setting |
... |
Other arguments passed to methods |
A list of forecasts.
as_tsibble(airmiles) %>% model(nn = NNETAR(box_cox(value, 0.15))) %>% forecast(times = 10)
as_tsibble(airmiles) %>% model(nn = NNETAR(box_cox(value, 0.15))) %>% forecast(times = 10)
Produces forecasts from a trained model.
## S3 method for class 'RW' forecast( object, new_data, specials = NULL, simulate = FALSE, bootstrap = FALSE, times = 5000, ... )
## S3 method for class 'RW' forecast( object, new_data, specials = NULL, simulate = FALSE, bootstrap = FALSE, times = 5000, ... )
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
simulate |
If |
bootstrap |
If |
times |
The number of sample paths to use in estimating the forecast distribution when |
... |
Other arguments passed to methods |
A list of forecasts.
as_tsibble(Nile) %>% model(NAIVE(value)) %>% forecast() library(tsibbledata) aus_production %>% model(snaive = SNAIVE(Beer ~ lag("year"))) %>% forecast()
as_tsibble(Nile) %>% model(NAIVE(value)) %>% forecast() library(tsibbledata) aus_production %>% model(snaive = SNAIVE(Beer ~ lag("year"))) %>% forecast()
Produces forecasts from a trained model.
## S3 method for class 'TSLM' forecast( object, new_data, specials = NULL, bootstrap = FALSE, approx_normal = TRUE, times = 5000, ... )
## S3 method for class 'TSLM' forecast( object, new_data, specials = NULL, bootstrap = FALSE, approx_normal = TRUE, times = 5000, ... )
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
bootstrap |
If |
approx_normal |
Should the resulting forecast distributions be approximated as a Normal distribution instead of a Student's T distribution. Returning Normal distributions (the default) is a useful approximation to make it easier for using TSLM models in model combinations or reconciliation processes. |
times |
The number of sample paths to use in estimating the forecast distribution when |
... |
Other arguments passed to methods |
A list of forecasts.
as_tsibble(USAccDeaths) %>% model(lm = TSLM(log(value) ~ trend() + season())) %>% forecast()
as_tsibble(USAccDeaths) %>% model(lm = TSLM(log(value) ~ trend() + season())) %>% forecast()
Produces forecasts from a trained model.
## S3 method for class 'VAR' forecast( object, new_data = NULL, specials = NULL, bootstrap = FALSE, times = 5000, ... )
## S3 method for class 'VAR' forecast( object, new_data = NULL, specials = NULL, bootstrap = FALSE, times = 5000, ... )
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
bootstrap |
If |
times |
The number of sample paths to use in estimating the forecast distribution when |
... |
Other arguments passed to methods |
A list of forecasts.
lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) lung_deaths %>% model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) %>% forecast()
lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) lung_deaths %>% model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) %>% forecast()
Simulates future paths from a dataset using a fitted model. Innovations are
sampled by the model's assumed error distribution. If bootstrap
is TRUE
,
innovations will be sampled from the model's residuals. If new_data
contains the .innov
column, those values will be treated as innovations.
## S3 method for class 'AR' generate(x, new_data = NULL, specials = NULL, bootstrap = FALSE, ...)
## S3 method for class 'AR' generate(x, new_data = NULL, specials = NULL, bootstrap = FALSE, ...)
x |
A fitted model. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
bootstrap |
If |
... |
Other arguments passed to methods |
as_tsibble(lh) %>% model(AR(value ~ order(3))) %>% generate()
as_tsibble(lh) %>% model(AR(value ~ order(3))) %>% generate()
Simulates future paths from a dataset using a fitted model. Innovations are
sampled by the model's assumed error distribution. If bootstrap
is TRUE
,
innovations will be sampled from the model's residuals. If new_data
contains the .innov
column, those values will be treated as innovations.
## S3 method for class 'ARIMA' generate(x, new_data, specials, bootstrap = FALSE, ...)
## S3 method for class 'ARIMA' generate(x, new_data, specials, bootstrap = FALSE, ...)
x |
A fitted model. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
bootstrap |
If |
... |
Other arguments passed to methods |
fable_fit <- as_tsibble(USAccDeaths) %>% model(model = ARIMA(value ~ 0 + pdq(0,1,1) + PDQ(0,1,1))) fable_fit %>% generate(times = 10)
fable_fit <- as_tsibble(USAccDeaths) %>% model(model = ARIMA(value ~ 0 + pdq(0,1,1) + PDQ(0,1,1))) fable_fit %>% generate(times = 10)
Simulates future paths from a dataset using a fitted model. Innovations are
sampled by the model's assumed error distribution. If bootstrap
is TRUE
,
innovations will be sampled from the model's residuals. If new_data
contains the .innov
column, those values will be treated as innovations.
## S3 method for class 'ETS' generate(x, new_data, specials, bootstrap = FALSE, ...)
## S3 method for class 'ETS' generate(x, new_data, specials, bootstrap = FALSE, ...)
x |
A fitted model. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
bootstrap |
If |
... |
Other arguments passed to methods |
as_tsibble(USAccDeaths) %>% model(ETS(log(value) ~ season("A"))) %>% generate(times = 100)
as_tsibble(USAccDeaths) %>% model(ETS(log(value) ~ season("A"))) %>% generate(times = 100)
Simulates future paths from a dataset using a fitted model. Innovations are
sampled by the model's assumed error distribution. If bootstrap
is TRUE
,
innovations will be sampled from the model's residuals. If new_data
contains the .innov
column, those values will be treated as innovations.
## S3 method for class 'model_mean' generate(x, new_data, bootstrap = FALSE, ...)
## S3 method for class 'model_mean' generate(x, new_data, bootstrap = FALSE, ...)
x |
A fitted model. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
bootstrap |
If |
... |
Other arguments passed to methods |
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% generate()
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% generate()
Simulates future paths from a dataset using a fitted model. Innovations are
sampled by the model's assumed error distribution. If bootstrap
is TRUE
,
innovations will be sampled from the model's residuals. If new_data
contains the .innov
column, those values will be treated as innovations.
## S3 method for class 'NNETAR' generate(x, new_data, specials = NULL, bootstrap = FALSE, ...)
## S3 method for class 'NNETAR' generate(x, new_data, specials = NULL, bootstrap = FALSE, ...)
x |
A fitted model. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
bootstrap |
If |
... |
Other arguments passed to methods |
as_tsibble(airmiles) %>% model(nn = NNETAR(box_cox(value, 0.15))) %>% generate()
as_tsibble(airmiles) %>% model(nn = NNETAR(box_cox(value, 0.15))) %>% generate()
Simulates future paths from a dataset using a fitted model. Innovations are
sampled by the model's assumed error distribution. If bootstrap
is TRUE
,
innovations will be sampled from the model's residuals. If new_data
contains the .innov
column, those values will be treated as innovations.
## S3 method for class 'RW' generate(x, new_data, bootstrap = FALSE, ...)
## S3 method for class 'RW' generate(x, new_data, bootstrap = FALSE, ...)
x |
A fitted model. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
bootstrap |
If |
... |
Other arguments passed to methods |
as_tsibble(Nile) %>% model(NAIVE(value)) %>% generate() library(tsibbledata) aus_production %>% model(snaive = SNAIVE(Beer ~ lag("year"))) %>% generate()
as_tsibble(Nile) %>% model(NAIVE(value)) %>% generate() library(tsibbledata) aus_production %>% model(snaive = SNAIVE(Beer ~ lag("year"))) %>% generate()
Simulates future paths from a dataset using a fitted model. Innovations are
sampled by the model's assumed error distribution. If bootstrap
is TRUE
,
innovations will be sampled from the model's residuals. If new_data
contains the .innov
column, those values will be treated as innovations.
## S3 method for class 'TSLM' generate(x, new_data, specials, bootstrap = FALSE, ...)
## S3 method for class 'TSLM' generate(x, new_data, specials, bootstrap = FALSE, ...)
x |
A fitted model. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
bootstrap |
If |
... |
Other arguments passed to methods |
as_tsibble(USAccDeaths) %>% model(lm = TSLM(log(value) ~ trend() + season())) %>% generate()
as_tsibble(USAccDeaths) %>% model(lm = TSLM(log(value) ~ trend() + season())) %>% generate()
Simulates future paths from a dataset using a fitted model. Innovations are
sampled by the model's assumed error distribution. If bootstrap
is TRUE
,
innovations will be sampled from the model's residuals. If new_data
contains the .innov
column, those values will be treated as innovations.
## S3 method for class 'VAR' generate(x, new_data, specials, ...)
## S3 method for class 'VAR' generate(x, new_data, specials, ...)
x |
A fitted model. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
... |
Other arguments passed to methods |
as_tsibble(USAccDeaths) %>% model(ETS(log(value) ~ season("A"))) %>% generate(times = 100)
as_tsibble(USAccDeaths) %>% model(ETS(log(value) ~ season("A"))) %>% generate(times = 100)
Simulates future paths from a dataset using a fitted model. Innovations are
sampled by the model's assumed error distribution. If bootstrap
is TRUE
,
innovations will be sampled from the model's residuals. If new_data
contains the .innov
column, those values will be treated as innovations.
## S3 method for class 'VECM' generate(x, new_data, specials, ...)
## S3 method for class 'VECM' generate(x, new_data, specials, ...)
x |
A fitted model. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
... |
Other arguments passed to methods |
as_tsibble(USAccDeaths) %>% model(ETS(log(value) ~ season("A"))) %>% generate(times = 100)
as_tsibble(USAccDeaths) %>% model(ETS(log(value) ~ season("A"))) %>% generate(times = 100)
Construct a single row summary of the AR model.
## S3 method for class 'AR' glance(x, ...)
## S3 method for class 'AR' glance(x, ...)
x |
model or other R object to convert to single-row data frame |
... |
other arguments passed to methods |
Contains the variance of residuals (sigma2
), the log-likelihood (log_lik
),
and information criterion (AIC
, AICc
, BIC
).
A one row tibble summarising the model's fit.
as_tsibble(lh) %>% model(AR(value ~ order(3))) %>% glance()
as_tsibble(lh) %>% model(AR(value ~ order(3))) %>% glance()
Construct a single row summary of the ARIMA model.
## S3 method for class 'ARIMA' glance(x, ...)
## S3 method for class 'ARIMA' glance(x, ...)
x |
model or other R object to convert to single-row data frame |
... |
other arguments passed to methods |
A data frame with 1 row, with columns:
The unbiased variance of residuals. Calculated as sum(residuals^2) / (num_observations - num_pararameters + 1)
The log-likelihood
Akaike information criterion
Akaike information criterion, corrected for small sample sizes
Bayesian information criterion
The model's characteristic roots
A one row tibble summarising the model's fit.
USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% glance()
USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% glance()
Construct a single row summary of the ETS model.
## S3 method for class 'ETS' glance(x, ...)
## S3 method for class 'ETS' glance(x, ...)
x |
model or other R object to convert to single-row data frame |
... |
other arguments passed to methods |
Contains the variance of residuals (sigma2
), the log-likelihood (log_lik
),
and information criterion (AIC
, AICc
, BIC
).
A one row tibble summarising the model's fit.
as_tsibble(USAccDeaths) %>% model(ets = ETS(log(value) ~ season("A"))) %>% glance()
as_tsibble(USAccDeaths) %>% model(ets = ETS(log(value) ~ season("A"))) %>% glance()
Construct a single row summary of the average method model.
## S3 method for class 'fable_theta' glance(x, ...)
## S3 method for class 'fable_theta' glance(x, ...)
x |
model or other R object to convert to single-row data frame |
... |
other arguments passed to methods |
Contains the variance of residuals (sigma2
).
A one row tibble summarising the model's fit.
Construct a single row summary of the average method model.
## S3 method for class 'model_mean' glance(x, ...)
## S3 method for class 'model_mean' glance(x, ...)
x |
model or other R object to convert to single-row data frame |
... |
other arguments passed to methods |
Contains the variance of residuals (sigma2
).
A one row tibble summarising the model's fit.
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% glance()
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% glance()
Construct a single row summary of the NNETAR model.
Contains the variance of residuals (sigma2
).
## S3 method for class 'NNETAR' glance(x, ...)
## S3 method for class 'NNETAR' glance(x, ...)
x |
model or other R object to convert to single-row data frame |
... |
other arguments passed to methods |
A one row tibble summarising the model's fit.
as_tsibble(airmiles) %>% model(nn = NNETAR(box_cox(value, 0.15))) %>% glance()
as_tsibble(airmiles) %>% model(nn = NNETAR(box_cox(value, 0.15))) %>% glance()
Construct a single row summary of the lag walk model.
Contains the variance of residuals (sigma2
).
## S3 method for class 'RW' glance(x, ...)
## S3 method for class 'RW' glance(x, ...)
x |
model or other R object to convert to single-row data frame |
... |
other arguments passed to methods |
A one row tibble summarising the model's fit.
as_tsibble(Nile) %>% model(NAIVE(value)) %>% glance() library(tsibbledata) aus_production %>% model(snaive = SNAIVE(Beer ~ lag("year"))) %>% glance()
as_tsibble(Nile) %>% model(NAIVE(value)) %>% glance() library(tsibbledata) aus_production %>% model(snaive = SNAIVE(Beer ~ lag("year"))) %>% glance()
Construct a single row summary of the TSLM model.
## S3 method for class 'TSLM' glance(x, ...)
## S3 method for class 'TSLM' glance(x, ...)
x |
model or other R object to convert to single-row data frame |
... |
other arguments passed to methods |
Contains the R squared (r_squared
), variance of residuals (sigma2
),
the log-likelihood (log_lik
), and information criterion (AIC
, AICc
, BIC
).
A one row tibble summarising the model's fit.
as_tsibble(USAccDeaths) %>% model(lm = TSLM(log(value) ~ trend() + season())) %>% glance()
as_tsibble(USAccDeaths) %>% model(lm = TSLM(log(value) ~ trend() + season())) %>% glance()
Construct a single row summary of the VAR model.
## S3 method for class 'VAR' glance(x, ...)
## S3 method for class 'VAR' glance(x, ...)
x |
model or other R object to convert to single-row data frame |
... |
other arguments passed to methods |
Contains the variance of residuals (sigma2
), the log-likelihood (log_lik
),
and information criterion (AIC
, AICc
, BIC
).
A one row tibble summarising the model's fit.
lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) lung_deaths %>% model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) %>% glance()
lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) lung_deaths %>% model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) %>% glance()
Construct a single row summary of the VECM model.
## S3 method for class 'VECM' glance(x, ...)
## S3 method for class 'VECM' glance(x, ...)
x |
model or other R object to convert to single-row data frame |
... |
other arguments passed to methods |
Contains the variance of residuals (sigma2
), the log-likelihood
(log_lik
), the cointegrating vector (beta
) and information criterion
(AIC
, AICc
, BIC
).
A one row tibble summarising the model's fit.
Applies a model-specific estimation technique to predict the values of missing values in a tsibble
, and replace them.
## S3 method for class 'ARIMA' interpolate(object, new_data, specials, ...)
## S3 method for class 'ARIMA' interpolate(object, new_data, specials, ...)
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
... |
Other arguments passed to methods |
A tibble of the same dimension of new_data
with missing values interpolated.
library(tsibbledata) olympic_running %>% model(arima = ARIMA(Time ~ trend())) %>% interpolate(olympic_running)
library(tsibbledata) olympic_running %>% model(arima = ARIMA(Time ~ trend())) %>% interpolate(olympic_running)
Applies a model-specific estimation technique to predict the values of missing values in a tsibble
, and replace them.
## S3 method for class 'model_mean' interpolate(object, new_data, specials, ...)
## S3 method for class 'model_mean' interpolate(object, new_data, specials, ...)
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
... |
Other arguments passed to methods |
A tibble of the same dimension of new_data
with missing values interpolated.
library(tsibbledata) olympic_running %>% model(mean = MEAN(Time)) %>% interpolate(olympic_running)
library(tsibbledata) olympic_running %>% model(mean = MEAN(Time)) %>% interpolate(olympic_running)
Applies a model-specific estimation technique to predict the values of missing values in a tsibble
, and replace them.
## S3 method for class 'TSLM' interpolate(object, new_data, specials, ...)
## S3 method for class 'TSLM' interpolate(object, new_data, specials, ...)
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
... |
Other arguments passed to methods |
A tibble of the same dimension of new_data
with missing values interpolated.
library(tsibbledata) olympic_running %>% model(lm = TSLM(Time ~ trend())) %>% interpolate(olympic_running)
library(tsibbledata) olympic_running %>% model(lm = TSLM(Time ~ trend())) %>% interpolate(olympic_running)
Calculate impulse responses from a fable model
## S3 method for class 'ARIMA' IRF(x, new_data, specials, ...)
## S3 method for class 'ARIMA' IRF(x, new_data, specials, ...)
x |
A fitted model. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
... |
Other arguments passed to methods |
Simulates future paths from a dataset using a fitted model. Innovations are
sampled by the model's assumed error distribution. If bootstrap
is TRUE
,
innovations will be sampled from the model's residuals. If new_data
contains the .innov
column, those values will be treated as innovations.
## S3 method for class 'VAR' IRF(x, new_data, specials, impulse = NULL, orthogonal = FALSE, ...)
## S3 method for class 'VAR' IRF(x, new_data, specials, impulse = NULL, orthogonal = FALSE, ...)
x |
A fitted model. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
impulse |
A character string specifying the name of the variable that is shocked (the impulse variable). |
orthogonal |
If TRUE, orthogonalised impulse responses will be computed. |
... |
Other arguments passed to methods |
Simulates future paths from a dataset using a fitted model. Innovations are
sampled by the model's assumed error distribution. If bootstrap
is TRUE
,
innovations will be sampled from the model's residuals. If new_data
contains the .innov
column, those values will be treated as innovations.
## S3 method for class 'VECM' IRF(x, new_data, specials, impulse = NULL, orthogonal = FALSE, ...)
## S3 method for class 'VECM' IRF(x, new_data, specials, impulse = NULL, orthogonal = FALSE, ...)
x |
A fitted model. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
impulse |
A character string specifying the name of the variable that is shocked (the impulse variable). |
orthogonal |
If TRUE, orthogonalised impulse responses will be computed. |
... |
Other arguments passed to methods |
MEAN()
returns an iid model applied to the formula's response variable.
MEAN(formula, ...)
MEAN(formula, ...)
formula |
Model specification. |
... |
Not used. |
A model specification.
The window
special is used to specify a rolling window for the mean.
window(size = NULL)
size |
The size (number of observations) for the rolling window. If NULL (default), a rolling window will not be used. |
Forecasting: Principles and Practices, Some simple forecasting methods (section 3.2)
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand))
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand))
Feed-forward neural networks with a single hidden layer and lagged inputs for forecasting univariate time series.
NNETAR(formula, n_nodes = NULL, n_networks = 20, scale_inputs = TRUE, ...)
NNETAR(formula, n_nodes = NULL, n_networks = 20, scale_inputs = TRUE, ...)
formula |
Model specification (see "Specials" section). |
n_nodes |
Number of nodes in the hidden layer. Default is half of the number of input nodes (including external regressors, if given) plus 1. |
n_networks |
Number of networks to fit with different random starting weights. These are then averaged when producing forecasts. |
scale_inputs |
If TRUE, inputs are scaled by subtracting the column means and dividing by their respective standard deviations. Scaling is applied after transformations. |
... |
Other arguments passed to |
A feed-forward neural network is fitted with lagged values of the response as
inputs and a single hidden layer with size
nodes. The inputs are for
lags 1 to p
, and lags m
to mP
where
m
is the seasonal period specified.
If exogenous regressors are provided, its columns are also used as inputs.
Missing values are currently not supported by this model.
A total of repeats
networks are
fitted, each with random starting weights. These are then averaged when
computing forecasts. The network is trained for one-step forecasting.
Multi-step forecasts are computed recursively.
For non-seasonal data, the fitted model is denoted as an NNAR(p,k) model, where k is the number of hidden nodes. This is analogous to an AR(p) model but with non-linear functions. For seasonal data, the fitted model is called an NNAR(p,P,k)[m] model, which is analogous to an ARIMA(p,0,0)(P,0,0)[m] model but with non-linear functions.
A model specification.
The AR
special is used to specify auto-regressive components in each of the
nodes of the neural network.
AR(p = NULL, P = 1, period = NULL)
p |
The order of the non-seasonal auto-regressive (AR) terms. If p = NULL , an optimal number of lags will be selected for a linear AR(p) model via AIC. For seasonal time series, this will be computed on the seasonally adjusted data (via STL decomposition). |
P |
The order of the seasonal auto-regressive (SAR) terms. |
period |
The periodic nature of the seasonality. This can be either a number indicating the number of observations in each seasonal period, or text to indicate the duration of the seasonal window (for example, annual seasonality would be "1 year"). |
Exogenous regressors can be included in an NNETAR model without explicitly using the xreg()
special. Common exogenous regressor specials as specified in common_xregs
can also be used. These regressors are handled using stats::model.frame()
, and so interactions and other functionality behaves similarly to stats::lm()
.
xreg(...)
... |
Bare expressions for the exogenous regressors (such as log(x) )
|
Forecasting: Principles and Practices, Neural network models (section 11.3)
as_tsibble(airmiles) %>% model(nn = NNETAR(box_cox(value, 0.15)))
as_tsibble(airmiles) %>% model(nn = NNETAR(box_cox(value, 0.15)))
Applies a fitted AR model to a new dataset.
## S3 method for class 'AR' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
## S3 method for class 'AR' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
reestimate |
If |
... |
Other arguments passed to methods |
A refitted model.
lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths) fit <- lung_deaths_male %>% model(AR(value ~ 1 + order(10))) report(fit) fit %>% refit(lung_deaths_female) %>% report()
lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths) fit <- lung_deaths_male %>% model(AR(value ~ 1 + order(10))) report(fit) fit %>% refit(lung_deaths_female) %>% report()
Applies a fitted ARIMA model to a new dataset.
## S3 method for class 'ARIMA' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
## S3 method for class 'ARIMA' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
reestimate |
If |
... |
Other arguments passed to methods |
A refitted model.
lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths) fit <- lung_deaths_male %>% model(ARIMA(value ~ 1 + pdq(2, 0, 0) + PDQ(2, 1, 0))) report(fit) fit %>% refit(lung_deaths_female) %>% report()
lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths) fit <- lung_deaths_male %>% model(ARIMA(value ~ 1 + pdq(2, 0, 0) + PDQ(2, 1, 0))) report(fit) fit %>% refit(lung_deaths_female) %>% report()
Applies a fitted ETS model to a new dataset.
## S3 method for class 'ETS' refit( object, new_data, specials = NULL, reestimate = FALSE, reinitialise = TRUE, ... )
## S3 method for class 'ETS' refit( object, new_data, specials = NULL, reestimate = FALSE, reinitialise = TRUE, ... )
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
reestimate |
If |
reinitialise |
If TRUE, the initial parameters will be re-estimated to suit the new data. |
... |
Other arguments passed to methods |
lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths) fit <- lung_deaths_male %>% model(ETS(value)) report(fit) fit %>% refit(lung_deaths_female, reinitialise = TRUE) %>% report()
lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths) fit <- lung_deaths_male %>% model(ETS(value)) report(fit) fit %>% refit(lung_deaths_female, reinitialise = TRUE) %>% report()
Applies a fitted average method model to a new dataset.
## S3 method for class 'model_mean' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
## S3 method for class 'model_mean' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
reestimate |
If |
... |
Other arguments passed to methods |
lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths) fit <- lung_deaths_male %>% model(MEAN(value)) report(fit) fit %>% refit(lung_deaths_female) %>% report()
lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths) fit <- lung_deaths_male %>% model(MEAN(value)) report(fit) fit %>% refit(lung_deaths_female) %>% report()
Applies a fitted NNETAR model to a new dataset.
## S3 method for class 'NNETAR' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
## S3 method for class 'NNETAR' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
reestimate |
If |
... |
Other arguments passed to methods |
A refitted model.
lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths) fit <- lung_deaths_male %>% model(NNETAR(value)) report(fit) fit %>% refit(new_data = lung_deaths_female, reestimate = FALSE) %>% report()
lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths) fit <- lung_deaths_male %>% model(NNETAR(value)) report(fit) fit %>% refit(new_data = lung_deaths_female, reestimate = FALSE) %>% report()
Applies a fitted random walk model to a new dataset.
## S3 method for class 'RW' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
## S3 method for class 'RW' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
reestimate |
If |
... |
Other arguments passed to methods |
The models NAIVE
and SNAIVE
have no specific model parameters. Using refit
for one of these models will provide the same estimation results as one would
use fabletools::model(NAIVE(...))
(or fabletools::model(SNAIVE(...))
.
lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths) fit <- lung_deaths_male %>% model(RW(value ~ drift())) report(fit) fit %>% refit(lung_deaths_female) %>% report()
lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths) fit <- lung_deaths_male %>% model(RW(value ~ drift())) report(fit) fit %>% refit(lung_deaths_female) %>% report()
TSLM
Applies a fitted TSLM
to a new dataset.
## S3 method for class 'TSLM' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
## S3 method for class 'TSLM' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
reestimate |
If |
... |
Other arguments passed to methods |
lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths) fit <- lung_deaths_male %>% model(TSLM(value ~ trend() + season())) report(fit) fit %>% refit(lung_deaths_female) %>% report()
lung_deaths_male <- as_tsibble(mdeaths) lung_deaths_female <- as_tsibble(fdeaths) fit <- lung_deaths_male %>% model(TSLM(value ~ trend() + season())) report(fit) fit %>% refit(lung_deaths_female) %>% report()
Extracts the residuals.
## S3 method for class 'AR' residuals(object, type = c("innovation", "regression"), ...)
## S3 method for class 'AR' residuals(object, type = c("innovation", "regression"), ...)
object |
A model for which forecasts are required. |
type |
The type of residuals to extract. |
... |
Other arguments passed to methods |
A vector of fitted residuals.
as_tsibble(lh) %>% model(AR(value ~ order(3))) %>% residuals()
as_tsibble(lh) %>% model(AR(value ~ order(3))) %>% residuals()
Extracts the residuals.
## S3 method for class 'ARIMA' residuals(object, type = c("innovation", "regression"), ...)
## S3 method for class 'ARIMA' residuals(object, type = c("innovation", "regression"), ...)
object |
A model for which forecasts are required. |
type |
The type of residuals to extract. |
... |
Other arguments passed to methods |
A vector of fitted residuals.
USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% residuals()
USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% residuals()
Extracts the residuals.
## S3 method for class 'croston' residuals(object, ...)
## S3 method for class 'croston' residuals(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted residuals.
library(tsibble) sim_poisson <- tsibble( time = yearmonth("2012 Dec") + seq_len(24), count = rpois(24, lambda = 0.3), index = time ) sim_poisson %>% model(CROSTON(count)) %>% residuals()
library(tsibble) sim_poisson <- tsibble( time = yearmonth("2012 Dec") + seq_len(24), count = rpois(24, lambda = 0.3), index = time ) sim_poisson %>% model(CROSTON(count)) %>% residuals()
Extracts the residuals.
## S3 method for class 'ETS' residuals(object, ...)
## S3 method for class 'ETS' residuals(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted residuals.
as_tsibble(USAccDeaths) %>% model(ets = ETS(log(value) ~ season("A"))) %>% residuals()
as_tsibble(USAccDeaths) %>% model(ets = ETS(log(value) ~ season("A"))) %>% residuals()
Extracts the residuals.
## S3 method for class 'fable_theta' residuals(object, ...)
## S3 method for class 'fable_theta' residuals(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted residuals.
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% residuals()
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% residuals()
Extracts the residuals.
## S3 method for class 'model_mean' residuals(object, ...)
## S3 method for class 'model_mean' residuals(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted residuals.
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% residuals()
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% residuals()
Extracts the residuals.
## S3 method for class 'NNETAR' residuals(object, ...)
## S3 method for class 'NNETAR' residuals(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted residuals.
as_tsibble(airmiles) %>% model(nn = NNETAR(box_cox(value, 0.15))) %>% residuals()
as_tsibble(airmiles) %>% model(nn = NNETAR(box_cox(value, 0.15))) %>% residuals()
Extracts the residuals.
## S3 method for class 'RW' residuals(object, ...)
## S3 method for class 'RW' residuals(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted residuals.
as_tsibble(Nile) %>% model(NAIVE(value)) %>% residuals() library(tsibbledata) aus_production %>% model(snaive = SNAIVE(Beer ~ lag("year"))) %>% residuals()
as_tsibble(Nile) %>% model(NAIVE(value)) %>% residuals() library(tsibbledata) aus_production %>% model(snaive = SNAIVE(Beer ~ lag("year"))) %>% residuals()
Extracts the residuals.
## S3 method for class 'TSLM' residuals(object, ...)
## S3 method for class 'TSLM' residuals(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted residuals.
as_tsibble(USAccDeaths) %>% model(lm = TSLM(log(value) ~ trend() + season())) %>% residuals()
as_tsibble(USAccDeaths) %>% model(lm = TSLM(log(value) ~ trend() + season())) %>% residuals()
Extracts the residuals.
## S3 method for class 'VAR' residuals(object, ...)
## S3 method for class 'VAR' residuals(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted residuals.
lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) lung_deaths %>% model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) %>% residuals()
lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) lung_deaths %>% model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) %>% residuals()
RW()
returns a random walk model, which is equivalent to an ARIMA(0,1,0)
model with an optional drift coefficient included using drift()
. naive()
is simply a wrapper
to rwf()
for simplicity. snaive()
returns forecasts and
prediction intervals from an ARIMA(0,0,0)(0,1,0)m model where m is the
seasonal period.
RW(formula, ...) NAIVE(formula, ...) SNAIVE(formula, ...)
RW(formula, ...) NAIVE(formula, ...) SNAIVE(formula, ...)
formula |
Model specification (see "Specials" section). |
... |
Not used. |
The random walk with drift model is
where is a normal iid error. Forecasts are
given by
. If there is no drift (as in
naive
), the drift parameter c=0. Forecast standard errors allow for
uncertainty in estimating the drift parameter (unlike the corresponding
forecasts obtained by fitting an ARIMA model directly).
The seasonal naive model is
where is a normal iid error.
A model specification.
The lag
special is used to specify the lag order for the random walk process.
If left out, this special will automatically be included.
lag(lag = NULL)
lag |
The lag order for the random walk process. If lag = m , forecasts will return the observation from m time periods ago. This can also be provided as text indicating the duration of the lag window (for example, annual seasonal lags would be "1 year").
|
The drift
special can be used to include a drift/trend component into the model. By default, drift is not included unless drift()
is included in the formula.
drift(drift = TRUE)
drift |
If drift = TRUE , a drift term will be included in the model.
|
Forecasting: Principles and Practices, Some simple forecasting methods (section 3.2)
library(tsibbledata) aus_production %>% model(rw = RW(Beer ~ drift())) as_tsibble(Nile) %>% model(NAIVE(value)) library(tsibbledata) aus_production %>% model(snaive = SNAIVE(Beer ~ lag("year")))
library(tsibbledata) aus_production %>% model(rw = RW(Beer ~ drift())) as_tsibble(Nile) %>% model(NAIVE(value)) library(tsibbledata) aus_production %>% model(snaive = SNAIVE(Beer ~ lag("year")))
The theta method of Assimakopoulos and Nikolopoulos (2000) is equivalent to simple exponential smoothing with drift. This is demonstrated in Hyndman and Billah (2003).
THETA(formula, ...)
THETA(formula, ...)
formula |
Model specification. |
... |
Not used. |
The series is tested for seasonality using the test outlined in A&N. If deemed seasonal, the series is seasonally adjusted using a classical multiplicative decomposition before applying the theta method. The resulting forecasts are then reseasonalized.
More general theta methods are available in the forecTheta package.
A model specification.
The season
special is used to specify the parameters of the seasonal adjustment via classical decomposition.
season(period = NULL, method = c("multiplicative", "additive"))
period |
The periodic nature of the seasonality. This can be either a number indicating the number of observations in each seasonal period, or text to indicate the duration of the seasonal window (for example, annual seasonality would be "1 year"). |
method |
The type of classical decomposition to apply. The original Theta method always used multiplicative seasonal decomposition, and so this is the default. |
Rob J Hyndman, Mitchell O'Hara-Wild
Assimakopoulos, V. and Nikolopoulos, K. (2000). The theta model: a decomposition approach to forecasting. International Journal of Forecasting 16, 521-530.
Hyndman, R.J., and Billah, B. (2003) Unmasking the Theta method. International J. Forecasting, 19, 287-290.
# Theta method with transform deaths <- as_tsibble(USAccDeaths) deaths %>% model(theta = THETA(log(value))) %>% forecast(h = "4 years") %>% autoplot(deaths) # Compare seasonal specifications library(tsibbledata) library(dplyr) aus_retail %>% filter(Industry == "Clothing retailing") %>% model(theta_multiplicative = THETA(Turnover ~ season(method = "multiplicative")), theta_additive = THETA(Turnover ~ season(method = "additive"))) %>% accuracy()
# Theta method with transform deaths <- as_tsibble(USAccDeaths) deaths %>% model(theta = THETA(log(value))) %>% forecast(h = "4 years") %>% autoplot(deaths) # Compare seasonal specifications library(tsibbledata) library(dplyr) aus_retail %>% filter(Industry == "Clothing retailing") %>% model(theta_multiplicative = THETA(Turnover ~ season(method = "multiplicative")), theta_additive = THETA(Turnover ~ season(method = "additive"))) %>% accuracy()
Returns the coefficients from the model in a tibble
format.
## S3 method for class 'AR' tidy(x, ...)
## S3 method for class 'AR' tidy(x, ...)
x |
An object to be converted into a tidy |
... |
Additional arguments to tidying method. |
The model's coefficients in a tibble
.
as_tsibble(lh) %>% model(AR(value ~ order(3))) %>% tidy()
as_tsibble(lh) %>% model(AR(value ~ order(3))) %>% tidy()
Returns the coefficients from the model in a tibble
format.
## S3 method for class 'ARIMA' tidy(x, ...)
## S3 method for class 'ARIMA' tidy(x, ...)
x |
An object to be converted into a tidy |
... |
Additional arguments to tidying method. |
The model's coefficients in a tibble
.
USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% tidy()
USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% tidy()
Returns the coefficients from the model in a tibble
format.
## S3 method for class 'croston' tidy(x, ...)
## S3 method for class 'croston' tidy(x, ...)
x |
An object to be converted into a tidy |
... |
Additional arguments to tidying method. |
The model's coefficients in a tibble
.
library(tsibble) sim_poisson <- tsibble( time = yearmonth("2012 Dec") + seq_len(24), count = rpois(24, lambda = 0.3), index = time ) sim_poisson %>% model(CROSTON(count)) %>% tidy()
library(tsibble) sim_poisson <- tsibble( time = yearmonth("2012 Dec") + seq_len(24), count = rpois(24, lambda = 0.3), index = time ) sim_poisson %>% model(CROSTON(count)) %>% tidy()
Returns the coefficients from the model in a tibble
format.
## S3 method for class 'ETS' tidy(x, ...)
## S3 method for class 'ETS' tidy(x, ...)
x |
An object to be converted into a tidy |
... |
Additional arguments to tidying method. |
The model's coefficients in a tibble
.
as_tsibble(USAccDeaths) %>% model(ets = ETS(log(value) ~ season("A"))) %>% tidy()
as_tsibble(USAccDeaths) %>% model(ets = ETS(log(value) ~ season("A"))) %>% tidy()
Returns the coefficients from the model in a tibble
format.
## S3 method for class 'fable_theta' tidy(x, ...)
## S3 method for class 'fable_theta' tidy(x, ...)
x |
An object to be converted into a tidy |
... |
Additional arguments to tidying method. |
The model's coefficients in a tibble
.
USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% tidy()
USAccDeaths %>% as_tsibble() %>% model(arima = ARIMA(log(value) ~ pdq(0, 1, 1) + PDQ(0, 1, 1))) %>% tidy()
Returns the coefficients from the model in a tibble
format.
## S3 method for class 'model_mean' tidy(x, ...)
## S3 method for class 'model_mean' tidy(x, ...)
x |
An object to be converted into a tidy |
... |
Additional arguments to tidying method. |
The model's coefficients in a tibble
.
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% tidy()
library(tsibbledata) vic_elec %>% model(avg = MEAN(Demand)) %>% tidy()
Returns the coefficients from the model in a tibble
format.
## S3 method for class 'NNETAR' tidy(x, ...)
## S3 method for class 'NNETAR' tidy(x, ...)
x |
An object to be converted into a tidy |
... |
Additional arguments to tidying method. |
The model's coefficients in a tibble
.
as_tsibble(airmiles) %>% model(nn = NNETAR(box_cox(value, 0.15))) %>% tidy()
as_tsibble(airmiles) %>% model(nn = NNETAR(box_cox(value, 0.15))) %>% tidy()
Returns the coefficients from the model in a tibble
format.
## S3 method for class 'RW' tidy(x, ...)
## S3 method for class 'RW' tidy(x, ...)
x |
An object to be converted into a tidy |
... |
Additional arguments to tidying method. |
The model's coefficients in a tibble
.
as_tsibble(Nile) %>% model(NAIVE(value)) %>% tidy() library(tsibbledata) aus_production %>% model(snaive = SNAIVE(Beer ~ lag("year"))) %>% tidy()
as_tsibble(Nile) %>% model(NAIVE(value)) %>% tidy() library(tsibbledata) aus_production %>% model(snaive = SNAIVE(Beer ~ lag("year"))) %>% tidy()
Returns the coefficients from the model in a tibble
format.
## S3 method for class 'TSLM' tidy(x, ...)
## S3 method for class 'TSLM' tidy(x, ...)
x |
An object to be converted into a tidy |
... |
Additional arguments to tidying method. |
The model's coefficients in a tibble
.
as_tsibble(USAccDeaths) %>% model(lm = TSLM(log(value) ~ trend() + season())) %>% tidy()
as_tsibble(USAccDeaths) %>% model(lm = TSLM(log(value) ~ trend() + season())) %>% tidy()
Returns the coefficients from the model in a tibble
format.
## S3 method for class 'VAR' tidy(x, ...)
## S3 method for class 'VAR' tidy(x, ...)
x |
An object to be converted into a tidy |
... |
Additional arguments to tidying method. |
The model's coefficients in a tibble
.
lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) lung_deaths %>% model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) %>% tidy()
lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) lung_deaths %>% model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) %>% tidy()
The model formula will be handled using stats::model.matrix()
, and so
the the same approach to include interactions in stats::lm()
applies when
specifying the formula
. In addition to stats::lm()
, it is possible to
include common_xregs
in the model formula, such as trend()
, season()
,
and fourier()
.
TSLM(formula)
TSLM(formula)
formula |
Model specification. |
A model specification.
Exogenous regressors can be included in a TSLM model without explicitly using the xreg()
special. Common exogenous regressor specials as specified in common_xregs
can also be used. These regressors are handled using stats::model.frame()
, and so interactions and other functionality behaves similarly to stats::lm()
.
xreg(...)
... |
Bare expressions for the exogenous regressors (such as log(x) )
|
stats::lm()
, stats::model.matrix()
Forecasting: Principles and Practices, Time series regression models (chapter 6)
as_tsibble(USAccDeaths) %>% model(lm = TSLM(log(value) ~ trend() + season())) library(tsibbledata) olympic_running %>% model(TSLM(Time ~ trend())) %>% interpolate(olympic_running)
as_tsibble(USAccDeaths) %>% model(lm = TSLM(log(value) ~ trend() + season())) library(tsibbledata) olympic_running %>% model(TSLM(Time ~ trend())) %>% interpolate(olympic_running)
By default, a kpss test (via feasts::unitroot_kpss()
) will be performed
for testing the required first order differences, and a test of the seasonal
strength (via feasts::feat_stl()
seasonal_strength) being above the 0.64
threshold is used for determining seasonal required differences.
unitroot_options( ndiffs_alpha = 0.05, nsdiffs_alpha = 0.05, ndiffs_pvalue = ~feasts::unitroot_kpss(.)["kpss_pvalue"], nsdiffs_pvalue = ur_seasonal_strength(0.64) )
unitroot_options( ndiffs_alpha = 0.05, nsdiffs_alpha = 0.05, ndiffs_pvalue = ~feasts::unitroot_kpss(.)["kpss_pvalue"], nsdiffs_pvalue = ur_seasonal_strength(0.64) )
ndiffs_alpha , nsdiffs_alpha
|
The level for the test specified in the |
ndiffs_pvalue , nsdiffs_pvalue
|
A function (or lambda expression) that provides a p-value for the unit root test. As long as For the function for the seasonal p-value, the seasonal period will be provided as the |
A list of parameters
Searches through the vector of lag orders to find the best VAR model which has lowest AIC, AICc or BIC value. It is implemented using OLS per equation.
VAR(formula, ic = c("aicc", "aic", "bic"), ...)
VAR(formula, ic = c("aicc", "aic", "bic"), ...)
formula |
Model specification (see "Specials" section). |
ic |
The information criterion used in selecting the model. |
... |
Further arguments for arima |
Exogenous regressors and common_xregs
can be specified in the model
formula.
A model specification.
The AR
special is used to specify the lag order for the auto-regression.
AR(p = 0:5)
p |
The order of the auto-regressive (AR) terms. If multiple values are provided, the one which minimises ic will be chosen. |
Exogenous regressors can be included in an VAR model without explicitly using the xreg()
special. Common exogenous regressor specials as specified in common_xregs
can also be used. These regressors are handled using stats::model.frame()
, and so interactions and other functionality behaves similarly to stats::lm()
.
The inclusion of a constant in the model follows the similar rules to stats::lm()
, where including 1
will add a constant and 0
or -1
will remove the constant. If left out, the inclusion of a constant will be determined by minimising ic
.
xreg(...)
... |
Bare expressions for the exogenous regressors (such as log(x) )
|
Forecasting: Principles and Practices, Vector autoregressions (section 11.2)
lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) fit <- lung_deaths %>% model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) report(fit) fit %>% forecast() %>% autoplot(lung_deaths)
lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) fit <- lung_deaths %>% model(VAR(vars(mdeaths, fdeaths) ~ AR(3))) report(fit) fit %>% forecast() %>% autoplot(lung_deaths)
Estimates a VARIMA model of a given order.
VARIMA(formula, identification = c("kronecker_indices", "none"), ...) ## S3 method for class 'VARIMA' forecast( object, new_data = NULL, specials = NULL, bootstrap = FALSE, times = 5000, ... ) ## S3 method for class 'VARIMA' fitted(object, ...) ## S3 method for class 'VARIMA' residuals(object, ...) ## S3 method for class 'VARIMA' tidy(x, ...) ## S3 method for class 'VARIMA' glance(x, ...) ## S3 method for class 'VARIMA' report(object, ...) ## S3 method for class 'VARIMA' generate(x, new_data, specials, ...) ## S3 method for class 'VARIMA' IRF(x, new_data, specials, impulse = NULL, orthogonal = FALSE, ...)
VARIMA(formula, identification = c("kronecker_indices", "none"), ...) ## S3 method for class 'VARIMA' forecast( object, new_data = NULL, specials = NULL, bootstrap = FALSE, times = 5000, ... ) ## S3 method for class 'VARIMA' fitted(object, ...) ## S3 method for class 'VARIMA' residuals(object, ...) ## S3 method for class 'VARIMA' tidy(x, ...) ## S3 method for class 'VARIMA' glance(x, ...) ## S3 method for class 'VARIMA' report(object, ...) ## S3 method for class 'VARIMA' generate(x, new_data, specials, ...) ## S3 method for class 'VARIMA' IRF(x, new_data, specials, impulse = NULL, orthogonal = FALSE, ...)
formula |
Model specification (see "Specials" section). |
identification |
The identification technique used to estimate the model. |
... |
Further arguments for arima |
object |
A model for which forecasts are required. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
bootstrap |
If |
times |
The number of sample paths to use in estimating the forecast distribution when |
x |
A fitted model. |
impulse |
A character string specifying the name of the variable that is shocked (the impulse variable). |
orthogonal |
If TRUE, orthogonalised impulse responses will be computed. |
Exogenous regressors and common_xregs
can be specified in the model
formula.
A model specification.
A one row tibble summarising the model's fit.
The pdq
special is used to specify non-seasonal components of the model.
pdq(p = 0:5, d = 0:2, q = 0:5)
p |
The order of the non-seasonal auto-regressive (AR) terms. If multiple values are provided, the one which minimises ic will be chosen. |
d |
The order of integration for non-seasonal differencing. If multiple values are provided, one of the values will be selected via repeated KPSS tests. |
q |
The order of the non-seasonal moving average (MA) terms. If multiple values are provided, the one which minimises ic will be chosen. |
Exogenous regressors can be included in an VARIMA model without explicitly using the xreg()
special. Common exogenous regressor specials as specified in common_xregs
can also be used. These regressors are handled using stats::model.frame()
, and so interactions and other functionality behaves similarly to stats::lm()
.
The inclusion of a constant in the model follows the similar rules to stats::lm()
, where including 1
will add a constant and 0
or -1
will remove the constant. If left out, the inclusion of a constant will be determined by minimising ic
.
xreg(...)
... |
Bare expressions for the exogenous regressors (such as log(x) )
|
library(tsibbledata) aus_production %>% autoplot(vars(Beer, Cement)) fit <- aus_production %>% model(VARIMA(vars(Beer, Cement) ~ pdq(4,1,1), identification = "none")) fit fit %>% forecast(h = 50) %>% autoplot(tail(aus_production, 100)) fitted(fit) residuals(fit) tidy(fit) glance(fit) report(fit) generate(fit, h = 10) IRF(fit, h = 10, impulse = "Beer")
library(tsibbledata) aus_production %>% autoplot(vars(Beer, Cement)) fit <- aus_production %>% model(VARIMA(vars(Beer, Cement) ~ pdq(4,1,1), identification = "none")) fit fit %>% forecast(h = 50) %>% autoplot(tail(aus_production, 100)) fitted(fit) residuals(fit) tidy(fit) glance(fit) report(fit) generate(fit, h = 10) IRF(fit, h = 10, impulse = "Beer")
Searches through the vector of lag orders to find the best VECM model which has lowest AIC, AICc or BIC value. The model is estimated using the Johansen procedure (maximum likelihood).
VECM(formula, ic = c("aicc", "aic", "bic"), r = 1L, ...)
VECM(formula, ic = c("aicc", "aic", "bic"), r = 1L, ...)
formula |
Model specification (see "Specials" section). |
ic |
The information criterion used in selecting the model. |
r |
The number of cointegrating relationships |
... |
Further arguments for arima |
Exogenous regressors and common_xregs
can be specified in the model
formula.
A model specification.
The AR
special is used to specify the lag order for the auto-regression.
AR(p = 0:5)
p |
The order of the auto-regressive (AR) terms. If multiple values are provided, the one which minimises ic will be chosen. |
Exogenous regressors can be included in an VECM model without explicitly using the xreg()
special. Common exogenous regressor specials as specified in common_xregs
can also be used. These regressors are handled using stats::model.frame()
, and so interactions and other functionality behaves similarly to stats::lm()
.
The inclusion of a constant in the model follows the similar rules to stats::lm()
, where including 1
will add a constant and 0
or -1
will remove the constant. If left out, the inclusion of a constant will be determined by minimising ic
.
xreg(...)
... |
Bare expressions for the exogenous regressors (such as log(x) )
|
lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) fit <- lung_deaths %>% model(VECM(vars(mdeaths, fdeaths) ~ AR(3))) report(fit) fit %>% forecast() %>% autoplot(lung_deaths)
lung_deaths <- cbind(mdeaths, fdeaths) %>% as_tsibble(pivot_longer = FALSE) fit <- lung_deaths %>% model(VECM(vars(mdeaths, fdeaths) ~ AR(3))) report(fit) fit %>% forecast() %>% autoplot(lung_deaths)