R/sts.R
sts_smooth_seasonal_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 tfp$distributions$LinearGaussianStateSpaceModel
for
details.
A smooth seasonal effect model is a special case of a linear Gaussian SSM. It
is the sum of a set of "cyclic" components, with one component for each
frequency:
frequencies[j] = 2. * pi * frequency_multipliers[j] / period
Each cyclic component contains two latent states which we denote effect
and
auxiliary
. The two latent states for component j
drift over time via:
effect[t] = (effect[t1] * cos(frequencies[j]) + auxiliary[t] * sin(frequencies[j]) + Normal(0., drift_scale)) auxiliary[t] = (effect[t1] * sin(frequencies[j]) + auxiliary[t] * cos(frequencies[j]) + Normal(0., drift_scale))
sts_smooth_seasonal_state_space_model( num_timesteps, period, frequency_multipliers, drift_scale, initial_state_prior, observation_noise_scale = 0, initial_step = 0, validate_args = FALSE, allow_nan_stats = TRUE, name = NULL )
num_timesteps  Scalar 

period  positive scalar 
frequency_multipliers  Onedimensional 
drift_scale  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  scalar 
validate_args 

allow_nan_stats 

name  string prefixed to ops created by this class. Default value: "LocalLinearTrendStateSpaceModel". 
an instance of LinearGaussianStateSpaceModel
.
The auxiliary
latent state only appears as a matter of construction and thus
its interpretation is not particularly important. The total smooth seasonal
effect is the sum of the effect
values from each of the cyclic components.
The parameters drift_scale
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 smooth seasonal effect model implements a
tfp$distributions$LinearGaussianStateSpaceModel
with
latent_size = 2 * len(frequency_multipliers)
and observation_size = 1
.
The latent state is the concatenation of the cyclic latent states which themselves
comprise an effect
and an auxiliary
state. The transition matrix is a block diagonal
matrix where block j
is:
transition_matrix[j] = [[cos(frequencies[j]), sin(frequencies[j])], [sin(frequencies[j]), cos(frequencies[j])]]
The observation model picks out the cyclic effect
values from the latent state:
observation_matrix = [[1., 0., 1., 0., ..., 1., 0.]] observation_noise ~ Normal(loc=0, scale=observation_noise_scale)
For further mathematical details please see Harvey (1990).
Harvey, A. Forecasting, Structural Time Series Models and the Kalman Filter. Cambridge: Cambridge University Press, 1990.
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_semi_local_linear_trend()
,
sts_smooth_seasonal()
,
sts_sparse_linear_regression()
,
sts_sum()