R/sts.R
sts_semi_local_linear_trend_state_space_model.Rd
A state space model (SSM) posits a set of latent (unobserved) variables that
evolve over time with dynamics specified by a probabilistic transition model
p(z[t+1] | z[t])
. At each timestep, we observe a value sampled from an
observation model conditioned on the current state, p(x[t] | z[t])
. The
special case where both the transition and observation models are Gaussians
with mean specified as a linear function of the inputs, is known as a linear
Gaussian state space model and supports tractable exact probabilistic
calculations; see tfd_linear_gaussian_state_space_model
for details.
sts_semi_local_linear_trend_state_space_model( num_timesteps, level_scale, slope_mean, slope_scale, autoregressive_coef, initial_state_prior, observation_noise_scale = 0, initial_step = 0, validate_args = FALSE, allow_nan_stats = TRUE, name = NULL )
num_timesteps | Scalar |
---|---|
level_scale | Scalar (any additional dimensions are treated as batch
dimensions) |
slope_mean | Scalar (any additional dimensions are treated as batch
dimensions) |
slope_scale | Scalar (any additional dimensions are treated as batch
dimensions) |
autoregressive_coef | Scalar (any additional dimensions are treated as
batch dimensions) |
initial_state_prior | instance of |
observation_noise_scale | Scalar (any additional dimensions are
treated as batch dimensions) |
initial_step | Optional scalar |
validate_args |
|
allow_nan_stats |
|
name | string` prefixed to ops created by this class. Default value: "SemiLocalLinearTrendStateSpaceModel". |
an instance of LinearGaussianStateSpaceModel
.
The semi-local linear trend model is a special case of a linear Gaussian
SSM, in which the latent state posits a level
and slope
. The level
evolves via a Gaussian random walk centered at the current slope
, while
the slope
follows a first-order autoregressive (AR1) process with
mean slope_mean
:
level[t] = level[t-1] + slope[t-1] + Normal(0, level_scale) slope[t] = (slope_mean + autoregressive_coef * (slope[t-1] - slope_mean) + Normal(0., slope_scale))
The latent state is the two-dimensional tuple [level, slope]
. The
level
is observed at each timestep.
The parameters level_scale
, slope_mean
, slope_scale
,
autoregressive_coef
, and observation_noise_scale
are each (a batch of)
scalars. The batch shape of this Distribution
is the broadcast batch shape
of these parameters and of the initial_state_prior
.
Mathematical Details
The semi-local linear trend model implements a
tfp.distributions.LinearGaussianStateSpaceModel
with latent_size = 2
and observation_size = 1
, following the transition model:
transition_matrix = [[1., 1.] [0., autoregressive_coef]] transition_noise ~ N(loc=slope_mean - autoregressive_coef * slope_mean, scale=diag([level_scale, slope_scale]))
which implements the evolution of [level, slope]
described above, and
the observation model:
observation_matrix = [[1., 0.]] observation_noise ~ N(loc=0, scale=observation_noise_scale)
which picks out the first latent component, i.e., the level
, as the
observation at each timestep.
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()
,
sts_smooth_seasonal_state_space_model()
,
sts_smooth_seasonal()
,
sts_sparse_linear_regression()
,
sts_sum()