Reputation: 11
This is probably obvious but I cannot see where the problem is. I’m trying to run bfast on a yearly time series to detect abrupt changes in trend but keep getting the following error (it is indeed the call to stl what is causing the problem):
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
My time series has frequency 1 and 95 years of data
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
Therefore it is periodic and has more than two periods… what is causing the error then?
Upvotes: 1
Views: 418
Reputation: 2210
You need to specify frequency
when you create the time series object using ts()
. Example of data with six measurements per year:
mydata <- rep(c(1,4,6,8,5,2), 50) + rnorm(50*6)
plot(mydata, type = "l")
ts <- ts(mydata, frequency = 6, start = 1969)
Check by typing ts
, that will give you:
Time Series:
Start = c(1969, 1)
End = c(2018, 6)
Frequency = 6
Upvotes: 0
Reputation: 11
Seasonality only occurs when there is more than one observation per year. bfast can't find a harmonic equation given a single value.
Upvotes: 1