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, ...)

Arguments

P

List of estimated DCMs; each must carry Ep, Cp, and M$pE/M$pC (or options) so the field indices can be resolved.

field

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.

covariates

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.

X_G

Optional group design matrix (N x r); overrides covariates.

V_list

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).

Value

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.

Details

All subjects must share the same parameterisation, so the selected field indices are required to match across P.

Examples

# 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
} # }