feasts::CCF
vsの違いbase::ccf
と、reprex で異なる結果が生成される理由を理解しようとしています (NA はそれと関係がありますか?)
## Data
df <- structure(list(date = structure(c(1590919200, 1590922800, 1590926400,
1590930000, 1590933600, 1590937200, 1590940800, 1590944400, 1590948000,
1590951600, 1590955200, 1590958800, 1590962400, 1590966000, 1590969600,
1590973200, 1590976800, 1590980400, 1590984000, 1590987600, 1590991200,
1590994800, 1590998400, 1591002000), tzone = "UTC", class = c("POSIXct",
"POSIXt")), x = c(12.61, 14.2, 13.37, 16.68, 13.35, 11.42, 16.51,
11.78, 12.18, 13.67, 14.12, 13.2, 11.24, 10.76, 12.93, 16.48,
20.65, 14.55, NA, NA, NA, NA, NA, NA), y = c(459.07, 496.83,
511.17, 510.99, 511.22, 511.16, 511.22, 511.08, 511.14, 511.24,
511.21, 511.03, 511.13, 511.23, 511.1, 511.11, 511.34, 510.98,
511.18, 509.62, 511.09, 510.89, 505.53, 497.52)), class = "data.frame", row.names = c(NA,
-24L), spec = structure(list(cols = list(date = structure(list(
format = ""), class = c("collector_datetime", "collector"
)), cp.sum = structure(list(), class = c("collector_double",
"collector")), vru_gc_h2s_ppmv = structure(list(), class = c("collector_double",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), skip = 1L), class = "col_spec"))
## Base R
ccf(df$x, df$y, lag.max = 12, plot = TRUE, na.action = na.pass)
## Feasts
library(tsibble)
library(feasts)
df %>%
as_tsibble(index = date) %>%
fill_gaps() %>%
CCF(x, y, lag_max = 12) %>%
autoplot()