The release version on CRAN:
install.packages("PCBN")
The development version from GitHub:
# install.packages("remotes")
# remotes::install_github("AlexisDerumigny/PCBN")
install.packages("PCBN", repos = c('https://alexisderumigny.r-universe.dev', 'https://cloud.r-project.org'))
PCBN supports bnlearn and caugi graphs. Existing calls continue to
use bnlearn. Install the optional caugi package to use its backend:
install.packages("caugi")
Pass graph_backend to a function that accepts a DAG to select its
backend. PCBN converts the input graph before computation, so the same
graph can be used to compare both backends:
library(PCBN)
DAG = bnlearn::model2network("[U1][U2|U1][U3|U2]")
dsep_set(DAG, "U1", "U3", "U2", graph_backend = "bnlearn")
## [1] TRUE
if (requireNamespace("caugi", quietly = TRUE)) {
dsep_set(DAG, "U1", "U3", "U2", graph_backend = "caugi")
}
## [1] TRUE
You can also build a native caugi graph:
if (requireNamespace("caugi", quietly = TRUE)) {
DAG = create_empty_DAG(3, graph_backend = "caugi")
DAG = caugi::add_edges(DAG, from = "U1", edge = "-->", to = "U3")
dsep_set(DAG, "U1", "U2")
}
## [1] TRUE
When graph_backend is omitted, functions infer it from the input
graph. new_PCBN(), fit_copulas(), and fit_all_orders() accept the
same argument. PCBN objects store the selected native graph in $DAG
and the backend name in $graph_backend. Simulation, likelihood
calculation, printing, and plotting use that backend automatically.
Graph repair also returns the selected native graph type.
Conversions preserve node order and isolated nodes. Different backends may use different valid topological orderings, so identical random seeds need not produce identical simulated samples across backends. The caugi backend requires version 1.3.0 or later; installing it from source requires a Rust toolchain.
Derumigny A., Horsman N., & Kurowicka D. Restrictions of PCBNs for integration-free computations arXiv:2510.03518.