时间序列模型使用流程_时间序列模型-程序员宅基地

技术标签: 算法  python  java  机器学习  人工智能  

时间序列模型使用流程

AR, MA, ARMA, and ARIMA models are used to forecast the observation at (t+1) based on the historical data of previous time spots recorded for the same observation. However, it is necessary to make sure that the time series is stationary over the historical data of observation overtime period. If the time series is not stationary then we could apply the differencing factor on the records and see if the graph of the time series is a stationary overtime period.

AR,MA,ARMA和ARIMA模型用于基于为同一观测记录的先前时间点的历史数据来预测(t + 1)处的观测。 但是,有必要确保时间序列在观察超时时段的历史数据上保持平稳。 如果时间序列不是平稳的,那么我们可以在记录上应用差异因子,然后查看时间序列的图是否是平稳的加班周期。

ACF(自动相关功能) (ACF (Auto Correlation Function))

Auto Correlation function takes into consideration of all the past observations irrespective of its effect on the future or present time period. It calculates the correlation between the t and (t-k) time period. It includes all the lags or intervals between t and (t-k) time periods. Correlation is always calculated using the Pearson Correlation formula.

自相关功能会考虑所有过去的观察结果,无论其对未来或当前时间段的影响如何。 它计算t和(tk)时间段之间的相关性。 它包括t和(tk)时间段之间的所有延迟或间隔。 始终使用Pearson Correlation公式计算相关性。

PACF(部分相关函数) (PACF(Partial Correlation Function))

The PACF determines the partial correlation between time period t and t-k. It doesn’t take into consideration all the time lags between t and t-k. For e.g. let's assume that today's stock price may be dependent on 3 days prior stock price but it might not take into consideration yesterday's stock price closure. Hence we consider only the time lags having a direct impact on future time period by neglecting the insignificant time lags in between the two-time slots t and t-k.

PACF确定时间段t和tk之间的偏相关。 它没有考虑到t和tk之间的所有时滞。 例如,假设今天的股价可能取决于之前三天的股价,但可能没有考虑到昨天的股价收盘。 因此,通过忽略两个时隙t和tk之间的无关紧要的时滞,我们认为仅时滞对未来时间段有直接影响。

如何区分何时使用ACF和PACF? (How to differentiate when to use ACF and PACF?)

Let's take an example of sweets sale and income generated in a village over a year. Under the assumption that every 2 months there is a festival in the village, we take out the historical data of sweets sale and income generated for 12 months. If we plot the time as month then we can observe that when it comes to calculating the sweets sale we are interested in only alternate months as the sale of sweets increases every two months. But if we are to consider the income generated next month then we have to take into consideration all the 12 months of last year.

让我们以一个村庄一年来的糖果销售和收入为例。 假设村里每2个月有一个节日,我们就拿出12个月的糖果销售和收入历史数据。 如果我们将时间绘制成月,那么我们可以观察到,在计算糖果销售时,我们仅对交替的月份感兴趣,因为糖果的销售每两个月增加一次。 但是,如果我们要考虑下个月产生的收入,那么我们就必须考虑去年的所有12个月。

So in the above situation, we will use ACF to find out the income generated in the future but we will be using PACF to find out the sweets sold in the next month.

因此,在上述情况下,我们将使用ACF来查找将来产生的收入,但是我们将使用PACF来查找下个月出售的糖果。

AR(自回归)模型 (AR (Auto-Regressive) Model)

Image for post
Image by Author
图片作者

The time period at t is impacted by the observation at various slots t-1, t-2, t-3, ….., t-k. The impact of previous time spots is decided by the coefficient factor at that particular period of time. The price of a share of any particular company X may depend on all the previous share prices in the time series. This kind of model calculates the regression of past time series and calculates the present or future values in the series in know as Auto Regression (AR) model.

t的时间段受在t-1,t-2,t-3,…..tk不同时隙的观察影响。 先前时间点的影响由该特定时间段的系数决定。 任何特定公司X的股票价格可能取决于时间序列中所有先前的股票价格。 这种模型计算过去时间序列的回归,并以已知的自动回归(AR)模型计算序列中的当前值或将来值。

Yt = β₁* y-₁ + β₂* yₜ-₂ + β₃ * yₜ-₃ + ………… + βₖ * yₜ-ₖ

Yt =β₁*y-₁+β2 *yₜ-_2+β₃*yₜ-₃+…………+βₖ*yₜ-ₖ

Consider an example of a milk distribution company that produces milk every month in the country. We want to calculate the amount of milk to be produced current month considering the milk generated in the last year. We begin by calculating the PACF values of all the 12 lags with respect to the current month. If the value of the PACF of any particular month is more than a significant value only those values will be considered for the model analysis.

考虑一个牛奶分销公司的例子,该公司每月在该国生产牛奶。 考虑到去年产生的牛奶,我们要计算当月的牛奶产量。 我们首先计算相对于当月的所有12个滞后的PACF值。 如果任何特定月份的PACF值大于显着值,则仅将这些值考虑用于模型分析。

For e.g in the above figure the values 1,2, 3 up to 12 displays the direct effect(PACF) of the milk production in the current month w.r.t the given the lag t. If we consider two significant values above the threshold then the model will be termed as AR(2).

例如,在上图中,值1,2、3到12表示给定滞后t时当月的牛奶产量的直接影响(PACF)。 如果我们认为高于阈值的两个有效值,则该模型将被称为AR(2)。

MA(移动平均值)模型 (MA (Moving Average) Model)

Image for post
Image by Author
图片作者

The time period at t is impacted by the unexpected external factors at various slots t-1, t-2, t-3, ….., t-k. These unexpected impacts are known as Errors or Residuals. The impact of previous time spots is decided by the coefficient factor α at that particular period of time. The price of a share of any particular company X may depend on some company merger that happened overnight or maybe the company resulted in shutdown due to bankruptcy. This kind of model calculates the residuals or errors of past time series and calculates the present or future values in the series in know as Moving Average (MA) model.

t的时间段受各种时隙t-1,t-2,t-3,…..tk中意外的外部因素的影响。 这些意外的影响称为“错误或残差”。 先前时间点的影响由该特定时间段的系数因子α决定。 任何特定公司X的股票价格可能取决于在一夜之间发生的某些公司合并,或者该公司可能因破产而倒闭。 这种模型可以计算过去时间序列的残差或误差,并以已知的移动平均(MA)模型来计算序列中的当前值或将来值。

Yt = α₁* Ɛₜ-₁ + α₂ * Ɛₜ-₂ + α₃ * Ɛₜ-₃ + ………… + αₖ * Ɛₜ-ₖ

Yt =α₁*Ɛₜ-₁+α2*Ɛₜ-²+α₃*Ɛₜ-₃+…………+αₖ*Ɛₜ-ₖ

Consider an example of Cake distribution during my birthday. Let's assume that your mom asks you to bring pastries to the party. Every year you miss judging the no of invites to the party and end upbringing more or less no of cakes as per requirement. The difference in the actual and expected results in the error. So you want to avoid the error for this year hence we apply the moving average model on the time series and calculate the no of pastries needed this year based on past collective errors. Next, calculate the ACF values of all the lags in the time series. If the value of the ACF of any particular month is more than a significant value only those values will be considered for the model analysis.

考虑一下我生日那天分发蛋糕的例子。 假设您的妈妈要您带糕点参加聚会。 每年您都会错过判断参加聚会的邀请数并最终按照要求养成或多或少的蛋糕的机会。 实际和预期的差异会导致错误。 因此,您要避免今年的误差,因此我们将移动平均模型应用于时间序列,并根据过去的集体误差计算今年所需的糕点数量。 接下来,计算时间序列中所有滞后的ACF值。 如果任何特定月份的ACF值大于显着值,则仅将这些值考虑用于模型分析。

For e.g in the above figure the values 1,2, 3 up to 12 displays the total error(ACF) of count in pastries current month w.r.t the given the lag t by considering all the in-between lags between time t and current month. If we consider two significant values above the threshold then the model will be termed as MA(2).

例如,在上图中,值1,2、3(最多12)显示了糕点在当月的总误差(ACF),其中给定的滞后t是考虑了时间t和当月之间的所有中间滞后。 如果我们认为高于阈值的两个有效值,则该模型将称为MA(2)。

ARMA(自动回归移动平均线)模型 (ARMA (Auto Regressive Moving Average) Model)

Image for post
Image by Author
图片作者

This is a model that is combined from the AR and MA models. In this model, the impact of previous lags along with the residuals is considered for forecasting the future values of the time series. Here β represents the coefficients of the AR model and α represents the coefficients of the MA model.

此模型是AR和MA模型的组合。 在此模型中,考虑了先前滞后的影响以及残差,以预测时间序列的未来值。 这里,β代表AR模型的系数,α代表MA模型的系数。

Yt = β₁* yₜ-₁ + α₁* Ɛₜ-₁ + β₂* yₜ-₂ + α₂ * Ɛₜ-₂ + β₃ * yₜ-₃ + α₃ * Ɛₜ-₃ +………… + βₖ * yₜ-ₖ + αₖ * Ɛₜ-ₖ

Yt =β₁*yₜ-₁+α₁*Ɛₜ-₁+β2 *yₜ-²+α2 *Ɛₜ-_2+β₃*yₜ-₃+α₃*Ɛₜ-₃+…………+βₖ*yₜ-ₖ+αₖ *Ɛₜ-ₖ

Consider the above graphs where the MA and AR values are plotted with their respective significant values. Let's assume that we consider only 1 significant value from the AR model and likewise 1 significant value from the MA model. So the ARMA model will be obtained from the combined values of the other two models will be of the order of ARMA(1,1).

考虑上面的图,其中MA和AR值分别以其有效值绘制。 假设我们只考虑AR模型的1个有效值,同样考虑MA模型的1个有效值。 因此,将从其他两个模型的组合值获得ARMA模型,其数量级将为ARMA(1,1)。

ARIMA(自回归综合移动平均线)模型 (ARIMA (Auto-Regressive Integrated Moving Average) Model)

Image for post
Image by Author
图片作者

We know that in order to apply the various models we must in the beginning convert the series into Stationary Time Series. In order to achieve the same, we apply the differencing or Integrated method where we subtract the t-1 value from t values of time series. After applying the first differencing if we are still unable to get the Stationary time series then we again apply the second-order differencing.

我们知道,为了应用各种模型,我们必须在开始时将序列转换为平稳时间序列。 为了达到相同的目的,我们应用了微分或积分方法,其中从时间序列的t值中减去t-1值。 在应用一次微分之后,如果我们仍然无法获得固定时间序列,那么我们将再次应用二次微分。

The ARIMA model is quite similar to the ARMA model other than the fact that it includes one more factor known as Integrated( I ) i.e. differencing which stands for I in the ARIMA model. So in short ARIMA model is a combination of a number of differences already applied on the model in order to make it stationary, the number of previous lags along with residuals errors in order to forecast future values.

ARIMA模型与ARMA模型非常相似,只不过它包含一个称为集成(I)的因子,即在ARIMA模型中代表I的差分。 因此,简而言之,ARIMA模型是为了使模型变得平稳而已应用到模型上的多个差异的组合,其中先前的滞后次数与残差误差一起用于预测未来值。

Consider the above graphs where the MA and AR values are plotted with their respective significant values. Let's assume that we consider only 1 significant value from the AR model and likewise 1 significant value from the MA model. Also, the graph was initially non-stationary and we had to perform differencing operation once in order to convert into a stationary set. Hence the ARIMA model which will be obtained from the combined values of the other two models along with the Integral operator can be displayed as ARIMA(1,1,1).

考虑上面的图,其中MA和AR值分别以其有效值绘制。 假设我们只考虑AR模型的1个有效值,同样考虑MA模型的1个有效值。 而且,该图最初是非平稳的,我们必须执行一次微分运算才能转换为平稳集。 因此,将从其他两个模型的组合值与积分算子一起获得的ARIMA模型可以显示为ARIMA(1,1,1)。

结论: (Conclusion :)

All these models give us an insight or at least close enough prediction about any particular time series. Also, it depends on the users that which model perfectly suffices their needs. If the chances of error rate are less in any one model compared to other models then it's preferred that we choose the one which gives us the closest estimation.

所有这些模型为我们提供了关于任何特定时间序列的见识或至少足够接近的预测。 同样,取决于用户的是哪种型号完全可以满足他们的需求。 如果在任何一个模型中错误率的机会都比其他模型少,那么我们最好选择一个给出最接近估计值的模型。

Hope this article helps you to understand things better !!

希望本文能帮助您更好地理解!!

翻译自: https://towardsdatascience.com/time-series-models-d9266f8ac7b0

时间序列模型使用流程

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_26729763/article/details/109122891

智能推荐

while循环&CPU占用率高问题深入分析与解决方案_main函数使用while(1)循环cpu占用99-程序员宅基地

文章浏览阅读3.8k次,点赞9次,收藏28次。直接上一个工作中碰到的问题,另外一个系统开启多线程调用我这边的接口,然后我这边会开启多线程批量查询第三方接口并且返回给调用方。使用的是两三年前别人遗留下来的方法,放到线上后发现确实是可以正常取到结果,但是一旦调用,CPU占用就直接100%(部署环境是win server服务器)。因此查看了下相关的老代码并使用JProfiler查看发现是在某个while循环的时候有问题。具体项目代码就不贴了,类似于下面这段代码。​​​​​​while(flag) {//your code;}这里的flag._main函数使用while(1)循环cpu占用99

【无标题】jetbrains idea shift f6不生效_idea shift +f6快捷键不生效-程序员宅基地

文章浏览阅读347次。idea shift f6 快捷键无效_idea shift +f6快捷键不生效

node.js学习笔记之Node中的核心模块_node模块中有很多核心模块,以下不属于核心模块,使用时需下载的是-程序员宅基地

文章浏览阅读135次。Ecmacript 中没有DOM 和 BOM核心模块Node为JavaScript提供了很多服务器级别,这些API绝大多数都被包装到了一个具名和核心模块中了,例如文件操作的 fs 核心模块 ,http服务构建的http 模块 path 路径操作模块 os 操作系统信息模块// 用来获取机器信息的var os = require('os')// 用来操作路径的var path = require('path')// 获取当前机器的 CPU 信息console.log(os.cpus._node模块中有很多核心模块,以下不属于核心模块,使用时需下载的是

数学建模【SPSS 下载-安装、方差分析与回归分析的SPSS实现(软件概述、方差分析、回归分析)】_化工数学模型数据回归软件-程序员宅基地

文章浏览阅读10w+次,点赞435次,收藏3.4k次。SPSS 22 下载安装过程7.6 方差分析与回归分析的SPSS实现7.6.1 SPSS软件概述1 SPSS版本与安装2 SPSS界面3 SPSS特点4 SPSS数据7.6.2 SPSS与方差分析1 单因素方差分析2 双因素方差分析7.6.3 SPSS与回归分析SPSS回归分析过程牙膏价格问题的回归分析_化工数学模型数据回归软件

利用hutool实现邮件发送功能_hutool发送邮件-程序员宅基地

文章浏览阅读7.5k次。如何利用hutool工具包实现邮件发送功能呢?1、首先引入hutool依赖<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.7.19</version></dependency>2、编写邮件发送工具类package com.pc.c..._hutool发送邮件

docker安装elasticsearch,elasticsearch-head,kibana,ik分词器_docker安装kibana连接elasticsearch并且elasticsearch有密码-程序员宅基地

文章浏览阅读867次,点赞2次,收藏2次。docker安装elasticsearch,elasticsearch-head,kibana,ik分词器安装方式基本有两种,一种是pull的方式,一种是Dockerfile的方式,由于pull的方式pull下来后还需配置许多东西且不便于复用,个人比较喜欢使用Dockerfile的方式所有docker支持的镜像基本都在https://hub.docker.com/docker的官网上能找到合..._docker安装kibana连接elasticsearch并且elasticsearch有密码

随便推点

Python 攻克移动开发失败!_beeware-程序员宅基地

文章浏览阅读1.3w次,点赞57次,收藏92次。整理 | 郑丽媛出品 | CSDN(ID:CSDNnews)近年来,随着机器学习的兴起,有一门编程语言逐渐变得火热——Python。得益于其针对机器学习提供了大量开源框架和第三方模块,内置..._beeware

Swift4.0_Timer 的基本使用_swift timer 暂停-程序员宅基地

文章浏览阅读7.9k次。//// ViewController.swift// Day_10_Timer//// Created by dongqiangfei on 2018/10/15.// Copyright 2018年 飞飞. All rights reserved.//import UIKitclass ViewController: UIViewController { ..._swift timer 暂停

元素三大等待-程序员宅基地

文章浏览阅读986次,点赞2次,收藏2次。1.硬性等待让当前线程暂停执行,应用场景:代码执行速度太快了,但是UI元素没有立马加载出来,造成两者不同步,这时候就可以让代码等待一下,再去执行找元素的动作线程休眠,强制等待 Thread.sleep(long mills)package com.example.demo;import org.junit.jupiter.api.Test;import org.openqa.selenium.By;import org.openqa.selenium.firefox.Firefox.._元素三大等待

Java软件工程师职位分析_java岗位分析-程序员宅基地

文章浏览阅读3k次,点赞4次,收藏14次。Java软件工程师职位分析_java岗位分析

Java:Unreachable code的解决方法_java unreachable code-程序员宅基地

文章浏览阅读2k次。Java:Unreachable code的解决方法_java unreachable code

标签data-*自定义属性值和根据data属性值查找对应标签_如何根据data-*属性获取对应的标签对象-程序员宅基地

文章浏览阅读1w次。1、html中设置标签data-*的值 标题 11111 222222、点击获取当前标签的data-url的值$('dd').on('click', function() { var urlVal = $(this).data('ur_如何根据data-*属性获取对应的标签对象

推荐文章

热门文章

相关标签