# \donttest{
library(data.table)
# 1. Create dummy data with ALL covariates required by prewhiten_*_glm()
# The internal GLM formulas likely include:
# I ~ t_norm + Regime + EconCycle + PopDensity + Epidemics + Climate + War
DT <- data.table(
year = 2000:2029,
I = rpois(30, lambda = 10),
C = rpois(30, lambda = 8),
exposure50 = runif(30, 100, 200),
log_exposure50 = log(runif(30, 100, 200)),
# Covariates
t_norm = seq(-1, 1, length.out = 30),
Regime = factor(sample(c("A", "B"), 30, replace = TRUE)),
EconCycle = rnorm(30),
PopDensity = rnorm(30),
Epidemics = rnorm(30),
Climate = rnorm(30),
War = rnorm(30)
)
# 2. Define global paths using tempdir() (Fixes CRAN policy)
# run_transfer_entropy writes output to 'dir_csv'
tmp_dir <- tempdir()
dir_csv <- file.path(tmp_dir, "csv")
if (!dir.exists(dir_csv)) dir.create(dir_csv, recursive = TRUE)
# 3. Run the function
# Using fewer shuffles for a faster example check
te_tab <- run_transfer_entropy(DT, lags = 1, shuffles = 10, seed = 123)
# Inspect results
if (!is.null(te_tab)) {
print(subset(te_tab, type == "counts"))
}
# }
Run the code above in your browser using DataLab