Cross correlation function between two vectors
my_ccf(x, y, min.overlap = 0.1 * max(length(x), length(y)))
x | vector |
---|---|
y | vector |
min.overlap | integer value: what is the minimal number of values between x and y that should be considered? |
list with ccf values and lags
#> $lag #> [1] -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 #> [20] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #> #> $ccf #> [1] NA NA NA NA NA #> [6] 1.000000000 0.982587728 -0.959964205 -0.471819520 -0.205928181 #> [11] -0.800593361 -0.701130950 0.346922624 0.030650455 0.230626584 #> [16] 0.486030506 -0.061027167 -0.008921997 -0.450871976 -0.558105497 #> [21] 0.139195766 -0.210373363 0.026651363 1.000000000 0.039898800 #> [26] -0.152508964 0.239216783 -0.569945792 -0.487071899 -0.045757932 #> [31] -0.046975494 0.397078213 0.439470185 0.482579941 0.689954653 #> [36] -0.840451872 -1.000000000 #>#> $lag #> [1] -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 #> [20] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #> #> $ccf #> [1] -0.076864474 0.961252204 -0.321111253 0.098186518 0.811079698 #> [6] 0.141241206 -0.041100941 -0.179277738 -0.452765109 0.285699384 #> [11] -0.186512969 0.039673848 1.000000000 0.030606532 0.029807696 #> [16] 0.455915424 -0.460528708 -0.450871976 -0.008921997 -0.061027167 #> [21] 0.486030506 0.230626584 0.030650455 0.346922624 -0.701130950 #> [26] -0.800593361 -0.205928181 -0.471819520 -0.959964205 0.982587728 #> [31] NA NA NA NA NA #>x <- runif(100) my_ccf(x[45:50], x, min.overlap=6)#> $lag #> [1] -94 -93 -92 -91 -90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -80 -79 -78 -77 -76 #> [20] -75 -74 -73 -72 -71 -70 -69 -68 -67 -66 -65 -64 -63 -62 -61 -60 -59 -58 -57 #> [39] -56 -55 -54 -53 -52 -51 -50 -49 -48 -47 -46 -45 -44 -43 -42 -41 -40 -39 -38 #> [58] -37 -36 -35 -34 -33 -32 -31 -30 -29 -28 -27 -26 -25 -24 -23 -22 -21 -20 -19 #> [77] -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 #> #> $ccf #> [1] 0.567940045 -0.833130740 0.603167018 -0.127067345 -0.565911269 #> [6] 0.687026364 -0.090968327 -0.076026813 0.340511005 -0.433715622 #> [11] 0.065911384 -0.716780515 0.181485975 0.216474546 -0.163140441 #> [16] -0.260435712 -0.323719423 0.714175859 -0.397009470 0.571847774 #> [21] -0.050274059 -0.428992330 -0.139262371 -0.300630626 0.632142554 #> [26] -0.050559298 -0.114109277 0.174181893 0.035467064 0.279482860 #> [31] -0.107581771 0.482307890 -0.454171142 -0.566116929 0.729602879 #> [36] -0.243380278 -0.108675817 0.184724023 -0.488727779 -0.038816392 #> [41] 0.455529034 -0.340999401 0.863261189 -0.567132205 -0.184643170 #> [46] 0.667071022 -0.869941477 0.606903357 -0.267686688 -0.831340363 #> [51] 1.000000000 -0.667069004 0.403601851 0.279403394 -0.304740806 #> [56] 0.882800003 -0.644289197 -0.219958608 0.420033562 -0.884201463 #> [61] 0.719892291 -0.371704153 -0.140795182 0.561900889 -0.355604367 #> [66] 0.160340390 0.200145131 -0.284535937 0.294292605 0.001622142 #> [71] -0.019830721 -0.101263091 -0.740532575 -0.055740692 0.489225625 #> [76] -0.475853229 0.372210166 0.550988431 -0.625995250 0.749486633 #> [81] -0.530582767 -0.573549632 0.729327827 -0.550012630 0.048621502 #> [86] 0.608128205 -0.972540327 0.707794490 -0.153947449 -0.393328934 #> [91] 0.257791616 -0.237568948 0.136382824 0.475223808 0.349642159 #>