问题描述
我是 R 的新手,遵循 Walter Zucchini 的 R 时间序列分析 PDF.我有一些来自传感器的数据,特别是我可以每分钟或每 5 秒获得一次数据.然后我想使用 ts()
命令来制作这些值的时间序列.所以语法应该是 data1mints <- ts(data1min ,freq = 525600)
其中 525600 是常规年份的分钟数.
之后我尝试用这个命令绘图 plot(stl(log(data1min), s.window = "periodic"))
但 R 告诉我
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 不是周期性的或少于两个周期
更准确地说,我有 3 月 20 日到 3 月 28 日的数据,所以我没有完整的年份数据,但我认为这段时间足以分析每分钟发生的事情.
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.
我错了什么?
推荐答案
错误消息告诉您哪里出了问题 - 您的句点少于 2 个.
The error message tells you what is wrong - you have less than 2 periods.
例如
# 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")
这篇关于用 R 分析时间序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!