如何在 Tensorflow Probability 中实现集成的随机游走趋势组件

How to Implement Integrated Random Walk Trend Component in Tensorflow Probability

我是 运行 tensorflow 2.1 和 tensorflow_probability 0.9。我已拟合具有季节性成分的结构时间序列模型。

我希望根据各州的时间序列分析 Space 方法:第二版,Durbin & Koopman,实施集成随机游走以平滑趋势分量。集成随机游走是通过将水平分量方差设置为0来实现的。

是否可以在 Tensorflow Probability 中实现此约束?

除此之外,Durbin & Koopman 还讨论了高阶随机游动。这能实现吗?

提前感谢您的宝贵时间。

如果我理解正确的话,综合随机游走只是 LocalLinearTrend 的特例,其中水平简单地综合了随机演变的斜率分量(即它没有独立的变化源)。您可以通过子类化 LocalLinearTrend 并在其构建的模型中修复 level_scale = 0. 来修补它:

class IntegratedRandomWalk(sts.LocalLinearTrend):

  def __init__(self,
               slope_scale_prior=None,
               initial_slope_prior=None,
               observed_time_series=None,
               name=None):
    super(IntegratedRandomWalk, self).__init__(
      slope_scale_prior=slope_scale_prior,
      initial_slope_prior=initial_slope_prior,
      observed_time_series=observed_time_series,
      name=None)
    # Remove 'level_scale' parameter from the model.
    del self._parameters[0]

  def _make_state_space_model(self,
                              num_timesteps,
                              param_map,
                              initial_state_prior=None,
                              initial_step=0):

    # Fix `level_scale` to zero, so that the level
    # cannot change except by integrating the
    # slope.
    param_map['level_scale'] = 0.

    return super(IntegratedRandomWalk, self)._make_state_space_model(
      num_timesteps=num_timesteps,
      param_map=param_map,
      initial_state_prior=initial_state_prior,
      initial_step=initial_step)

(这在数学上等同于构建一个 LocalLinearTrendlevel_scale_prior 集中在零,但该约束使推理变得困难,因此通常最好忽略或完全删除该参数,因为我在这里做的)。

高阶随机游走是指自回归模型吗?如果是这样,sts.Autoregressive 可能是相关的。