python 二次平滑_时序分析 指数平滑

11fac7dbe6d97eb0e0ec3f56b6b863dd.png

该帖主要介绍了一次指数平滑法、二次指数平滑法以及三次指数平滑法。

1 简介

指数平滑法是对单变量数据进行时间序列预测的一种方法,它可以推广到具有系统趋势或季节成分的数据。

建模类似Box-Jenkins ARIMA的建模方式,但其预测是最近的过去观测或滞后的加权线性和。

指数平滑预测法与用过去观测值的加权和进行预测相似,但是模型的过去观测值的权重是指数递减的。

具体地说,过去的观测结果是按几何递减比例加权的:

Forecasts produced using exponential smoothing methods are weighted averages of past observations, with the weights decaying exponentially as the observations get older. In other words, the more recent the observation the higher the associated weight. — Page 171, Forecasting: principles and practice, 2013.

指数平滑和ARIMA有时被统称为ETS模型,指的是对误差、趋势和季节性的建模。

指数平滑预测法主要有三种:

  • 没有系统结构的简单指数平滑,又叫一次指数平滑,这里结构是指趋势和季节
  • 有明确趋势的叫二次指数平滑
  • 有趋势和季节性的叫三次指数平滑

2 一次指数平滑

一次指数平滑(single exponential smoothing, SES),是一种对没有趋势或季节性的单变量时间序列的预测方法。

它需要一个参数,称为 ,也称为平滑因子或平滑系数。

这个参数控制前面历史观测值的权重指数递减速度。常被设置为0到1之间的值。大的值意味着模型更关注最近的观测值,小的值意味着预测时更关注历史观测值。

A value close to 1 indicates fast learning (that is, only the most recent values influence the forecasts), whereas a value close to 0 indicates slow learning (past observations have a large influence on forecasts).

超参:

Alpha:smoothing factor for the level.

python实现

from statsmodels.tsa.holtwinters import SimpleExpSmoothing
# prepare data
data = ...
# create class
model = SimpleExpSmoothing(data)
# fit model
model_fit = model.fit(...)
# make prediction
yhat = model_fit.predict(...)

3 二次指数平滑

双指数平滑( double exponential smoothing)是指数平滑的扩展,它增加了对单变量时间序列趋势的支持。

参数除了用于控制水平的平滑因子 alpha,还增加了用于控制趋势变化影响的衰减平滑因子 beta 。

该方法支持不同变化方式的趋势:加法和乘法,取决于趋势是线性还是指数的。

  • 加性趋势(additive trend):具有线性趋势的双指数平滑

  • 乘性趋势(multiplicative trend):具有指数趋势的双指数平滑

二次指数平滑通常称为 Holt 线性趋势模型,以开发者 Charles Holt 命名。

对于较大时间步长的预测,趋势可能会不符合实际。因此,随着时间的推移,可能需要抑制这种趋势。

抑制(dampening)意味着随着未来时间的推移将减少趋势的大小直至成为一条直线(没有趋势)。

与趋势建模一样,可用相同原则来抑制趋势,尤其是线性的加性和指数的乘性的抑制效果。抑制系数 Phi 用于控制抑制的速度。

  • 加性抑制(additive dampening):抑制线性趋势

  • 乘性抑制(multiplicative dampening):抑制指数趋势

超参:

Alpha:smoothing factor for the level.

Beta: Smoothing factor for the trend.

Trend Type: Additive or multiplicative.

Dampen Type: Additive or multiplicative.

Phi: Damping coefficient.

python实现

from statsmodels.tsa.holtwinters import ExponentialSmoothing
# prepare data
data = ...
# create class
model = ExponentialSmoothing(data, ...)
# fit model
model_fit = model.fit(...)
# make prediction
yhat = model_fit.predict(...)

4 三次指数平滑

三次指数平滑是指数平滑的扩展,它为单变量时间序列增加了对季节性的支持。

这种方法有时被称为 Holt-Winters 指数平滑法,以该方法的两位贡献者 Charles Holt and Peter Winters 的名字命名。

除了alpha和beta平滑因子外,还添加了一个新的参数 gamma,该参数控制对季节成分的影响。

与趋势一样,季节性也有加性(线性)或乘性(指数)过程。

  • 加法季节性(additive seasonality):具有线性季节性的三次指数平滑。

  • 乘法季节性(multiplicative seasonality):具有指数季节性的三次指数平滑。

三次指数平滑是指数平滑最先进的变体,通过参数配置,还可以建立双指数平滑模型和单指数平滑模型。

Being an adaptive method, Holt-Winter’s exponential smoothing allows the level, trend and seasonality patterns to change over time.

为了确保正确地对季节性建模,必须指定季节性的时间步长。若该时序是月度数据,而季节周期每年重复,那么周期=12。

超参:

Alpha:smoothing factor for the level.

Beta: Smoothing factor for the trend.

Trend Type: Additive or multiplicative.

Dampen Type: Additive or multiplicative.

Phi: Damping coefficient.

Seasonality Type: Additive or multiplicative.

Period: Time steps in seasonal period.

python实现

同二次指数平滑

5 参数选取

以上所有超参都可手动设置,这种方法适合专家或初学者。

正常会用数值优化的方法通过最小误差来找平滑参数。

a more robust and objective way to obtain values for the unknown parameters included in any exponential smoothing method is to estimate them from the observed data. the unknown parameters and the initial values for any exponential smoothing method can be estimated by minimizing the SSE [sum of the squared errors].

python 二次平滑_时序分析 指数平滑_第1张图片

你可能感兴趣的:(python,二次平滑)