[英]Get the Output of CCF in Matrix / data frame format
我正在使用R中的prewhiten()
計算互相關。我想以矩陣/數據幀格式導出輸出,並且僅用於正滯后。 例如:
x<-c(12,14,22,23,25,26,28,30,32,27,36,44,22,15,8,18)
y<-c(1,2,5,2,4,4,5,6,8,9,10,3,4,8,8,9)
x_model<-auto.arima(x)
correlation<-prewhiten(x,y,x.model=x_model,plot=FALSE)
correlation$ccf
輸出不是data.frame或矩陣格式。
我想以以下格式輸出:
Lag CCF
0 0.063
1 0.263
3 0.192
等等....
您可以這樣做:
data.frame(lag=correlation$ccf$lag, CCF=correlation$ccf$acf)
但是,您可以使用str
輕松檢查對象的結構,這將幫助您轉換為所需的結構:
str(correlation$ccf)
# List of 6
# $ acf : num [1:19, 1, 1] -0.1702 0.1041 -0.0985 0.1238 0.0107 ...
# $ type : chr "correlation"
# $ n.used: int 16
# $ lag : num [1:19, 1, 1] -9 -8 -7 -6 -5 -4 -3 -2 -1 0 ...
# $ series: chr "X"
# $ snames: chr "x & y"
# - attr(*, "class")= chr "acf"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.