# [R] Finding the max correlation coefficient value using CCF function

Nikhil Kaza nikhil.list at gmail.com
Wed Apr 28 14:11:20 CEST 2010

```try this

?which.max

Nikhil Kaza
Asst. Professor,
City and Regional Planning
University of North Carolina

nikhil.list at gmail.com

On Apr 27, 2010, at 11:42 PM, vikrant wrote:

>
> Hi All,
> Suppose I have 2 time series
> a = 1:20
> b = 5:15
>
> and I am finding the cross correlation between these two time series
> using
> CCF function.
>
> c = ccf(a,b)
> print(c)
>
> Autocorrelations of series ‘X’, by lag
>
>    -7     -6     -5     -4     -3     -2     -1      0      1
> 2      3
> 4      5      6      7
> -0.358 -0.255 -0.110  0.070  0.278  0.507  0.750  1.000  0.750
> 0.507  0.278
> 0.070 -0.110 -0.255 -0.358
>
> it will give me the correlation coefficient (r) with corrsponding
> lags.
> My Question is how to find the value of maximum correlation
> coefficient
> with the corrsponding lag.
> here in this case its r = 0.75 with lag = 0
>
> how to get this valus in a vector or variable?
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Finding-the-max-correlation-coefficient-value-using-CCF-function-tp2068580p2068580.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

```