class_docstr: Formal representation of a dynamic linear regresson model.
  
  The dynamic linear regression model is a special case of a linear Gaussian SSM
  and a generalization of typical (static) linear regression. The model
  represents regression `weights` with a latent state which evolves via a
  Gaussian random walk:
  
  ```
  weights[t] ~ Normal(weights[t-1], drift_scale)
  ```
  
  The latent state has dimension `num_features`, while 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, the `initial_state_prior`, and the `design_matrix`. `num_features`
  is determined from the last dimension of `design_matrix` (equivalent to the
  number of columns in the design matrix in linear regression).
class_docstr_tok: ["Formal","representation","of","a","dynamic","linear","regresson","model",".","The","dynamic","linear","regression","model","is","a","special","case","of","a","linear","Gaussian","SSM","and","a","generalization","of","typical","(","static",")","linear","regression",".","The","model","represents","regression","`","weights","`","with","a","latent","state","which","evolves","via","a","Gaussian","random","walk",":","``","`","weights","[","t","]","~","Normal","(","weights","[","t-1","]",",","drift_scale",")","``","`","The","latent","state","has","dimension","`","num_features","`",",","while","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",",","the","`","initial_state_prior","`",",","and","the","`","design_matrix","`",".","`","num_features","`","is","determined","from","the","last","dimension","of","`","design_matrix","`","(","equivalent","to","the","number","of","columns","in","the","design","matrix","in","linear","regression",")","."]
docstr: Specify a dynamic linear regression.
  
  Args:
    design_matrix: float `Tensor` of shape `concat([batch_shape,
      [num_timesteps, num_features]])`.
    drift_scale_prior: instance of `tfd.Distribution` specifying a prior on
      the `drift_scale` parameter. If `None`, a heuristic default prior is
      constructed based on the provided `observed_time_series`.
      Default value: `None`.
    initial_weights_prior: instance of `tfd.MultivariateNormal` representing
      the prior distribution on the latent states (the regression weights).
      Must have event shape `[num_features]`. If `None`, a weakly-informative
      Normal(0., 10.) prior is used.
      Default value: `None`.
    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 `NaN`s
      are interpreted as missing observations; missingness may be also be
      explicitly specified by passing a `tfp.sts.MaskedTimeSeries` instance.
      Any priors not explicitly set will be given default values according to
      the scale of the observed time series (or batch of time series).
      Default value: `None`.
    name: Python `str` for the name of this component.
      Default value: 'DynamicLinearRegression'.
docstr_tok: ["Specify","a","dynamic","linear","regression",".","Args",":","design_matrix",":","float","`","Tensor","`","of","shape","`","concat","(","[","batch_shape",",","[","num_timesteps",",","num_features","]","]",")","`",".","drift_scale_prior",":","instance","of","`","tfd.Distribution","`","specifying","a","prior","on","the","`","drift_scale","`","parameter",".","If","`","None","`",",","a","heuristic","default","prior","is","constructed","based","on","the","provided","`","observed_time_series","`",".","Default","value",":","`","None","`",".","initial_weights_prior",":","instance","of","`","tfd.MultivariateNormal","`","representing","the","prior","distribution","on","the","latent","states","(","the","regression","weights",")",".","Must","have","event","shape","`","[","num_features","]","`",".","If","`","None","`",",","a","weakly-informative","Normal","(","0.",",","10",".",")","prior","is","used",".","Default","value",":","`","None","`",".","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","`","NaN","`","s","are","interpreted","as","missing","observations",";","missingness","may","be","also","be","explicitly","specified","by","passing","a","`","tfp.sts.MaskedTimeSeries","`","instance",".","Any","priors","not","explicitly","set","will","be","given","default","values","according","to","the","scale","of","the","observed","time","series","(","or","batch","of","time","series",")",".","Default","value",":","`","None","`",".","name",":","Python","`","str","`","for","the","name","of","this","component",".","Default","value",":","'DynamicLinearRegression","'","."]
code: def __init__(
      self,
      design_matrix,
      drift_scale_prior=None,
      initial_weights_prior=None,
      observed_time_series=None,
      name=None,
  ):
      """Specify a dynamic linear regression.
  
      Args:
        design_matrix: float `Tensor` of shape `concat([batch_shape,
          [num_timesteps, num_features]])`.
        drift_scale_prior: instance of `tfd.Distribution` specifying a prior on
          the `drift_scale` parameter. If `None`, a heuristic default prior is
          constructed based on the provided `observed_time_series`.
          Default value: `None`.
        initial_weights_prior: instance of `tfd.MultivariateNormal` representing
          the prior distribution on the latent states (the regression weights).
          Must have event shape `[num_features]`. If `None`, a weakly-informative
          Normal(0., 10.) prior is used.
          Default value: `None`.
        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 `NaN`s
          are interpreted as missing observations; missingness may be also be
          explicitly specified by passing a `tfp.sts.MaskedTimeSeries` instance.
          Any priors not explicitly set will be given default values according to
          the scale of the observed time series (or batch of time series).
          Default value: `None`.
        name: Python `str` for the name of this component.
          Default value: 'DynamicLinearRegression'.
  
      """
      init_parameters = dict(locals())
      with tf.name_scope(name or "DynamicLinearRegression") as name:
          dtype = dtype_util.common_dtype(
              [design_matrix, drift_scale_prior, initial_weights_prior]
          )
  
          num_features = prefer_static.shape(design_matrix)[-1]
  
          # Default to a weakly-informative Normal(0., 10.) for the initital state
          if initial_weights_prior is None:
              initial_weights_prior = mvn_diag.MultivariateNormalDiag(
                  scale_diag=10.0 * tf.ones([num_features], dtype=dtype)
              )
  
          # Heuristic default priors. Overriding these may dramatically
          # change inference performance and results.
          if observed_time_series is None:
              observed_stddev = tf.constant(1.0, dtype=dtype)
          else:
              _, observed_stddev, _ = sts_util.empirical_statistics(
                  observed_time_series
              )
          if drift_scale_prior is None:
              drift_scale_prior = lognormal.LogNormal(
                  loc=tf.math.log(0.05 * observed_stddev),
                  scale=3.0,
                  name="drift_scale_prior",
              )
  
          self._initial_state_prior = initial_weights_prior
          self._design_matrix = design_matrix
  
          super(DynamicLinearRegression, self).__init__(
              parameters=[
                  Parameter(
                      "drift_scale",
                      drift_scale_prior,
                      chain.Chain(
                          [
                              scale.Scale(scale=observed_stddev),
                              softplus.Softplus(
                                  low=dtype_util.eps(dtype)
                              ),
                          ]
                      ),
                  )
              ],
              latent_size=num_features,
              init_parameters=init_parameters,
              name=name,
          )
  
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import chain
  from tensorflow_probability.python.bijectors import scale
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.distributions import linear_gaussian_ssm
  from tensorflow_probability.python.distributions import lognormal
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.sts.internal import util
  from tensorflow_probability.python.sts.structural_time_series import Parameter
  from tensorflow_probability.python.sts.structural_time_series import StructuralTimeSeries
label_desc: Use image node_id 1 to create a new DynamicLinearRegression object from inherited base classes: StructuralTimeSeries with example: obj = DynamicLinearRegression(design_matrix, drift_scale_prior, initial_weights_prior, observed_time_series, name)