Reputation: 1615
I'm a newbie on R following a PDF of timeseries analysis with R, by Walter Zucchini. I have some data coming from a sensor, in particular I can have data every minutes or every 5 seconds.
Then I want to use ts()
command to make a time series of those values. So the syntax should be data1mints <- ts(data1min ,freq = 525600)
where 525600 are the minutes in a regular year.
after that I try to plot with this command plot(stl(log(data1min), s.window = "periodic"))
but R says me that
series is not periodic or has less than two periods
To be more precise, I have data from 20 March to 28 March, so i didn't have a complete year data, but I think it's a enough period to analyze what happens every minute.
What I'm wrong?
Upvotes: 4
Views: 3764
Reputation: 270248
The error message tells you what is wrong - you have less than 2 periods.
For example,
# this works since there are 3 periods
freq <- 100
ny <- 3 # no of years, i.e. periods
n <- ny * freq
set.seed(13)
tt <- ts(rnorm(n), freq = freq)
s <- stl(tt, "periodic")
# this issues error since there are less than 2 periods. (We have changed ny to 1.)
freq <- 100
ny <- 1 ##
n <- ny * freq
set.seed(13)
tt <- ts(rnorm(n), freq = freq)
s <- stl(tt, "periodic")
Upvotes: 5