rrr
rrr

Reputation: 371

Extracting seasonal effect without using stl or decompose

I have a data named 'bicoal' which consists of annual bituminous coal production in the United States from 1920 to 1968.

`Time Series:
Start = 1920 

End = 1968 

Frequency = 1 
 
[1] 569 416 422 565 484 520 573 518 501 505 468 382 310 334 359 372 439 446 349 395
[21] 461 511 583 590 620 578 534 631 600 438 516 534 467 457 392 467 500 493 410 412
[41] 416 403 422 459 467 512 534 552 545`

I made a time series, saved under the name time_series, and wanted to extract the seasonal effect using the code plot(decompose(time_series)) and plot(stl(time_series)), but got an error message

Error in stl(time_series) : 
  series is not periodic or has less than two periods
Error in decompose(time_series) : 
  time series has no or less than 2 periods

If stl nor decompose doesn't work, is there a way to extract the seasonal effect?

Upvotes: 0

Views: 120

Answers (1)

Victor Feagins
Victor Feagins

Reputation: 320

Without seeing how your time series is constructed I think this might be your problem.

data <- rep(seq(1,5),5)
ts.1 <- ts(data)
stl(ts.1)

enter image description here

Now to fix this issue the ts function has a frequency argument that defines the period of the data.

ts.2 <- ts(data, frequency = 5)

stl(ts.2, s.window = "periodic")

enter image description here

Upvotes: 0

Related Questions