Description Usage Arguments Value Author(s) Examples
Estimates a structural time series model using the Kalman filter and maximum likelihood. The seasonal and cycle components are assumed to be of a trigonometric form. The function checks three trend specifications to decompose a univariate time series into trend, cycle, and/or seasonal components plus noise. The function automatically detects the frequency and checks for a seasonal and cycle component if the user does not specify the frequency or decomposition model. This can be turned off by setting freq or specifying decomp. State space model for decomposition follows Yt = T_t + C_t + S_t + BX_t + e_t, e_t ~ N(0, sig_e^2) Y is the data T is the trend component C is the cycle component S is the seasonal component X is the exogenous data with parameter vector B e is the observation error
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | tcs_decomp_estim(
y,
exo = NULL,
freq = NULL,
decomp = NULL,
trend_spec = NULL,
multiplicative = NULL,
par = NULL,
harmonics = NULL,
det_obs = F,
det_trend = F,
det_seas = F,
det_cycle = F,
det_drift = F,
wavelet.method = "ARIMA",
wavelet.sim = 100,
level = 0.01,
optim_methods = c("BFGS", "NM", "CG", "SANN"),
maxit = 10000,
verbose = F
)
|
y |
Univariate time series of data values. May also be a 2 column data frame containing a date column. |
exo |
Matrix of exogenous variables. Can be used to specify regression effects or other seasonal effects like holidays, etc. |
freq |
Frequency of the data (1 (yearly), 4 (quarterly), 12 (monthly), 52 (weekly), 365 (daily)), default is NULL and will be automatically detected |
decomp |
Decomposition model ("tend-cycle-seasonal", "trend-seasonal", "trend-cycle", "trend-noise") |
trend_spec |
Trend specification ("rw", "rwd", "2rw"). The default is NULL which will choose the best of all specifications based on the maximum likielhood. "rw" is the random walk trend. "rwd" is the random walk with random walk drift trend. "2rw" is a 2nd order random walk trend. |
multiplicative |
If data should be logged to create a multiplicative model |
par |
Initial parameters, defalut is NULL |
harmonics |
The seasonal harmonics to include, default is NULL which results in unique(1:floor(seasons/2)) |
det_obs |
Set the observation equation error variance to 0 (deterministic observation equation) |
det_trend |
Set the trend error variance to 0 (deterministic trend) |
det_seas |
Set the seasonality error variances to 0 (deterministic seasonality) |
det_cycle |
Set thecycle error variance to 0 (deterministic cycle) |
det_drift |
Set the drift error variance to 0 (deterministic drift) |
wavelet.method |
Method for wavelet analysis comparison ("white.nose", "shuffle", "Fourier.rand", "AR", "ARIMA"). Default is "ARIMA". |
wavelet.sim |
Number of simulations for wavelet analysis. Default is 100 |
optim_methods |
Vector of 1 to 3 optimization methods in order of preference ("NR", "BFGS", "CG", "BHHH", or "SANN") |
maxit |
Maximum number of iterations for the optimization |
List of estimation values including coefficients, convergence code, datea frequency, decomposition used, and trend specification selected.
Alex Hubbard (hubbard.alex@gmail.com)
1 2 3 4 5 6 7 8 9 10 11 | tcs_decomp_estim(y = DT[, c("date", "y")])
If multiplicative = T, then the data is logged and the original model becomes multiplicative (Y_t = T_t * C_t * S_t * BX_t * e_t)
If trend is "rw", the trend model is T_t = T_{t-1} + e_t, e_t ~ N(0, sig_t^2)
If trend is "rwd", the trend model is T_t = M_{t-1} + T_{t-1} + e_t, e_t ~ N(0, sig_t^2) with
M_t = M_{t-1} + n_t, n_t ~ N(0, sig_m^2) where
If trend is "2rw", the trend model is T_t = 2T_{t-1} - T_{t-2} + e_t, e_t ~ N(0, sig_t^2)
If det_obs = T then sig_e is set to 0
If det_trend = T then the variacne of the trend (sig_t) is set to 0 and is referred to as a smooth trend
If det_drift = T then the variance of the drift (sig_m) is set to 0 and is refereed to as a deterministic drift
If det_seas = T then the variance all seasonality frequencies j (sig_s) are set to 0 and is referred to as deterministic seasonality
If det_cycle = T then the variance of the cyclce (sig_c) is set to 0 and is refreed to as a deterministic cycle
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.