R ccf function producing "need finite 'ylim' values" / "no non-missing arguments" error messages

StackOverflow https://stackoverflow.com/questions/23521848

  •  17-07-2023
  •  | 
  •  

Pregunta

I'm trying to calculate the cross-correlation scores between a series of vectors.

My code for doing so is:

smusF<-array(ccf(arrMat[[r,1]],arrMat[[h,1]],lag.max=(length(arrMat[[r,1]])+length(arrMat[[h,1]])))[[1]])

Where smusF is the vector of all ccf scores, for each overlap position, and the r and h variables assign differing vectors for comparison.

What I'm finding is sometimes this code has no errors and works correctly, but sometimes it produces the error message:

Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

I'm really stuck as to why this happens in some instances and not others, and what I can do to fix it. Any help much appreciated.

An example of two vectors that produce this error message when compared are..

> arrMat[[r,1]]
[1] 0.011688 0.014871 0.015314 0.013446 0.008538 0.006948 0.006514 0.004343
[9] 0.002171 0.000000 0.002196 0.006899 0.012790 0.014289 0.015993 0.015321
[17] 0.016845 0.010438 0.005219 0.003040 0.007235 0.011430 0.009546 0.005351
[25] 0.004531 0.006752 0.011283 0.009062 0.006842 0.002311 0.002311 0.003614
[33] 0.006072 0.008825 0.009742 0.012397 0.013938 0.019788 0.022163 0.025293
[41] 0.022794 0.024204 0.020493 0.017092 0.010652 0.009013 0.007760 0.008768
[49] 0.008235 0.008858 0.005392 0.002696 0.000000 0.000000 0.000869 0.001737
[57] 0.003474 0.003474 0.003474 0.002212 0.009292 0.016371 0.027220 0.023992
[65] 0.023172 0.015995 0.015421 0.010799 0.011676 0.012986 0.017361 0.018033
[73] 0.018508 0.022458 0.027989 0.034674 0.030668 0.024449 0.013905 0.009333
[81] 0.005809 0.005219 0.003441 0.002433 0.001425 0.000950 0.002138 0.003326
[89] 0.004989 0.003326 0.001663 0.000000 0.000000 0.000000 0.000000 0.000000
[97] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[105] 0.000000 0.000000 0.000000 0.000770 0.001540 0.002311 0.001540 0.000770
[113] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[121] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[129] 0.000000 0.000000 0.000000 0.001188 0.002376 0.004719 0.004687 0.004654
[137] 0.002311 0.001155 0.000000 0.000000 0.000713 0.001425 0.002138 0.001425
[145] 0.000713 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[153] 0.000000 0.000000

And..

> arrMat[[h,1]]
[1] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[9] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[17] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[25] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[33] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[41] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[49] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[57] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[65] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[73] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[81] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[89] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[97] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[105] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[113] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[121] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[129] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[137] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[145] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[153] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[161] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[169] 0.000000 0.000000 0.012729 0.025457 0.045459 0.043641 0.063643 0.089100
[177] 0.125907 0.119074 0.079510 0.040635 0.023581 0.031983 0.034051 0.036118
[185] 0.030912 0.023639 0.016365 0.007273 0.003637 0.007273 0.018184 0.029094
[193] 0.030912 0.025457 0.020002 0.010910 0.005455 0.000000 0.000000 0.000000
[201] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[209] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[217] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[225] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[233] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[241] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[249] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[257] 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
[265] 0.000000 0.000000 0.000000 0.000000
¿Fue útil?

Solución

For future reference it seems ccf is not happy comparing un-fluctuating vectors, such as a vector of only '1's against a vector of only '2's, or in the above example, overlaps to '0's against '0's

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top