The main user-facing class. Specify a DAG, optionally assign mechanisms to nodes, fit to data, and extract causal effects.
Public fields
dagNamed list - the DAG specification.
mechanismsNamed list of
Mechanisminstances, one per node.dataThe training
data.frame(set after$fit()).tracesNamed list of mechanism fit objects, one per node (after fit).
.fittedLogical - whether
$fit()has been called.
Methods
KaguModel$new()
Create a new KaguModel.
Usage
KaguModel$new(dag, mechanisms = NULL)Arguments
dagNamed list mapping each node to a character vector of its parent node names. Root nodes map to
c().mechanismsOptional named list of
Mechanisminstances. Any node not specified receives aGPMechanismby default.
KaguModel$fit()
Fit each node's conditional distribution in topological order.
KaguModel$effects()
Estimate the causal effect of source on target.
Usage
KaguModel$effects(
source,
target,
values = NULL,
std_units = FALSE,
conditions = NULL,
sweep = FALSE,
sweep_n = 50L,
sweep_range = NULL,
hdi = 0.9
)Arguments
sourceCharacter scalar - the intervention (treatment) node.
targetCharacter scalar - the outcome node.
valuesOptional numeric vector of length 2
c(from, to)giving the explicit intervention contrast.std_unitsLogical - if
TRUE, compute the effect of a 1-SD increase centred at the mean.conditionsOptional named list of node values to condition on (fixes those nodes at the given values during propagation). Can also be a list of such lists to compute and overlay multiple conditions.
sweepLogical - if
TRUE, compute the dose-response curve.sweep_nInteger - number of points in the sweep grid (default 50).
sweep_rangeNumeric vector
c(min, max)for the sweep grid. Defaults to the observed range ofsource.hdiNumeric in (0, 1) - HDI probability (default 0.90).
KaguModel$summary()
Per-node summary table.
For each node, reports the direct local effect of each parent (the function's gradient at the parents' means - comparable to a regression coefficient) and the residual noise sd, each with posterior mean, sd and HDI.
KaguModel$diagnostics()
Fit diagnostics for each node.
The Gaussian-process sampler produces a single chain, so r-hat / ESS do not apply; this reports the posterior draw count and the residual noise sd per node.
KaguModel$plot_dag()
Visualise the DAG structure.
KaguModel$plot_posterior()
Plot the posterior for a fitted node.
Shows the node's direct local effects (each parent's gradient at the means) and residual noise, as posterior means with HDI intervals.