Like the sts_local_linear_trend
model, a semi-local linear trend posits a
latent level
and slope
, with the level component updated according to
the current slope plus a random walk:
sts_semi_local_linear_trend(
observed_time_series = NULL,
level_scale_prior = NULL,
slope_mean_prior = NULL,
slope_scale_prior = NULL,
autoregressive_coef_prior = NULL,
initial_level_prior = NULL,
initial_slope_prior = NULL,
constrain_ar_coef_stationary = TRUE,
constrain_ar_coef_positive = FALSE,
name = NULL
)
an instance of StructuralTimeSeries
.
optional float
tensor
of shape
batch_shape + [T, 1]
(omitting the trailing unit dimension is also
supported when T > 1
), specifying an observed time series.
Any priors not explicitly set will be given default values according to
the scale of the observed time series (or batch of time series). May
optionally be an instance of sts_masked_time_series
, which includes
a mask tensor
to specify timesteps with missing observations.
Default value: NULL
.
optional tfp$distribution
instance specifying a prior
on the level_scale
parameter. If NULL
, a heuristic default prior is
constructed based on the provided observed_time_series
.
Default value: NULL
.
optional tfd$Distribution
instance specifying a prior
on the slope_mean
parameter. If NULL
, a heuristic default prior is
constructed based on the provided observed_time_series
. Default value: NULL
.
optional tfd$Distribution
instance specifying a prior
on the slope_scale
parameter. If NULL
, a heuristic default prior is
constructed based on the provided observed_time_series
. Default value: NULL
.
optional tfd$Distribution
instance specifying
a prior on the autoregressive_coef
parameter. If NULL
, the default
prior is a standard Normal(0, 1)
. Note that the prior may be
implicitly truncated by constrain_ar_coef_stationary
and/or constrain_ar_coef_positive
.
Default value: NULL
.
optional tfp$distribution
instance specifying a
prior on the initial level. If NULL
, a heuristic default prior is
constructed based on the provided observed_time_series
.
Default value: NULL
.
optional tfd$Distribution
instance specifying a
prior on the initial slope. If NULL
, a heuristic default prior is
constructed based on the provided observed_time_series
. Default value: NULL
.
if TRUE
, perform inference using a
parameterization that restricts autoregressive_coef
to the interval
(-1, 1)
, or (0, 1)
if force_positive_ar_coef
is also TRUE
,
corresponding to stationary processes. This will implicitly truncate
the support of autoregressive_coef_prior
. Default value: TRUE
.
if TRUE
, perform inference using a
parameterization that restricts autoregressive_coef
to be positive,
or in (0, 1)
if constrain_ar_coef_stationary
is also TRUE
. This
will implicitly truncate the support of autoregressive_coef_prior
.
Default value: FALSE
.
the name of this model component. Default value: 'SemiLocalLinearTrend'.
level[t] = level[t-1] + slope[t-1] + Normal(0., level_scale)
The slope component in a sts_semi_local_linear_trend
model evolves according to
a first-order autoregressive (AR1) process with potentially nonzero mean:
slope[t] = (slope_mean + autoregressive_coef * (slope[t-1] - slope_mean) + Normal(0., slope_scale))
Unlike the random walk used in LocalLinearTrend
, a stationary
AR1 process (coefficient in (-1, 1)
) maintains bounded variance over time,
so a SemiLocalLinearTrend
model will often produce more reasonable
uncertainties when forecasting over long timescales.
For usage examples see sts_fit_with_hmc()
, sts_forecast()
, sts_decompose_by_component()
.
Other sts:
sts_additive_state_space_model()
,
sts_autoregressive_state_space_model()
,
sts_autoregressive()
,
sts_constrained_seasonal_state_space_model()
,
sts_dynamic_linear_regression_state_space_model()
,
sts_dynamic_linear_regression()
,
sts_linear_regression()
,
sts_local_level_state_space_model()
,
sts_local_level()
,
sts_local_linear_trend_state_space_model()
,
sts_local_linear_trend()
,
sts_seasonal_state_space_model()
,
sts_seasonal()
,
sts_semi_local_linear_trend_state_space_model()
,
sts_smooth_seasonal_state_space_model()
,
sts_smooth_seasonal()
,
sts_sparse_linear_regression()
,
sts_sum()