Title: | Tidy Tools for Forecasting |
---|---|
Description: | Tidies up the forecasting modeling and prediction work flow, extends the 'broom' package with 'sw_tidy', 'sw_glance', 'sw_augment', and 'sw_tidy_decomp' functions for various forecasting models, and enables converting 'forecast' objects to "tidy" data frames with 'sw_sweep'. |
Authors: | Matt Dancho [aut, cre], Davis Vaughan [aut] |
Maintainer: | Matt Dancho <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.5.9000 |
Built: | 2024-10-25 04:48:34 UTC |
Source: | https://github.com/business-science/sweep |
Adds a sequential index column to a data frame
add_index(ret, rename_index)
add_index(ret, rename_index)
ret |
An object of class tibble |
rename_index |
A variable indicating the index name to be used in the tibble returned |
Refer to forecast:::arima.string.
forecast
arima.R
arima_string(object, padding = FALSE)
arima_string(object, padding = FALSE)
object |
An object of class Arima |
padding |
Add padding to the name returned |
Refer to forecast:::makeText.
forecast
bats.R
bats_string(object)
bats_string(object)
object |
An object of class bats |
A dataset containing the fictional bicycle orders spanning 2011 through 2015.
Hypothetically, the bike_sales
data are similar to sales data mainatained
in a business' sales data base. The unit price and model names come from
data provided by model for the bicycle manufacturer, Cannondale (2016).
The customers (bicycle shops) including name, location, etc and
the orders including quantity purchased and order dates are fictional.
The data is intended for implementing business analytics techniques
(e.g. forecast, clustering, etc) to identify underlying trends.
bike_sales
bike_sales
A data frame with 15644 rows and 17 variables:
Date the order was placed
A unique order identification number
The sequential identification number for products on and order
Number of units purchased
The unit price of the bicycle
The extended price = price x quantity
A unique customer identification number
The customer name
The city that the bike shop is located
The state that the bike shop is located
The geograhpic latitude of the customer location
The geograhpic longitude of the customer location
A unique product identification number
The model name of the bicycle
The main bicycle category, either "Mountain" or "Road"
One of nine more specific bicycle categories
The bicycle frame material, either "Carbon" or "Aluminum"
The 2016 bicycle model names and prices originated from https://www.cannondale.com/en-us
Given an R statistical model or other non-tidy object, add columns to the original dataset such as predictions, residuals and cluster assignments.
sw_augment(x, ...)
sw_augment(x, ...)
x |
model or other R object to convert to data frame |
... |
other arguments passed to methods |
sw_augment()
is a wrapper for broom::augment()
. The benefit of sw_augment
is that it has methods for various time-series model classes such as
HoltWinters
, ets
, Arima
, etc.
For non-time series, sw_augment()
defaults to broom::augment()
.
The only difference is that the return is a tibble.
Note that by convention the first argument is almost always data
,
which specifies the original data object. This is not part of the S3
signature, partly because it prevents rowwise_df_tidiers from
taking a column name as the first argument.
Augments data
sw_augment_columns(ret, data, rename_index, timetk_idx = FALSE)
sw_augment_columns(ret, data, rename_index, timetk_idx = FALSE)
ret |
An object of class tibble |
data |
Any time series data that is to be augmented |
rename_index |
A variable indicating the index name to be used in the tibble returned |
timetk_idx |
Uses the timetk index (irregular time index) if present. |
By default, sw_augment()
uses broom::augment()
to convert its output.
## Default S3 method: sw_augment(x, ...)
## Default S3 method: sw_augment(x, ...)
x |
an object to be tidied |
... |
extra arguments passed to |
A tibble generated by broom::augment()
Construct a single row summary "glance" of a model, fit, or other object
sw_glance(x, ...)
sw_glance(x, ...)
x |
model or other R object to convert to single-row data frame |
... |
other arguments passed to methods |
sw_glance()
is a wrapper for broom::glance()
. The benefit of sw_glance
is that it has methods for various time-series model classes such as
HoltWinters
, ets
, Arima
, etc.
sw_glance
methods always return either a one-row tibble or NULL
.
The single row includes summary statistics relevent to the model accuracy,
which can be used to assess model fit and quality.
For non-time series, sw_glance()
defaults to broom::glance()
.
The only difference is that the return is a tibble.
single-row tibble with model summary information.
By default, sw_glance()
uses broom::glance()
to convert its output.
## Default S3 method: sw_glance(x, ...)
## Default S3 method: sw_glance(x, ...)
x |
an object to be tidied |
... |
extra arguments passed to |
A tibble generated by broom::glance()
Tidy forecast objects
sw_sweep(x, fitted = FALSE, timetk_idx = FALSE, rename_index = "index", ...)
sw_sweep(x, fitted = FALSE, timetk_idx = FALSE, rename_index = "index", ...)
x |
A time-series forecast of class |
fitted |
Whether or not to return the fitted values (model values) in the results. FALSE by default. |
timetk_idx |
If timetk index (non-regularized index) is present, uses it to develop forecast. Otherwise uses default index. |
rename_index |
Enables the index column to be renamed. |
... |
Additional arguments passed to |
sw_sweep
is designed
to coerce forecast
objects from the forecast
package
into tibble
objects in a "tidy" format (long).
The returned object contains both the actual values
and the forecasted values including the point forecast and upper and lower
confidence intervals.
The timetk_idx
argument is used to modify the return format of the index.
If timetk_idx = FALSE
, a regularized time index is always constructed.
This may be in the format of numeric values (e.g. 2010.000) or the
higher order yearmon
and yearqtr
classes from the zoo
package.
A higher order class is attempted to be returned.
If timetk_idx = TRUE
and a timetk index is present, an irregular time index
will be returned that combines the original time series (i.e. date or datetime)
along with a computed future time series created using tk_make_future_timeseries()
from the timetk
package. The ...
can be used to pass additional arguments
to tk_make_future_timeseries()
such as inspect_weekdays
, skip_values
, etc
that can be useful in tuning the future time series sequence.
The index column name can be changed using the rename_index
argument.
Returns a tibble
object.
library(forecast) library(dplyr) # ETS forecasts USAccDeaths %>% ets() %>% forecast(level = c(80, 95, 99)) %>% sw_sweep()
library(forecast) library(dplyr) # ETS forecasts USAccDeaths %>% ets() %>% forecast(level = c(80, 95, 99)) %>% sw_sweep()
Tidy the result of a time-series model into a summary tibble
sw_tidy(x, ...)
sw_tidy(x, ...)
x |
An object to be converted into a tibble ("tidy" data.frame) |
... |
extra arguments |
sw_tidy()
is a wrapper for broom::tidy()
. The main benefit of sw_tidy()
is that it has methods for various time-series model classes such as
HoltWinters
, ets
, Arima
, etc.
sw_tidy()
methods always returns a "tidy" tibble with model coefficient / parameters.
For non-time series, sw_tidy()
defaults to broom::tidy()
.
The only difference is that the return is a tibble.
The output of sw_tidy()
is always a tibble with disposable row names. It is
therefore suited for further manipulation by packages like dplyr and
ggplot2.
a tibble
library(dplyr) library(forecast) WWWusage %>% auto.arima() %>% sw_tidy(conf.int = TRUE)
library(dplyr) library(forecast) WWWusage %>% auto.arima() %>% sw_tidy(conf.int = TRUE)
Coerces decomposed time-series objects to tibble format.
sw_tidy_decomp(x, timetk_idx = FALSE, rename_index = "index", ...)
sw_tidy_decomp(x, timetk_idx = FALSE, rename_index = "index", ...)
x |
A time-series object of class |
timetk_idx |
When |
rename_index |
Enables the index column to be renamed. |
... |
Not used. |
sw_tidy_decomp
is designed
to coerce time-series objects with decompositions to tibble
objects.
A regularized time index is always constructed. If no time index is
detected, a sequential index is returned as a default.
The index column name can be changed using the rename_index
argument.
Returns a tibble
object.
library(dplyr) library(forecast) library(sweep) # Decompose ETS model USAccDeaths %>% ets() %>% sw_tidy_decomp() # Decompose STL object USAccDeaths %>% stl(s.window = 'periodic') %>% sw_tidy_decomp()
library(dplyr) library(forecast) library(sweep) # Decompose ETS model USAccDeaths %>% ets() %>% sw_tidy_decomp() # Decompose STL object USAccDeaths %>% stl(s.window = 'periodic') %>% sw_tidy_decomp()
By default, sw_tidy()
uses broom::tidy()
to convert its output.
## Default S3 method: sw_tidy(x, ...)
## Default S3 method: sw_tidy(x, ...)
x |
an object to be tidied |
... |
extra arguments passed to |
A tibble generated by broom::tidy()
Refer to forecast:::makeTextTBATS.
forecast
bats.R
tbats_string(object)
tbats_string(object)
object |
An object of class bats or tbats |
These methods tidy the coefficients of ARIMA models of univariate time series.
## S3 method for class 'Arima' sw_tidy(x, ...) ## S3 method for class 'Arima' sw_glance(x, ...) ## S3 method for class 'Arima' sw_augment(x, data = NULL, rename_index = "index", timetk_idx = FALSE, ...) ## S3 method for class 'stlm' sw_tidy(x, ...)
## S3 method for class 'Arima' sw_tidy(x, ...) ## S3 method for class 'Arima' sw_glance(x, ...) ## S3 method for class 'Arima' sw_augment(x, data = NULL, rename_index = "index", timetk_idx = FALSE, ...) ## S3 method for class 'stlm' sw_tidy(x, ...)
x |
An object of class "Arima" |
... |
Additional parameters (not used) |
data |
Used with |
rename_index |
Used with |
timetk_idx |
Used with |
sw_tidy()
returns one row for each coefficient in the model,
with five columns:
term
: The term in the nonlinear model being estimated and tested
estimate
: The estimated coefficient
sw_glance()
returns one row with the columns
model.desc
: A description of the model including the
three integer components (p, d, q) are the AR order,
the degree of differencing, and the MA order.
sigma
: The square root of the estimated residual variance
logLik
: The data's log-likelihood under the model
AIC
: The Akaike Information Criterion
BIC
: The Bayesian Information Criterion
ME
: Mean error
RMSE
: Root mean squared error
MAE
: Mean absolute error
MPE
: Mean percentage error
MAPE
: Mean absolute percentage error
MASE
: Mean absolute scaled error
ACF1
: Autocorrelation of errors at lag 1
sw_augment()
returns a tibble with the following time series attributes:
index
: An index is either attempted to be extracted from the model or
a sequential index is created for plotting purposes
.actual
: The original time series
.fitted
: The fitted values from the model
.resid
: The residual values from the model
sw_tidy()
returns the underlying ETS or ARIMA model's sw_tidy()
one row for each coefficient in the model,
with five columns:
term
: The term in the nonlinear model being estimated and tested
estimate
: The estimated coefficient
library(dplyr) library(forecast) fit_arima <- WWWusage %>% auto.arima() sw_tidy(fit_arima) sw_glance(fit_arima) sw_augment(fit_arima)
library(dplyr) library(forecast) fit_arima <- WWWusage %>% auto.arima() sw_tidy(fit_arima) sw_glance(fit_arima) sw_augment(fit_arima)
Tidying methods for BATS and TBATS modeling of time series
## S3 method for class 'bats' sw_tidy(x, ...) ## S3 method for class 'bats' sw_glance(x, ...) ## S3 method for class 'bats' sw_augment(x, data = NULL, rename_index = "index", timetk_idx = FALSE, ...) ## S3 method for class 'bats' sw_tidy_decomp(x, timetk_idx = FALSE, rename_index = "index", ...)
## S3 method for class 'bats' sw_tidy(x, ...) ## S3 method for class 'bats' sw_glance(x, ...) ## S3 method for class 'bats' sw_augment(x, data = NULL, rename_index = "index", timetk_idx = FALSE, ...) ## S3 method for class 'bats' sw_tidy_decomp(x, timetk_idx = FALSE, rename_index = "index", ...)
x |
An object of class "bats" or "tbats" |
... |
Additional parameters (not used) |
data |
Used with |
rename_index |
Used with |
timetk_idx |
Used with |
sw_tidy()
returns one row for each model parameter,
with two columns:
term
: The various parameters (lambda, alpha, gamma, etc)
estimate
: The estimated parameter value
sw_glance()
returns one row with the columns
model.desc
: A description of the model including the
three integer components (p, d, q) are the AR order,
the degree of differencing, and the MA order.
sigma
: The square root of the estimated residual variance
logLik
: The data's log-likelihood under the model
AIC
: The Akaike Information Criterion
BIC
: The Bayesian Information Criterion (NA
for bats / tbats)
ME
: Mean error
RMSE
: Root mean squared error
MAE
: Mean absolute error
MPE
: Mean percentage error
MAPE
: Mean absolute percentage error
MASE
: Mean absolute scaled error
ACF1
: Autocorrelation of errors at lag 1
sw_augment()
returns a tibble with the following time series attributes:
index
: An index is either attempted to be extracted from the model or
a sequential index is created for plotting purposes
.actual
: The original time series
.fitted
: The fitted values from the model
.resid
: The residual values from the model
sw_tidy_decomp()
returns a tibble with the following time series attributes:
index
: An index is either attempted to be extracted from the model or
a sequential index is created for plotting purposes
observed
: The original time series
level
: The level component
slope
: The slope component (Not always present)
season
: The seasonal component (Not always present)
library(dplyr) library(forecast) fit_bats <- WWWusage %>% bats() sw_tidy(fit_bats) sw_glance(fit_bats) sw_augment(fit_bats)
library(dplyr) library(forecast) fit_bats <- WWWusage %>% bats() sw_tidy(fit_bats) sw_glance(fit_bats) sw_augment(fit_bats)
Tidying methods for decomposed time series
## S3 method for class 'decomposed.ts' sw_tidy_decomp(x, timetk_idx = FALSE, rename_index = "index", ...)
## S3 method for class 'decomposed.ts' sw_tidy_decomp(x, timetk_idx = FALSE, rename_index = "index", ...)
x |
An object of class "decomposed.ts" |
timetk_idx |
Used with |
rename_index |
Used with |
... |
Not used. |
sw_tidy_decomp()
returns a tibble with the following time series attributes:
index
: An index is either attempted to be extracted from the model or
a sequential index is created for plotting purposes
season
: The seasonal component
trend
: The trend component
random
: The error component
seasadj
: observed - season
library(dplyr) library(forecast) fit_decomposed <- USAccDeaths %>% decompose() sw_tidy_decomp(fit_decomposed)
library(dplyr) library(forecast) fit_decomposed <- USAccDeaths %>% decompose() sw_tidy_decomp(fit_decomposed)
Tidying methods for ETS (Error, Trend, Seasonal) exponential smoothing modeling of time series
## S3 method for class 'ets' sw_tidy(x, ...) ## S3 method for class 'ets' sw_glance(x, ...) ## S3 method for class 'ets' sw_augment(x, data = NULL, timetk_idx = FALSE, rename_index = "index", ...) ## S3 method for class 'ets' sw_tidy_decomp(x, timetk_idx = FALSE, rename_index = "index", ...)
## S3 method for class 'ets' sw_tidy(x, ...) ## S3 method for class 'ets' sw_glance(x, ...) ## S3 method for class 'ets' sw_augment(x, data = NULL, timetk_idx = FALSE, rename_index = "index", ...) ## S3 method for class 'ets' sw_tidy_decomp(x, timetk_idx = FALSE, rename_index = "index", ...)
x |
An object of class "ets" |
... |
Not used. |
data |
Used with |
timetk_idx |
Used with |
rename_index |
Used with |
sw_tidy()
returns one row for each model parameter,
with two columns:
term
: The smoothing parameters (alpha, gamma) and the initial states
(l, s0 through s10)
estimate
: The estimated parameter value
sw_glance()
returns one row with the columns
model.desc
: A description of the model including the
three integer components (p, d, q) are the AR order,
the degree of differencing, and the MA order.
sigma
: The square root of the estimated residual variance
logLik
: The data's log-likelihood under the model
AIC
: The Akaike Information Criterion
BIC
: The Bayesian Information Criterion
ME
: Mean error
RMSE
: Root mean squared error
MAE
: Mean absolute error
MPE
: Mean percentage error
MAPE
: Mean absolute percentage error
MASE
: Mean absolute scaled error
ACF1
: Autocorrelation of errors at lag 1
sw_augment()
returns a tibble with the following time series attributes:
index
: An index is either attempted to be extracted from the model or
a sequential index is created for plotting purposes
.actual
: The original time series
.fitted
: The fitted values from the model
.resid
: The residual values from the model
sw_tidy_decomp()
returns a tibble with the following time series attributes:
index
: An index is either attempted to be extracted from the model or
a sequential index is created for plotting purposes
observed
: The original time series
level
: The level component
slope
: The slope component (Not always present)
season
: The seasonal component (Not always present)
library(dplyr) library(forecast) fit_ets <- WWWusage %>% ets() sw_tidy(fit_ets) sw_glance(fit_ets) sw_augment(fit_ets) sw_tidy_decomp(fit_ets)
library(dplyr) library(forecast) fit_ets <- WWWusage %>% ets() sw_tidy(fit_ets) sw_glance(fit_ets) sw_augment(fit_ets) sw_tidy_decomp(fit_ets)
These methods tidy HoltWinters
models of univariate time
series.
## S3 method for class 'HoltWinters' sw_tidy(x, ...) ## S3 method for class 'HoltWinters' sw_glance(x, ...) ## S3 method for class 'HoltWinters' sw_augment(x, data = NULL, rename_index = "index", timetk_idx = FALSE, ...) ## S3 method for class 'HoltWinters' sw_tidy_decomp(x, timetk_idx = FALSE, rename_index = "index", ...)
## S3 method for class 'HoltWinters' sw_tidy(x, ...) ## S3 method for class 'HoltWinters' sw_glance(x, ...) ## S3 method for class 'HoltWinters' sw_augment(x, data = NULL, rename_index = "index", timetk_idx = FALSE, ...) ## S3 method for class 'HoltWinters' sw_tidy_decomp(x, timetk_idx = FALSE, rename_index = "index", ...)
x |
An object of class "HoltWinters" |
... |
Additional parameters (not used) |
data |
Used with |
rename_index |
Used with |
timetk_idx |
Used with |
sw_tidy()
returns one row for each model parameter,
with two columns:
term
: The various parameters (alpha, beta, gamma, and coefficients)
estimate
: The estimated parameter value
sw_glance()
returns one row with the following columns:
model.desc
: A description of the model
sigma
: The square root of the estimated residual variance
logLik
: The data's log-likelihood under the model
AIC
: The Akaike Information Criterion
BIC
: The Bayesian Information Criterion (NA
for bats / tbats)
ME
: Mean error
RMSE
: Root mean squared error
MAE
: Mean absolute error
MPE
: Mean percentage error
MAPE
: Mean absolute percentage error
MASE
: Mean absolute scaled error
ACF1
: Autocorrelation of errors at lag 1
sw_augment()
returns a tibble with the following time series attributes:
index
: An index is either attempted to be extracted from the model or
a sequential index is created for plotting purposes
.actual
: The original time series
.fitted
: The fitted values from the model
.resid
: The residual values from the model
sw_tidy_decomp()
returns a tibble with the following time series attributes:
index
: An index is either attempted to be extracted from the model or
a sequential index is created for plotting purposes
observed
: The original time series
season
: The seasonal component
trend
: The trend component
remainder
: observed - (season + trend)
seasadj
: observed - season (or trend + remainder)
library(dplyr) library(forecast) fit_hw <- USAccDeaths %>% stats::HoltWinters() sw_tidy(fit_hw) sw_glance(fit_hw) sw_augment(fit_hw) sw_tidy_decomp(fit_hw)
library(dplyr) library(forecast) fit_hw <- USAccDeaths %>% stats::HoltWinters() sw_tidy(fit_hw) sw_glance(fit_hw) sw_augment(fit_hw) sw_tidy_decomp(fit_hw)
These methods tidy the coefficients of NNETAR models of univariate time series.
## S3 method for class 'nnetar' sw_tidy(x, ...) ## S3 method for class 'nnetar' sw_glance(x, ...) ## S3 method for class 'nnetar' sw_augment(x, data = NULL, timetk_idx = FALSE, rename_index = "index", ...)
## S3 method for class 'nnetar' sw_tidy(x, ...) ## S3 method for class 'nnetar' sw_glance(x, ...) ## S3 method for class 'nnetar' sw_augment(x, data = NULL, timetk_idx = FALSE, rename_index = "index", ...)
x |
An object of class "nnetar" |
... |
Additional parameters (not used) |
data |
Used with |
timetk_idx |
Used with |
rename_index |
Used with |
sw_tidy()
returns one row for each model parameter,
with two columns:
term
: The smoothing parameters (alpha, gamma) and the initial states
(l, s0 through s10)
estimate
: The estimated parameter value
sw_glance()
returns one row with the columns
model.desc
: A description of the model including the
three integer components (p, d, q) are the AR order,
the degree of differencing, and the MA order.
sigma
: The square root of the estimated residual variance
logLik
: The data's log-likelihood under the model (NA
)
AIC
: The Akaike Information Criterion (NA
)
BIC
: The Bayesian Information Criterion (NA
)
ME
: Mean error
RMSE
: Root mean squared error
MAE
: Mean absolute error
MPE
: Mean percentage error
MAPE
: Mean absolute percentage error
MASE
: Mean absolute scaled error
ACF1
: Autocorrelation of errors at lag 1
sw_augment()
returns a tibble with the following time series attributes:
index
: An index is either attempted to be extracted from the model or
a sequential index is created for plotting purposes
.actual
: The original time series
.fitted
: The fitted values from the model
.resid
: The residual values from the model
library(dplyr) library(forecast) fit_nnetar <- lynx %>% nnetar() sw_tidy(fit_nnetar) sw_glance(fit_nnetar) sw_augment(fit_nnetar)
library(dplyr) library(forecast) fit_nnetar <- lynx %>% nnetar() sw_tidy(fit_nnetar) sw_glance(fit_nnetar) sw_augment(fit_nnetar)
Tidying methods for STL (Seasonal, Trend, Level) decomposition of time series
## S3 method for class 'stl' sw_tidy(x, ...) ## S3 method for class 'stl' sw_tidy_decomp(x, timetk_idx = FALSE, rename_index = "index", ...) ## S3 method for class 'stlm' sw_tidy_decomp(x, timetk_idx = FALSE, rename_index = "index", ...) ## S3 method for class 'stlm' sw_glance(x, ...) ## S3 method for class 'stlm' sw_augment(x, data = NULL, rename_index = "index", timetk_idx = FALSE, ...)
## S3 method for class 'stl' sw_tidy(x, ...) ## S3 method for class 'stl' sw_tidy_decomp(x, timetk_idx = FALSE, rename_index = "index", ...) ## S3 method for class 'stlm' sw_tidy_decomp(x, timetk_idx = FALSE, rename_index = "index", ...) ## S3 method for class 'stlm' sw_glance(x, ...) ## S3 method for class 'stlm' sw_augment(x, data = NULL, rename_index = "index", timetk_idx = FALSE, ...)
x |
An object of class "stl" |
... |
Not used. |
timetk_idx |
Used with |
rename_index |
Used with |
data |
Used with |
sw_tidy()
wraps sw_tidy_decomp()
sw_tidy_decomp()
returns a tibble with the following time series attributes:
index
: An index is either attempted to be extracted from the model or
a sequential index is created for plotting purposes
season
: The seasonal component
trend
: The trend component
remainder
: observed - (season + trend)
seasadj
: observed - season (or trend + remainder)
sw_glance()
returns the underlying ETS or ARIMA model's sw_glance()
results one row with the columns
model.desc
: A description of the model including the
three integer components (p, d, q) are the AR order,
the degree of differencing, and the MA order.
sigma
: The square root of the estimated residual variance
logLik
: The data's log-likelihood under the model
AIC
: The Akaike Information Criterion
BIC
: The Bayesian Information Criterion
ME
: Mean error
RMSE
: Root mean squared error
MAE
: Mean absolute error
MPE
: Mean percentage error
MAPE
: Mean absolute percentage error
MASE
: Mean absolute scaled error
ACF1
: Autocorrelation of errors at lag 1
sw_augment()
returns a tibble with the following time series attributes:
index
: An index is either attempted to be extracted from the model or
a sequential index is created for plotting purposes
.actual
: The original time series
.fitted
: The fitted values from the model
.resid
: The residual values from the model
library(dplyr) library(forecast) library(sweep) fit_stl <- USAccDeaths %>% stl(s.window = "periodic") sw_tidy_decomp(fit_stl)
library(dplyr) library(forecast) library(sweep) fit_stl <- USAccDeaths %>% stl(s.window = "periodic") sw_tidy_decomp(fit_stl)
These methods tidy the coefficients of StructTS models of univariate time series.
## S3 method for class 'StructTS' sw_tidy(x, ...) ## S3 method for class 'StructTS' sw_glance(x, ...) ## S3 method for class 'StructTS' sw_augment(x, data = NULL, timetk_idx = FALSE, rename_index = "index", ...)
## S3 method for class 'StructTS' sw_tidy(x, ...) ## S3 method for class 'StructTS' sw_glance(x, ...) ## S3 method for class 'StructTS' sw_augment(x, data = NULL, timetk_idx = FALSE, rename_index = "index", ...)
x |
An object of class "StructTS" |
... |
Additional parameters (not used) |
data |
Used with |
timetk_idx |
Used with |
rename_index |
Used with |
sw_tidy()
returns one row for each model parameter,
with two columns:
term
: The model parameters
estimate
: The estimated parameter value
sw_glance()
returns one row with the columns
model.desc
: A description of the model including the
three integer components (p, d, q) are the AR order,
the degree of differencing, and the MA order.
sigma
: The square root of the estimated residual variance
logLik
: The data's log-likelihood under the model
AIC
: The Akaike Information Criterion
BIC
: The Bayesian Information Criterion
ME
: Mean error
RMSE
: Root mean squared error
MAE
: Mean absolute error
MPE
: Mean percentage error
MAPE
: Mean absolute percentage error
MASE
: Mean absolute scaled error
ACF1
: Autocorrelation of errors at lag 1
sw_augment()
returns a tibble with the following time series attributes:
index
: An index is either attempted to be extracted from the model or
a sequential index is created for plotting purposes
.actual
: The original time series
.fitted
: The fitted values from the model
.resid
: The residual values from the model
library(dplyr) library(forecast) fit_StructTS <- WWWusage %>% StructTS() sw_tidy(fit_StructTS) sw_glance(fit_StructTS) sw_augment(fit_StructTS)
library(dplyr) library(forecast) fit_StructTS <- WWWusage %>% StructTS() sw_tidy(fit_StructTS) sw_glance(fit_StructTS) sw_augment(fit_StructTS)
Validates data frame has column named the same name as variable rename_index
validate_index(ret, rename_index)
validate_index(ret, rename_index)
ret |
An object of class tibble |
rename_index |
A variable indicating the index name to be used in the tibble returned |