找出互相关最大的滞后 ccf( ) [英] Finding lag at which cross correlation is maximum ccf( )
本文介绍了找出互相关最大的滞后 ccf( )的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 2 个时间序列,我正在使用 ccf
来查找它们之间的互相关性.ccf(ts1, ts2)
列出所有时间滞后的互相关.如何在不手动查看数据的情况下找到导致最大相关性的滞后?
I have 2 time series and I am using ccf
to find the cross correlation between them.
ccf(ts1, ts2)
lists the cross-correlations for all time lags. How can I find the lag which results in maximum correlation without manually looking at the data?
推荐答案
发布答案 http://r.789695.n4.nabble.com/ccf-function-td2288257.html
Find_Max_CCF<- function(a,b)
{
d <- ccf(a, b, plot = FALSE)
cor = d$acf[,,1]
lag = d$lag[,,1]
res = data.frame(cor,lag)
res_max = res[which.max(res$cor),]
return(res_max)
}
这篇关于找出互相关最大的滞后 ccf( )的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文