Estimate Theta method.
Forecast with fitted Theta method.
Produce a plot of the fitted Theta method.
theta(y, m = NULL, sign.level = 0.05, cost0 = c("MSE", "MdSE", "MAE",
"MdAE"), cost2 = c("MSE", "MdSE", "MAE", "MdAE"), costs = c("MSE",
"MdSE", "MAE", "MdAE"), multiplicative = c("multiplicative",
"additive", "auto"), cma = NULL, outliers = NULL)# S3 method for theta
forecast(object, h = NULL, ...)
# S3 method for theta
plot(x, thetalines = c(TRUE, FALSE), ...)
theta.thief(y, h = NULL, ...)
input time series. Can be ts
object.
seasonal period. If y
is a ts
object then the default is its frequency.
significance level for trend and seasonality tests.
cost function of theta0 line. Can be:
"MSE"
: mean squared error.
"MdSE"
: median squared error.
"MAE"
: mean absolute error.
"MdAE"
: median absolute error.
cost function of theta2 line. Same options as cost0
.
cost function of seasonal element. Same options as cost0
.
type of seasonal decomposition. This can be "multiplicative"
, "additive"
or "auto"
. If y
contains non-positive values then this is forced to "additive"
.
input precalculated level/trend for the analysis. Use NULL
to estimate internally.
provide vector of location of observations that are considered outliers (see residout
). These will be considered in the estimation of theta0. For no outliers use NULL
.
object of class theta
.
forecast horizon. If h
is NULL
, then the horizon is set equal to the the seasonal frequency.
additional arguments passed to functions.
object of class theta
.
if TRUE
, then theta lines are included in the plot.
An object of class theta
, containing:
"method"
: "Theta".
"y"
: the input time series.
"m"
: seasonal periods.
"exist"
: Statistical testing results, exist[1]
is the result for trend, exist[2]
is for season.
"multiplicative"
: If TRUE
, then seasonality is modelled multiplicatively.
"theta0"
: fitted theta0 line values.
"theta2"
: fitted theta2 line values.
"season"
: fitted season values.
"x.out"
: modelled outliers.
"cost"
: cost functions for theta0, theta2 and season components.
"a"
: SES parameters of theta2.
"b"
: regression parameters of theta0.
"p"
: coefficients of outliers from theta0 and theta2 estimation.
"g"
: pure seasonal exponential smoothing parameters.
"fitted"
: fitted values.
"residuals"
: in-sample residuals.
"MSE"
: in-sample Mean Squared Error.
theta.thief
: Wrapper function to use Theta with thief
.
This implementation of the Theta method tests automatically for seasonality and trend. Seasonal decomposition can be done either additively or multiplicatively and the seasonality is treated as a pure seasonal model. The various Theta components can be optimised using different cost functions. The originally proposed Theta method always assumed multiplicative seasonality and presence of trend, while all theta lines were optimised using MSE and seasonality was estimated using classical decomposition.
The original Theta method was proposed by: Assimakopoulos, V., & Nikolopoulos, K. (2000). The theta model: a decomposition approach to forecasting. International journal of forecasting, 16(4), 521-530. See details in how the implementation here differs.
The THieF forecasting methodology used for theta.thief
is proposed by: Athanasopoulos, G., Hyndman, R. J., Kourentzes, N., & Petropoulos, F. (2017). Forecasting with temporal hierarchies. European Journal of Operational Research, 262(1), 60-74.
# NOT RUN {
fit <- theta(referrals)
plot(fit)
forecast.theta(fit,h=12) # Or simply use forecast(fit)
# }
# NOT RUN {
library(thief)
thief(referrals,forecastfunction=theta.thief)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab