R Under development (unstable) (2026-07-17 r90265 ucrt) -- "Unsuffered Consequences" Copyright (C) 2026 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > # Regression tests for audit item 6: graphicalVAR-datatype bootstrap paths. > # > # Bugs fixed in R/bootnet.R: > # 1. Node-drop setup used `length(vars)` with `vars` undefined in bootnet()'s > # scope -> "object 'vars' not found" for any node-drop bootstrap on > # graphicalVAR data. > # 2. Node-drop subsetting of data_l used grep() with a character VECTOR as > # pattern, so only the first sampled node's lag columns were kept -> > # wrong design matrix. > # 3. The tsData 'vars' field was not subset, but graphicalVAR::graphicalVAR() > # uses it to locate the lag-1 beta columns -> subscript error. > > library(bootnet) Loading required package: ggplot2 This is bootnet 1.9.1 For questions and issues, please see github.com/SachaEpskamp/bootnet. > > if (!requireNamespace("graphicalVAR", quietly = TRUE)) { + message("Package 'graphicalVAR' not available; skipping item 6 tests.") + } else { + + set.seed(42) + Mod <- graphicalVAR::randomGVARmodel(4, probKappaEdge = 0.3, probBetaEdge = 0.3) + simData <- graphicalVAR::graphicalVARsim(100, Mod$beta, Mod$kappa) + + net <- suppressWarnings(estimateNetwork( + simData, + default = "graphicalVAR", + nLambda = 4, + verbose = FALSE + )) + stopifnot(inherits(net, "bootnetResult")) + stopifnot(net$datatype == "graphicalVAR") + + # Sanity check of the stored tsData-like object and its lag-column naming + # (intercept column "1" plus "_lag1" per variable): + stopifnot(!is.null(net$data$vars)) + stopifnot(identical( + names(net$data$data_l), + c("1", paste0(net$data$vars, "_lag1")) + )) + + ## 1) Nonparametric bootstrap completes: + set.seed(1) + bNP <- suppressWarnings(bootnet( + net, nBoots = 2, type = "nonparametric", + verbose = FALSE, statistics = "edge" + )) + stopifnot(inherits(bNP, "bootnet")) + stopifnot(length(bNP$boots) == 2) + + ## 2) Node-drop bootstrap completes (previously: "object 'vars' not found"): + set.seed(2) + bND <- suppressWarnings(bootnet( + net, nBoots = 2, type = "node", + verbose = FALSE, statistics = "edge", + memorysaver = FALSE # keep boot data so retained columns can be inspected + )) + stopifnot(inherits(bND, "bootnet")) + stopifnot(length(bND$boots) == 2) + + # Each node-drop bootstrap must have retained exactly the sampled nodes' + # columns: contemporaneous data, intercept + lag columns, vars field, and + # graph dimensions all matching the sampled node set: + for (i in seq_along(bND$boots)) { + boot_i <- bND$boots[[i]] + sampled <- boot_i$labels + stopifnot(all(sampled %in% net$labels)) + stopifnot(boot_i$nNode == length(sampled)) + stopifnot(boot_i$nNode >= 2, boot_i$nNode <= 3) # subNodes = 2:(p-1) + + # Graph dimensions match the sampled node count: + stopifnot(identical(dim(boot_i$graph$contemporaneous), + c(length(sampled), length(sampled)))) + stopifnot(identical(dim(boot_i$graph$temporal), + c(length(sampled), length(sampled)))) + + # The bootstrapped tsData kept exactly the sampled nodes' columns: + bd <- boot_i$data + stopifnot(identical(bd$vars, sampled)) + stopifnot(identical(colnames(bd$data_c), sampled)) + stopifnot(identical(names(bd$data_l), c("1", paste0(sampled, "_lag1")))) + } + + message("test-item06-graphicalvar.R: all tests passed.") + } Model did NOT converge in inner loop Model did NOT converge in inner loopMinimal tuning parameter for beta selected. Minimal tuning parameter for kappa selected. Note: bootnet will store only the following statistics: edge Model did NOT converge in inner loop Model did NOT converge in inner loop Model did NOT converge in inner loopMinimal tuning parameter for kappa selected. Model did NOT converge in inner loop Model did NOT converge in inner loopMinimal tuning parameter for beta selected. Minimal tuning parameter for kappa selected. Note: bootnet will store only the following statistics: edge Model did NOT converge in inner loop Model did NOT converge in inner loop Model did NOT converge in inner loop Model did NOT converge in inner loop Model did NOT converge in inner loop Model did NOT converge in inner loopMinimal tuning parameter for beta selected. Minimal tuning parameter for kappa selected. Model did NOT converge in inner loop Model did NOT converge in inner loopMinimal tuning parameter for beta selected. Minimal tuning parameter for kappa selected. test-item06-graphicalvar.R: all tests passed. > > proc.time() user system elapsed 5.85 0.93 6.78