stl中的错误,序列的周期少于两个(错误?) [英] error in stl, series has less than two periods (erroneous?)

查看:193
本文介绍了stl中的错误,序列的周期少于两个(错误?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两年的每月数据,但是 stl()似乎至少需要两年零一个月.

I have two years of monthly data but stl() seems to need a minimum of two years and one month.

以下是两个简单的示例:

Here are two simple examples:

示例1-返回

stl(x,"periodic")中的错误: 系列不是周期性的,或者周期少于两个

Error in stl(x, "periodic") : series is not periodic or has less than two periods

dat_24 <- cumsum(rnorm(24))
x_24 <- ts(dat_24, frequency = 12)
stl(x_24, "periodic")

示例2-按预期返回预测

Example 2 - returns forecast as expected

dat_25 <- cumsum(rnorm(25))
x_25 <- ts(dat_25, frequency = 12)
stl(x_25, "periodic")

我应该只能用频率为12的24个数字来获得预测吗?

Shouldn't I be able to get a forecast with only 24 numbers with frequency = 12?

推荐答案

它适用于所有周期性序列,无论是每周,每年还是任何其他时期.除了该期间至少 2 个完整周期外,您还必须至少有1个额外的数据点.

It holds true for all kind of periodic series, be it a weekly or yearly or any other period. You have to have atleast 1 extra data point, in addition to atleast 2 complete cycles of the period.

以下是每周系列的一个示例,在该示例中您也会遇到错误:

Here is an example for weekly series where you will get error too:

dat_Weekly <- cumsum(rnorm(104,0,5))
x_Weekly <- ts(dat_Weekly, frequency = 52, start = c(2013))
stl(x_Weekly, "periodic")

您可以浏览原始论文:此处

You can go through the original paper: here

下面的解释可能不是最好的解释,但我想尝试一下.

Below explanation might not be the best one, but I want to give a shot.

假设您有一家冰淇淋公司的2年月度销售数据( 24 个数据点),而您的目标是找出其中的季节性.

Let's say you have exactly 2 years of monthly sales data (24 data points) for an ice-cream company and your goal is to find out seasonality in it.

STL要做的第一件事是使用2年或更长时间(24或36或48个月)的数据,以便计算季节性,趋势等.在这种情况下,我们有24个数据点.现在,STL将至少需要一个额外的数据点 ON ,它可以预测季节性. 由于STL已经使用您的前24个数据点来学习每月的季节性,因此绝对需要下一个数据点来扩展先前的预测.

First thing STL would do is consume the data for 2 or more years (24 or 36 or 48 months) in order to calculate Seasonality, Trend etc. In this case we have exactly 24 data points. Now, STL would required atleast an additional data point ON which it would predict the seasonality. Since STL has already used your first 24 data points in learning the monthly seasonality, the next data point is absolutely required to extend what has been predicted earlier.

换句话说,前24个数据点用于检查季节性,而下一个数据点(大于24 )将遵循之前计算的两年的季节性模式.对于一月份的销售,您可能会看到STL图表出现下降.

In other words, first 24 data points are being used to check out the seasonality while the next data points (greater than 24) will follow the previously calculated seasonal patterns of two years. For January sales, you might see a dip in the STL plot.

这篇关于stl中的错误,序列的周期少于两个(错误?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆