R 为多个ACF生成箱线图
我使用以下命令在大约200列上运行R 为多个ACF生成箱线图,r,plot,time-series,boxplot,R,Plot,Time Series,Boxplot,我使用以下命令在大约200列上运行forecast::Acf。现在我想生成一个箱线图,显示滞后1:36时相关值的分布 ## a simple example d <- data.frame(ts1 = rnorm(100), ts2 = rnorm(100)) acorr <- apply(d, 2, Acf) ##一个简单的例子 d假设您在一个数据帧中存储了多个时间序列(每列为一个序列),我们可以使用以下方法获得滞后36的ACF(nrow(d)>>36): 要生成箱线图,只需使用
forecast::Acf
。现在我想生成一个箱线图,显示滞后1:36时相关值的分布
## a simple example
d <- data.frame(ts1 = rnorm(100), ts2 = rnorm(100))
acorr <- apply(d, 2, Acf)
##一个简单的例子
d假设您在一个数据帧中存储了多个时间序列(每列为一个序列),我们可以使用以下方法获得滞后36的ACF(nrow(d)>>36
):
要生成箱线图,只需使用:
boxplot(acfs)
为什么$acf
是一个3D阵列。因为acf
函数可以直接处理多个时间序列。尝试:
## whether `d` is data frame or matrix, it is converted to "mts" inside `acf`
oo <- acf(d, lag.max = 36, plot = FALSE)$acf
在x轴上,我想要1-36,而不是ts1和ts2。在所有列上的每个滞后的分布。如果你能修好,你的回答很好。
boxplot(acfs)
## whether `d` is data frame or matrix, it is converted to "mts" inside `acf`
oo <- acf(d, lag.max = 36, plot = FALSE)$acf
boxplot(t(acfs))