R/stsfunctions.R
sts_decompose_by_component.Rd
This method decomposes a time series according to the posterior represention of a structural time series model. In particular, it:
Computes the posterior marginal mean and covariances over the additive model's latent space.
Decomposes the latent posterior into the marginal blocks for each model component.
Maps the percomponent latent posteriors back through each component's observation model, to generate the time series modeled by that component.
sts_decompose_by_component(observed_time_series, model, parameter_samples)
observed_time_series 


model  An instance of 
parameter_samples 

component_dists A named list mapping
component StructuralTimeSeries instances (elements of model$components
)
to Distribution
instances representing the posterior marginal
distributions on the process modeled by each component. Each distribution
has batch shape matching that of posterior_means
/posterior_covs
, and
event shape of list(num_timesteps)
.
Other stsfunctions:
sts_build_factored_surrogate_posterior()
,
sts_build_factored_variational_loss()
,
sts_decompose_forecast_by_component()
,
sts_fit_with_hmc()
,
sts_forecast()
,
sts_one_step_predictive()
,
sts_sample_uniform_initial_state()
# \donttest{ observed_time_series < array(rnorm(2 * 1 * 12), dim = c(2, 1, 12)) day_of_week < observed_time_series %>% sts_seasonal(num_seasons = 7, name = "seasonal") local_linear_trend < observed_time_series %>% sts_local_linear_trend(name = "local_linear") model < observed_time_series %>% sts_sum(components = list(day_of_week, local_linear_trend)) states_and_results < observed_time_series %>% sts_fit_with_hmc( model, num_results = 10, num_warmup_steps = 5, num_variational_steps = 15 ) samples < states_and_results[[1]] component_dists < observed_time_series %>% sts_decompose_by_component(model = model, parameter_samples = samples) # }