Title: | Forecasting Binary Time Series |
---|---|
Description: | Provides a collection of time series forecasting models suitable for binary time series. 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: | Rob Hyndman [aut, cre, cph], Mitchell O'Hara-Wild [aut] |
Maintainer: | Rob Hyndman <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0 |
Built: | 2024-11-22 03:06:06 UTC |
Source: | https://github.com/tidyverts/fable.binary |
Feed-forward neural networks with a single hidden layer and lagged inputs for forecasting univariate binary time series.
BINNET(formula, n_nodes = NULL, n_networks = 20, scale_inputs = TRUE, ...)
BINNET(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 external regressors 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. |
... |
Other arguments passed to |
A feed-forward neural network is fitted with a single hidden layer containing size
nodes.
Exogenous regressors are used as inputs.
A total of repeats
networks are
fitted, each with random starting weights. These are then averaged when
computing forecasts.
A model specification.
melb_rain |> model(nn = BINNET(Wet ~ fourier(K = 1, period = "year")))
melb_rain |> model(nn = BINNET(Wet ~ fourier(K = 1, period = "year")))
Extracts the fitted values.
## S3 method for class 'BINNET' fitted(object, ...)
## S3 method for class 'BINNET' fitted(object, ...)
object |
Fitted model |
... |
Other arguments ignored |
melb_rain |> model(nn = BINNET(Wet ~ fourier(K = 1, period = "year"))) |> fitted()
melb_rain |> model(nn = BINNET(Wet ~ fourier(K = 1, period = "year"))) |> fitted()
Extracts the fitted values.
## S3 method for class 'LOGISTIC' fitted(object, ...)
## S3 method for class 'LOGISTIC' fitted(object, ...)
object |
Fitted model |
... |
Other arguments ignored |
melb_rain |> model(logistic = LOGISTIC(Wet ~ fourier(K = 5, period = "year"))) |> fitted()
melb_rain |> model(logistic = LOGISTIC(Wet ~ fourier(K = 5, period = "year"))) |> fitted()
Produces forecasts from a trained model.
## S3 method for class 'BINNET' forecast(object, new_data, specials = NULL, simulate = TRUE, times = 5000, ...)
## S3 method for class 'BINNET' forecast(object, new_data, specials = NULL, simulate = 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 |
simulate |
If |
times |
The number of sample paths to use in estimating the forecast distribution when |
... |
Other arguments passed to methods |
melb_rain |> model(nn = BINNET(Wet ~ fourier(K = 1, period = "year"))) |> forecast(times = 10)
melb_rain |> model(nn = BINNET(Wet ~ fourier(K = 1, period = "year"))) |> forecast(times = 10)
Produces forecasts from a trained model.
## S3 method for class 'LOGISTIC' forecast( object, new_data, specials = NULL, simulate = FALSE, times = 5000, ... )
## S3 method for class 'LOGISTIC' forecast( object, new_data, specials = NULL, simulate = 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 |
times |
The number of sample paths to use in estimating the forecast distribution when |
... |
Other arguments passed to methods |
melb_rain |> model(logistic = LOGISTIC(Wet ~ fourier(K = 5, period = "year"))) |> forecast(h = "2 years")
melb_rain |> model(logistic = LOGISTIC(Wet ~ fourier(K = 5, period = "year"))) |> forecast(h = "2 years")
Simulates future paths from a dataset using a fitted model.
## S3 method for class 'BINNET' generate(x, new_data, specials = NULL, ...)
## S3 method for class 'BINNET' generate(x, new_data, specials = NULL, ...)
x |
An object. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
... |
Other arguments passed to methods |
melb_rain |> model(nn = BINNET(Wet ~ fourier(K = 1, period = "year"))) |> generate()
melb_rain |> model(nn = BINNET(Wet ~ fourier(K = 1, period = "year"))) |> generate()
Simulates future paths from a dataset using a fitted model.
## S3 method for class 'LOGISTIC' generate(x, new_data, specials, ...)
## S3 method for class 'LOGISTIC' generate(x, new_data, specials, ...)
x |
An object. |
new_data |
A tsibble containing the time points and exogenous regressors to produce forecasts for. |
specials |
(passed by |
... |
Other arguments passed to methods |
melb_rain |> model(logistic = LOGISTIC(Wet ~ fourier(K = 5, period = "year"))) |> generate()
melb_rain |> model(logistic = LOGISTIC(Wet ~ fourier(K = 5, period = "year"))) |> generate()
Construct a single row summary of the BINNET model.
Contains the variance of residuals (sigma2
).
## S3 method for class 'BINNET' glance(x, ...)
## S3 method for class 'BINNET' glance(x, ...)
x |
model or other R object to convert to single-row data frame |
... |
Other arguments ignored |
A one row tibble summarising the model's fit.
melb_rain |> model(nn = BINNET(Wet ~ fourier(K = 1, period = "year"))) |> glance()
melb_rain |> model(nn = BINNET(Wet ~ fourier(K = 1, period = "year"))) |> glance()
Construct a single row summary of the LOGISTIC model.
## S3 method for class 'LOGISTIC' glance(x, ...)
## S3 method for class 'LOGISTIC' 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.
melb_rain |> model(logistic = LOGISTIC(Wet ~ fourier(K = 5, period = "year"))) |> glance()
melb_rain |> model(logistic = LOGISTIC(Wet ~ fourier(K = 5, period = "year"))) |> glance()
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()
.
LOGISTIC(formula)
LOGISTIC(formula)
formula |
Model specification. |
A model specification.
Exogenous regressors can be included in a LOGISTIC 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)
melb_rain |> model(logistic = LOGISTIC(Wet ~ fourier(K = 5, period = "year")))
melb_rain |> model(logistic = LOGISTIC(Wet ~ fourier(K = 5, period = "year")))
A dataset containing daily rainfall amounts from 1 January 2000 to 31 December 2011.
melb_rain
melb_rain
A tsibble
data frame with 4322 rows and 3 variables.
Australian Bureau of Meteorology. http://www.bom.gov.au/climate/data/
Applies a fitted BINNET model to a new dataset.
## S3 method for class 'BINNET' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
## S3 method for class 'BINNET' 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.
LOGISTIC
Applies a fitted LOGISTIC
to a new dataset.
## S3 method for class 'LOGISTIC' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
## S3 method for class 'LOGISTIC' refit(object, new_data, specials = NULL, reestimate = FALSE, ...)
object |
A fitted model object. |
new_data |
A tsibble containing the time points and exogenous regressors for which a refit is required. |
specials |
A list of special functions used in the model, (passed by
|
reestimate |
If TRUE, the networks will be initialized with random starting weights to suit the new data. If FALSE, for every network the best individual set of weights found in the pre-estimation process is used as the starting weight vector. |
... |
Other arguments passed to methods |
Extracts the residuals.
## S3 method for class 'BINNET' residuals(object, ...)
## S3 method for class 'BINNET' residuals(object, ...)
object |
Fitted model |
... |
Other arguments ignored |
melb_rain |> model(nn = BINNET(Wet ~ fourier(K = 1, period = "year"))) |> residuals()
melb_rain |> model(nn = BINNET(Wet ~ fourier(K = 1, period = "year"))) |> residuals()
Extracts the residuals.
## S3 method for class 'LOGISTIC' residuals( object, type = c("deviance", "innovation", "pearson", "working", "response", "partial"), ... )
## S3 method for class 'LOGISTIC' residuals( object, type = c("deviance", "innovation", "pearson", "working", "response", "partial"), ... )
object |
Fitted model |
type |
the type of residuals which should be returned. alternatives are: "deviance" (default), "pearson", "working", "response", and "partial". Can be abbreviated. |
... |
Other arguments ignored |
melb_rain |> model(logistic = LOGISTIC(Wet ~ fourier(K = 5, period = "year"))) |> residuals(type = "deviance")
melb_rain |> model(logistic = LOGISTIC(Wet ~ fourier(K = 5, period = "year"))) |> residuals(type = "deviance")
Returns the coefficients from the model in a tibble
format.
## S3 method for class 'BINNET' tidy(x, ...)
## S3 method for class 'BINNET' tidy(x, ...)
x |
An object to be converted into a tidy |
... |
Additional arguments to tidying method. |
melb_rain |> model(nn = BINNET(Wet ~ fourier(K = 1, period = "year"))) |> tidy()
melb_rain |> model(nn = BINNET(Wet ~ fourier(K = 1, period = "year"))) |> tidy()
Returns the coefficients from the model in a tibble
format.
## S3 method for class 'LOGISTIC' tidy(x, ...)
## S3 method for class 'LOGISTIC' tidy(x, ...)
x |
An object to be converted into a tidy |
... |
Additional arguments to tidying method. |
melb_rain |> model(logistic = LOGISTIC(Wet ~ fourier(K = 5, period = "year"))) |> tidy()
melb_rain |> model(logistic = LOGISTIC(Wet ~ fourier(K = 5, period = "year"))) |> tidy()