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
)

Arguments

observed_time_series

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.

level_scale_prior

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.

slope_mean_prior

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.

slope_scale_prior

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.

autoregressive_coef_prior

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.

initial_level_prior

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.

initial_slope_prior

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.

constrain_ar_coef_stationary

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.

constrain_ar_coef_positive

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.

name

the name of this model component. Default value: 'SemiLocalLinearTrend'.

Value

an instance of StructuralTimeSeries.

Details

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.

See also