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

技术标签: 算法  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

智能推荐

使用nginx解决浏览器跨域问题_nginx不停的xhr-程序员宅基地

文章浏览阅读1k次。通过使用ajax方法跨域请求是浏览器所不允许的,浏览器出于安全考虑是禁止的。警告信息如下:不过jQuery对跨域问题也有解决方案,使用jsonp的方式解决,方法如下:$.ajax({ async:false, url: 'http://www.mysite.com/demo.do', // 跨域URL ty..._nginx不停的xhr

在 Oracle 中配置 extproc 以访问 ST_Geometry-程序员宅基地

文章浏览阅读2k次。关于在 Oracle 中配置 extproc 以访问 ST_Geometry,也就是我们所说的 使用空间SQL 的方法,官方文档链接如下。http://desktop.arcgis.com/zh-cn/arcmap/latest/manage-data/gdbs-in-oracle/configure-oracle-extproc.htm其实简单总结一下,主要就分为以下几个步骤。..._extproc

Linux C++ gbk转为utf-8_linux c++ gbk->utf8-程序员宅基地

文章浏览阅读1.5w次。linux下没有上面的两个函数,需要使用函数 mbstowcs和wcstombsmbstowcs将多字节编码转换为宽字节编码wcstombs将宽字节编码转换为多字节编码这两个函数,转换过程中受到系统编码类型的影响,需要通过设置来设定转换前和转换后的编码类型。通过函数setlocale进行系统编码的设置。linux下输入命名locale -a查看系统支持的编码_linux c++ gbk->utf8

IMP-00009: 导出文件异常结束-程序员宅基地

文章浏览阅读750次。今天准备从生产库向测试库进行数据导入,结果在imp导入的时候遇到“ IMP-00009:导出文件异常结束” 错误,google一下,发现可能有如下原因导致imp的数据太大,没有写buffer和commit两个数据库字符集不同从低版本exp的dmp文件,向高版本imp导出的dmp文件出错传输dmp文件时,文件损坏解决办法:imp时指定..._imp-00009导出文件异常结束

python程序员需要深入掌握的技能_Python用数据说明程序员需要掌握的技能-程序员宅基地

文章浏览阅读143次。当下是一个大数据的时代,各个行业都离不开数据的支持。因此,网络爬虫就应运而生。网络爬虫当下最为火热的是Python,Python开发爬虫相对简单,而且功能库相当完善,力压众多开发语言。本次教程我们爬取前程无忧的招聘信息来分析Python程序员需要掌握那些编程技术。首先在谷歌浏览器打开前程无忧的首页,按F12打开浏览器的开发者工具。浏览器开发者工具是用于捕捉网站的请求信息,通过分析请求信息可以了解请..._初级python程序员能力要求

Spring @Service生成bean名称的规则(当类的名字是以两个或以上的大写字母开头的话,bean的名字会与类名保持一致)_@service beanname-程序员宅基地

文章浏览阅读7.6k次,点赞2次,收藏6次。@Service标注的bean,类名:ABDemoService查看源码后发现,原来是经过一个特殊处理:当类的名字是以两个或以上的大写字母开头的话,bean的名字会与类名保持一致public class AnnotationBeanNameGenerator implements BeanNameGenerator { private static final String C..._@service beanname

随便推点

二叉树的各种创建方法_二叉树的建立-程序员宅基地

文章浏览阅读6.9w次,点赞73次,收藏463次。1.前序创建#include<stdio.h>#include<string.h>#include<stdlib.h>#include<malloc.h>#include<iostream>#include<stack>#include<queue>using namespace std;typed_二叉树的建立

解决asp.net导出excel时中文文件名乱码_asp.net utf8 导出中文字符乱码-程序员宅基地

文章浏览阅读7.1k次。在Asp.net上使用Excel导出功能,如果文件名出现中文,便会以乱码视之。 解决方法: fileName = HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8);_asp.net utf8 导出中文字符乱码

笔记-编译原理-实验一-词法分析器设计_对pl/0作以下修改扩充。增加单词-程序员宅基地

文章浏览阅读2.1k次,点赞4次,收藏23次。第一次实验 词法分析实验报告设计思想词法分析的主要任务是根据文法的词汇表以及对应约定的编码进行一定的识别,找出文件中所有的合法的单词,并给出一定的信息作为最后的结果,用于后续语法分析程序的使用;本实验针对 PL/0 语言 的文法、词汇表编写一个词法分析程序,对于每个单词根据词汇表输出: (单词种类, 单词的值) 二元对。词汇表:种别编码单词符号助记符0beginb..._对pl/0作以下修改扩充。增加单词

android adb shell 权限,android adb shell权限被拒绝-程序员宅基地

文章浏览阅读773次。我在使用adb.exe时遇到了麻烦.我想使用与bash相同的adb.exe shell提示符,所以我决定更改默认的bash二进制文件(当然二进制文件是交叉编译的,一切都很完美)更改bash二进制文件遵循以下顺序> adb remount> adb push bash / system / bin /> adb shell> cd / system / bin> chm..._adb shell mv 权限

投影仪-相机标定_相机-投影仪标定-程序员宅基地

文章浏览阅读6.8k次,点赞12次,收藏125次。1. 单目相机标定引言相机标定已经研究多年,标定的算法可以分为基于摄影测量的标定和自标定。其中,应用最为广泛的还是张正友标定法。这是一种简单灵活、高鲁棒性、低成本的相机标定算法。仅需要一台相机和一块平面标定板构建相机标定系统,在标定过程中,相机拍摄多个角度下(至少两个角度,推荐10~20个角度)的标定板图像(相机和标定板都可以移动),即可对相机的内外参数进行标定。下面介绍张氏标定法(以下也这么称呼)的原理。原理相机模型和单应矩阵相机标定,就是对相机的内外参数进行计算的过程,从而得到物体到图像的投影_相机-投影仪标定

Wayland架构、渲染、硬件支持-程序员宅基地

文章浏览阅读2.2k次。文章目录Wayland 架构Wayland 渲染Wayland的 硬件支持简 述: 翻译一篇关于和 wayland 有关的技术文章, 其英文标题为Wayland Architecture .Wayland 架构若是想要更好的理解 Wayland 架构及其与 X (X11 or X Window System) 结构;一种很好的方法是将事件从输入设备就开始跟踪, 查看期间所有的屏幕上出现的变化。这就是我们现在对 X 的理解。 内核是从一个输入设备中获取一个事件,并通过 evdev 输入_wayland

推荐文章

热门文章

相关标签