运行bfast功能时出错

时间:2013-11-26 12:16:54

标签: r

这可能很明显,但我看不出问题出在哪里。我试图在年度时间序列上运行bfast以检测趋势的突然变化,但不断得到以下错误(确实是调用stl导致问题的原因):

bfast(GM85.ts,h=0.15,max.iter=1,season="none")

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

我的时间序列有1年和95年的频率数据

GM85.ts
Time Series:
Start = 2006 
End = 2100 
Frequency = 1

 [1] 13.88868 13.89915 13.91431 13.93718 13.94067 13.94063 13.96324 13.99648 14.01391 14.03268 14.04667 14.05893 14.05230 14.06443 14.07909 14.11433 14.14736 14.14514 14.15454 14.19593 14.23417 14.23578 14.25171 14.27545 14.27213
[26] 14.29543 14.32851 14.34124 14.36091 14.38245 14.41517 14.42666 14.45183 14.49599 14.50378 14.52052 14.54298 14.58360 14.60798 14.62069 14.64962 14.68641 14.71247 14.72497 14.76606 14.79369 14.81297 14.84822 14.86503 14.89134
[51] 14.92601 14.95497 14.98318 15.01789 15.05929 15.09193 15.11453 15.14574 15.17960 15.20188 15.23737 15.27275 15.28612 15.32248 15.34883 15.38858 15.42155 15.45223 15.48342 15.51099 15.54076 15.58005 15.59959 15.63353 15.66272
[76] 15.69312 15.71358 15.73641 15.76502 15.79923 15.83983 15.87472 15.91833 15.93602 15.99177 16.03119 16.05529 16.07834 16.10982 16.14174 16.17376 16.22898 16.25100 16.27703 16.30971

因此它是周期性的并且有两个以上的时期......那么导致错误的是什么?

2 个答案:

答案 0 :(得分:1)

仅在每年有多次观察时才会出现季节性。给定单个值时,bfast无法找到谐波方程。

答案 1 :(得分:0)

使用frequency创建时间序列对象时,需要指定ts()。每年进行六次测量的数据示例:

mydata <- rep(c(1,4,6,8,5,2), 50) + rnorm(50*6)
plot(mydata, type = "l")
ts <- ts(mydata, frequency = 6, start = 1969)

通过键入ts进行检查,这将为您提供:

Time Series:
Start = c(1969, 1) 
End = c(2018, 6) 
Frequency = 6