On Mon, 27 Nov 2006, [EMAIL PROTECTED] wrote:

> hello,
>
> i have been using ccf() to look at the correlation between lightning and 
> electrogamnetic data. for the most part it has worked exactly as 
> expected. however, i have come across something that puzzles me a bit:
>
>> x <- c(1, 0, 1, 0, 1, 0)
>> y <- c(0, 0, 0, 0, 0, 0)
>> ccf(x, x, plot = FALSE)
>
> Autocorrelations of series 'X', by lag
>
>    -4     -3     -2     -1      0      1      2      3      4
> 0.333 -0.500  0.667 -0.833  1.000 -0.833  0.667 -0.500  0.333
>> ccf(x, y, plot = FALSE)
>
> Autocorrelations of series 'X', by lag
>
> -4  -3  -2  -1   0   1   2   3   4
> NaN NaN NaN NaN NaN NaN NaN NaN NaN
>> y <- c(1, 1, 1, 1, 1, 1)
>> ccf(x, y, plot = FALSE)
>
> Autocorrelations of series 'X', by lag
>
> -4  -3  -2  -1   0   1   2   3   4
> NaN NaN NaN NaN NaN NaN NaN NaN NaN
>
> i don't see why the result from ccf() would be NaN if the elements of y 
> are all the same... perhaps i am just being silly or missing something. 
> but if i work this out by hand, then i get a proper result. so, why not 
> with ccf()?

How do you get a non-zero value for the variance of y?  Dividing zero by 
zero is NaN, and that is what is happening here.

-- 
Brian D. Ripley,                  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to