Convenience wrapper around rsdcm that assembles its
inputs from a list of estimated DCMs (as returned by
dcm_estimate). For each subject it takes the posterior mean
Ep and covariance Cp restricted to the requested parameter
field, builds a between-subject design, and fits the robust + sparse group
model.
rsdcm_fit(P, field = "A", covariates = NULL, X_G = NULL, V_list = NULL, ...)List of estimated DCMs; each must carry Ep, Cp, and
M$pE/M$pC (or options) so the field indices can be
resolved.
Parameter block(s) to model at the group level, named as in the
DCM parameter structure Ep. For an fMRI DCM these are "A",
"B", "C", "D", "transit", "decay" and
"epsilon"; pass one (e.g. "A") or several (e.g.
c("A", "B")). Case-sensitive: the connectivity blocks are uppercase
("A", not "a"). Passed to dcm_find_pC.
Optional data frame of between-subject covariates, one row
per subject; NULL gives an intercept-only design (the group mean).
Ignored if X_G is supplied.
Optional group design matrix (N x r); overrides covariates.
Optional list of p x p variance-component bases; defaults to a per-parameter diagonal basis.
Further arguments passed to rsdcm (e.g.
nu, pi, verbose).
The list returned by rsdcm, with the group
effects and inclusion probabilities labelled by the selected parameters and
design columns, plus the selected param_index.
All subjects must share the same parameterisation, so the selected field
indices are required to match across P.
# This wrapper consumes a list of fitted DCMs (each from dcm_estimate): you
# invert every subject, then fit the group model on a chosen field. For a
# runnable example on precomputed summaries, see ?rsdcm and the
# narps_dcm dataset.
if (FALSE) { # \dontrun{
dcm_files <- list.files("dcms", pattern = "\\.rds$", full.names = TRUE)
fits <- lapply(dcm_files, function(f) dcm_estimate(readRDS(f)))
grp <- rsdcm_fit(fits, field = "A",
covariates = data.frame(age = subject_ages))
round(grp$beta_mat, 3) # group-level A effects
round(grp$inclusion, 3) # posterior inclusion probabilities
} # }