# \donttest{
library(data.table)
# 1. Create dummy data with ALL required columns for VARX
# The function explicitly requires these specific exogenous variables
DT <- data.table(
year = 2000:2049, # 50 obs to ensure diagnostics (lags.pt=10) don't fail
I = rpois(50, lambda = 10),
C = rpois(50, lambda = 8),
# Exogenous regressors required by the function
EconCycle = rnorm(50),
PopDensity = rnorm(50),
Epidemics = rnorm(50),
Climate = rnorm(50),
War = rnorm(50),
t_norm = seq(-1, 1, length.out = 50)
)
# 2. Define global output directory using tempdir() (Fixes CRAN policy)
# run_varx looks for 'dir_out' in the global environment
tmp_dir <- tempdir()
dir_out <- file.path(tmp_dir, "varx")
if (!dir.exists(dir_out)) dir.create(dir_out, recursive = TRUE)
# 3. Run the function
# We use p=1 to keep it fast and stable for the example check
res_varx <- run_varx(DT, p = 1)
# Inspect the fitted VAR object if it didn't fail
if (!inherits(res_varx$fit, "try-error")) {
print(res_varx$fit)
}
# }
Run the code above in your browser using DataLab