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

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

智能推荐

分布式光纤传感器的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告_预计2026年中国分布式传感器市场规模有多大-程序员宅基地

文章浏览阅读3.2k次。本文研究全球与中国市场分布式光纤传感器的发展现状及未来发展趋势,分别从生产和消费的角度分析分布式光纤传感器的主要生产地区、主要消费地区以及主要的生产商。重点分析全球与中国市场的主要厂商产品特点、产品规格、不同规格产品的价格、产量、产值及全球和中国市场主要生产商的市场份额。主要生产商包括:FISO TechnologiesBrugg KabelSensor HighwayOmnisensAFL GlobalQinetiQ GroupLockheed MartinOSENSA Innovati_预计2026年中国分布式传感器市场规模有多大

07_08 常用组合逻辑电路结构——为IC设计的延时估计铺垫_基4布斯算法代码-程序员宅基地

文章浏览阅读1.1k次,点赞2次,收藏12次。常用组合逻辑电路结构——为IC设计的延时估计铺垫学习目的:估计模块间的delay,确保写的代码的timing 综合能给到多少HZ,以满足需求!_基4布斯算法代码

OpenAI Manager助手(基于SpringBoot和Vue)_chatgpt网页版-程序员宅基地

文章浏览阅读3.3k次,点赞3次,收藏5次。OpenAI Manager助手(基于SpringBoot和Vue)_chatgpt网页版

关于美国计算机奥赛USACO,你想知道的都在这_usaco可以多次提交吗-程序员宅基地

文章浏览阅读2.2k次。USACO自1992年举办,到目前为止已经举办了27届,目的是为了帮助美国信息学国家队选拔IOI的队员,目前逐渐发展为全球热门的线上赛事,成为美国大学申请条件下,含金量相当高的官方竞赛。USACO的比赛成绩可以助力计算机专业留学,越来越多的学生进入了康奈尔,麻省理工,普林斯顿,哈佛和耶鲁等大学,这些同学的共同点是他们都参加了美国计算机科学竞赛(USACO),并且取得过非常好的成绩。适合参赛人群USACO适合国内在读学生有意向申请美国大学的或者想锻炼自己编程能力的同学,高三学生也可以参加12月的第_usaco可以多次提交吗

MySQL存储过程和自定义函数_mysql自定义函数和存储过程-程序员宅基地

文章浏览阅读394次。1.1 存储程序1.2 创建存储过程1.3 创建自定义函数1.3.1 示例1.4 自定义函数和存储过程的区别1.5 变量的使用1.6 定义条件和处理程序1.6.1 定义条件1.6.1.1 示例1.6.2 定义处理程序1.6.2.1 示例1.7 光标的使用1.7.1 声明光标1.7.2 打开光标1.7.3 使用光标1.7.4 关闭光标1.8 流程控制的使用1.8.1 IF语句1.8.2 CASE语句1.8.3 LOOP语句1.8.4 LEAVE语句1.8.5 ITERATE语句1.8.6 REPEAT语句。_mysql自定义函数和存储过程

半导体基础知识与PN结_本征半导体电流为0-程序员宅基地

文章浏览阅读188次。半导体二极管——集成电路最小组成单元。_本征半导体电流为0

随便推点

【Unity3d Shader】水面和岩浆效果_unity 岩浆shader-程序员宅基地

文章浏览阅读2.8k次,点赞3次,收藏18次。游戏水面特效实现方式太多。咱们这边介绍的是一最简单的UV动画(无顶点位移),整个mesh由4个顶点构成。实现了水面效果(左图),不动代码稍微修改下参数和贴图可以实现岩浆效果(右图)。有要思路是1,uv按时间去做正弦波移动2,在1的基础上加个凹凸图混合uv3,在1、2的基础上加个水流方向4,加上对雾效的支持,如没必要请自行删除雾效代码(把包含fog的几行代码删除)S..._unity 岩浆shader

广义线性模型——Logistic回归模型(1)_广义线性回归模型-程序员宅基地

文章浏览阅读5k次。广义线性模型是线性模型的扩展,它通过连接函数建立响应变量的数学期望值与线性组合的预测变量之间的关系。广义线性模型拟合的形式为:其中g(μY)是条件均值的函数(称为连接函数)。另外,你可放松Y为正态分布的假设,改为Y 服从指数分布族中的一种分布即可。设定好连接函数和概率分布后,便可以通过最大似然估计的多次迭代推导出各参数值。在大部分情况下,线性模型就可以通过一系列连续型或类别型预测变量来预测正态分布的响应变量的工作。但是,有时候我们要进行非正态因变量的分析,例如:(1)类别型.._广义线性回归模型

HTML+CSS大作业 环境网页设计与实现(垃圾分类) web前端开发技术 web课程设计 网页规划与设计_垃圾分类网页设计目标怎么写-程序员宅基地

文章浏览阅读69次。环境保护、 保护地球、 校园环保、垃圾分类、绿色家园、等网站的设计与制作。 总结了一些学生网页制作的经验:一般的网页需要融入以下知识点:div+css布局、浮动、定位、高级css、表格、表单及验证、js轮播图、音频 视频 Flash的应用、ul li、下拉导航栏、鼠标划过效果等知识点,网页的风格主题也很全面:如爱好、风景、校园、美食、动漫、游戏、咖啡、音乐、家乡、电影、名人、商城以及个人主页等主题,学生、新手可参考下方页面的布局和设计和HTML源码(有用点赞△) 一套A+的网_垃圾分类网页设计目标怎么写

C# .Net 发布后,把dll全部放在一个文件夹中,让软件目录更整洁_.net dll 全局目录-程序员宅基地

文章浏览阅读614次,点赞7次,收藏11次。之前找到一个修改 exe 中 DLL地址 的方法, 不太好使,虽然能正确启动, 但无法改变 exe 的工作目录,这就影响了.Net 中很多获取 exe 执行目录来拼接的地址 ( 相对路径 ),比如 wwwroot 和 代码中相对目录还有一些复制到目录的普通文件 等等,它们的地址都会指向原来 exe 的目录, 而不是自定义的 “lib” 目录,根本原因就是没有修改 exe 的工作目录这次来搞一个启动程序,把 .net 的所有东西都放在一个文件夹,在文件夹同级的目录制作一个 exe._.net dll 全局目录

BRIEF特征点描述算法_breif description calculation 特征点-程序员宅基地

文章浏览阅读1.5k次。本文为转载,原博客地址:http://blog.csdn.net/hujingshuang/article/details/46910259简介 BRIEF是2010年的一篇名为《BRIEF:Binary Robust Independent Elementary Features》的文章中提出,BRIEF是对已检测到的特征点进行描述,它是一种二进制编码的描述子,摈弃了利用区域灰度..._breif description calculation 特征点

房屋租赁管理系统的设计和实现,SpringBoot计算机毕业设计论文_基于spring boot的房屋租赁系统论文-程序员宅基地

文章浏览阅读4.1k次,点赞21次,收藏79次。本文是《基于SpringBoot的房屋租赁管理系统》的配套原创说明文档,可以给应届毕业生提供格式撰写参考,也可以给开发类似系统的朋友们提供功能业务设计思路。_基于spring boot的房屋租赁系统论文