sts_linear_regression: Formal representation of a linear regression from provided...

View source: R/sts.R

sts_linear_regressionR Documentation

Formal representation of a linear regression from provided covariates.

Description

This model defines a time series given by a linear combination of covariate time series provided in a design matrix:

observed_time_series <- tf$matmul(design_matrix, weights)

Usage

sts_linear_regression(design_matrix, weights_prior = NULL, name = NULL)

Arguments

design_matrix

float tensor of shape tf$concat(list(batch_shape, list(num_timesteps, num_features))). This may also optionally be an instance of tf$linalg$LinearOperator.

weights_prior

Distribution representing a prior over the regression weights. Must have event shape list(num_features) and batch shape broadcastable to the design matrix's batch_shape. Alternately, event_shape may be scalar (list()), in which case the prior is internally broadcast as tfd_transformed_distribution(weights_prior, tfb_identity(), event_shape = list(num_features), batch_shape = design_matrix$batch_shape). If NULL, defaults to tfd_student_t(df = 5, loc = 0, scale = 10), a weakly-informative prior loosely inspired by the Stan prior choice recommendations. Default value: NULL.

name

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

Details

The design matrix has shape list(num_timesteps, num_features). The weights are treated as an unknown random variable of size list(num_features) (both components also support batch shape), and are integrated over using the same approximate inference tools as other model parameters, i.e., generally HMC or variational inference.

This component does not itself include observation noise; it defines a deterministic distribution with mass at the point tf$matmul(design_matrix, weights). In practice, it should be combined with observation noise from another component such as sts_sum, as demonstrated below.

Value

an instance of StructuralTimeSeries.

See Also

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_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_state_space_model(), sts_smooth_seasonal(), sts_sparse_linear_regression(), sts_sum()


tfprobability documentation built on Sept. 1, 2022, 5:07 p.m.