Autoregressive model

本文深入探讨了Autoregressive(AR)模型的概念及其在时间序列预测中的应用。AR模型通过建立当前值与历史值之间的线性关系进行预测,是一种经典的Markov模型。文章详细解释了AR过程的数学公式,包括如何利用白噪声和过程平均值来定义模型的随机性和不确定性。此外,还介绍了如何使用tfp库中的sts.Autoregressive组件在TensorFlow平台上构建AR模型。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在下面build_model的代码中涉及到tfp中的sts.Autoregressive.很长时间不用,恍惚中忘记了何为Autoregressive?通过阅读Autoregressive Model: Definition & The AR Process学习到以下几点:

  • auto不是英文单词,而是表示self的希腊语.这可能也说明这个模型有多么经典.
  • autoregressive model旨在寻找当前时刻的值,与相近历史值的线性关系,因此又叫做markov model.与过去几个值,由order这个参数来指定.
  • autoregressive model本身是一个包含随机信息的过程,可以很好的预测未来趋势,但无法得到准确的point estimation.(The AR process is an example of a stochastic process, which have degrees of uncertainty or randomness built in. The randomness means that you might be able to predict future trends pretty well with past data, but you’re never going to get 100 percent accuracy. Usually, the process gets “close enough” for it to be useful in most scenarios.)

数学公式还是最简洁的表达方式,AR model表示如下:

y t = φ 1 y t − 1 + φ 2 y t − 2 + . . . + φ p y t − p + A t + δ y_t = \varphi_1 y_{t-1} + \varphi_2 y_{t-2} + ... + \varphi_p y_{t-p} + A_t+ \delta yt=φ1yt1+φ2yt2+...+φpytp+At+δ

  • y t − 1 y_{t-1} yt1, y t − 2 y_{t-2} yt2, …, y t − p y_{t-p} ytp are the past series values.
  • A t A_t At is white noise (i.e. randomness)
  • δ \delta δ is defined by the following equation:

δ = ( 1 − ∑ i = 1 p ϕ i ) μ \delta = (1 - \sum_{i=1}^p \phi_i) \mu δ=(1i=1pϕi)μ
where μ \mu μ is the process mean.

为在markdown中写出上述公式,参照了LaTeX Math Symbols and Motivating Examples.

def build_model(observed_time_series):
  hour_of_day_effect = sts.Seasonal(
      num_seasons=24,
      observed_time_series=observed_time_series,
      name='hour_of_day_effect')
  day_of_week_effect = sts.Seasonal(
      num_seasons=7, num_steps_per_season=24,
      observed_time_series=observed_time_series,
      name='day_of_week_effect')
  temperature_effect = sts.LinearRegression(
      design_matrix=tf.reshape(temperature - np.mean(temperature),
                               (-1, 1)), name='temperature_effect')
  autoregressive = sts.Autoregressive(
      order=1, # scalar Python positive int specifying the number of past timesteps to regress on.
      observed_time_series=observed_time_series,
      name='autoregressive')
  model = sts.Sum([hour_of_day_effect,
                   day_of_week_effect,
                   temperature_effect,
                   autoregressive],
                   observed_time_series=observed_time_series)
  return model

代码来自Structural Time Series Modeling Case Studies: Atmospheric CO2 and Electricity Demand

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值