R Observatory
Search

rsDCM

0.1.0CRAN

Robust and Sparse Dynamic Causal Modelling for Functional MRI

install.packages("rsDCM")
Test coverage, method
64%of lines run by tests

Provides a robust and sparse method for group-level Dynamic Causal Modelling (DCM) of functional magnetic resonance imaging (fMRI) data: Student-t weighting of subjects for robustness, combined with a nonlocal product-moment (pMOM) spike-and-slab prior for sparse selection of group-level effects ...

Full description

Provides a robust and sparse method for group-level Dynamic Causal Modelling (DCM) of functional magnetic resonance imaging (fMRI) data: Student-t weighting of subjects for robustness, combined with a nonlocal product-moment (pMOM) spike-and-slab prior for sparse selection of group-level effects (<doi:10.48550/arXiv.2609.06379>). The package also provides an R implementation of single-subject DCM for fMRI using variational Laplace inversion (Friston et al., 2003 <doi:10.1016/S1053-8119(03)00202-7>), including the bilinear neural state equation and the Buxton-Friston hemodynamic response model, ported from the 'SPM25' (version 25.01.02) toolbox for 'MATLAB'.

Maintainer
Godfred Arhin
Licence
GPL-2
Latest release
6 Oct 2026
First release
6 Oct 2026

Compare with another package

More details
Releases
1
Needs compilation
No
Needs R
>= 4.0.0
Config/roxygen2/version
8.0.0
Config/testthat/edition
3
Date
2026-09-24
LazyData
true
Subjects (2) Method, Subjects
Cite

Package

Run in R for the authors' preferred citation:

citation("rsDCM")

The package provides a citation file that builds its entry when R runs it. Run citation() to see it.

R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA
Balamuta, J. J. (2026). R Observatory: Metrics for rsDCM version 0.1.0 [Data set]. HJJB, LLC. Data release v2026-10-28. https://doi.org/10.5281/zenodo.21843040
About

From data release v2026-10-28, which the citation names so these numbers can be found later.

All 13 check platforms pass.

  • r-devel-linux-x86_64-debian-clang

    The unreleased R on Linux, x86_64, debian-clang

    OK

    Version checked
    0.1.0
    Time taken
    139 s
  • r-devel-linux-x86_64-debian-gcc

    The unreleased R on Linux, x86_64, debian-gcc

    OK

    Version checked
    0.1.0
    Time taken
    97 s
  • r-devel-linux-x86_64-fedora-clang

    The unreleased R on Linux, x86_64, fedora-clang

    OK

    Version checked
    0.1.0
    Time taken
    120 s
  • r-devel-linux-x86_64-fedora-gcc

    The unreleased R on Linux, x86_64, fedora-gcc

    OK

    Version checked
    0.1.0
    Time taken
    96 s
  • r-devel-windows-x86_64

    The unreleased R on Windows, x86_64

    OK

    Version checked
    0.1.0
    Time taken
    143 s
  • r-oldrel-macos-arm64

    The previous release of R on macOS, arm64

    OK

    Version checked
    0.1.0
    Time taken
    47 s
  • r-oldrel-macos-x86_64

    The previous release of R on macOS, x86_64

    OK

    Version checked
    0.1.0
    Time taken
    135 s
  • r-oldrel-windows-x86_64

    The previous release of R on Windows, x86_64

    OK

    Version checked
    0.1.0
    Time taken
    178 s
  • r-patched-linux-x86_64

    The patched release of R on Linux, x86_64

    OK

    Version checked
    0.1.0
    Time taken
    132 s
  • r-release-linux-x86_64

    The current release of R on Linux, x86_64

    OK

    Version checked
    0.1.0
    Time taken
    129 s
  • r-release-macos-arm64

    The current release of R on macOS, arm64

    OK

    Version checked
    0.1.0
    Time taken
    37 s
  • r-release-macos-x86_64

    The current release of R on macOS, x86_64

    OK

    Version checked
    0.1.0
    Time taken
    150 s
  • r-release-windows-x86_64

    The current release of R on Windows, x86_64

    OK

    Version checked
    0.1.0
    Time taken
    143 s
  • 13 OK

Check results on CRAN

Total downloads in the last 30 days
327It comes from CRAN alone. autoCRAN was counted over another window, so it is not added.

CRAN rank

11,843 of 26,530

  • CRAN

CRAN

327 downloads in the last 30 days

Rank
11,843 of 26,530

It is in the total. Take it out

autoCRAN

0 downloads in the last 7 days

It is not added because it has no figure for the last 30 days.

Over time

Compare downloads

Needs
6
Dependent packages
0
Suggested by
0
Needs (6)
Installing it adds
1 package, 145 KB of source
Of those, need compilation
1
Optional extras (5)
Functions
64
Public exports
51
Lines of R code
4,235
Median complexity
8.5
Functions (64)
Size and composition

Lines by kind (6,683)

KindLinesShare
R code4,23563%
Tests4867%
Documentation1,78727%
Guides1753%

Lines by language

LanguageLinesShare
R4,72171%
Rd1,78727%
Vignettes1753%

Languages are counted from file extensions.

Files
94
R functions
64
Complexity
Median
8.5
Mean
14.19
Highest
77
Median lines per function
30
About complexity

Cyclomatic complexity counts the independent paths through a function: 1 is a straight line, higher is harder to test. R functions only.

Call graph figures
R functions
64
Calls
110
Unconnected
10
Groups
1

The tests ran and coverage was measured.

Lines run by tests
64.2%
Expressions run by tests
63.8%
Test cases
30
Exports named in tests
39.2%
Coverage by file (16)
Coverage run
Lines counted
2,243
Lines the tests ran
1,440
Tests passed
Yes
Measured with
covr 3.6.5 on R 4.6.1
Test suite
Has tests
Yes
Test frameworks
testthat
Test cases
30
Lines of tests
486
Test lines per line of code
0.11
Exports documented
100%
Arguments documented
95%
Return value documented
100%
Help pages with examples
42.6%
Examples run in checks
91.3%
Guides (1)
Other documentation
README
Yes, 420 words
Release notes file
Yes
Help pages
54
Lines of documentation
1,787
DatasetSize
narps_dcmSubject-level DCM summaries for a group analysis (NARPS)length 6
toy_dcmExample DCM for fMRI inversionlength 11

Kay202 / rsdcm on github.com

Stars
0
Forks
0
Open issues
0
Last commit
6 Oct 2026
Activity
Commits
–
Open pull requests
0
Tagged releases
0
Latest tagged release
–
Issues closed in
–
Pull requests closed in
–
Pull requests merged
–
Created
14 Sep 2026
Licence file reads as
–
Development practices (4)
KindFound
Continuous integrationGitHub Actions, R CMD check workflow
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
Docs sourceGitHub Pages site last deployed 2026-09-15
Reproducibility and dev environmentdata-raw/

Method, repository practices

Across Kay202

R releases
  • On CRAN
  • Release
VersionReleasedR
0.1.0 current6 Oct 20264.6.1
Release notes (0.1.0)

First release.

Robust and sparse group-level DCM

  • rsdcm() fits a robust, sparse group-level model to subject-level DCM parameters: Student-t weighting of subjects for robustness to outliers, a nonlocal product-moment (pMOM) spike-and-slab prior for sparse selection of group effects, and ReML-estimated between-subject variance components. It returns the group effects, their posterior inclusion probabilities, the per-subject robustness weights, and the learned spike/slab scales. See <arXiv:2609.06379>.
  • rsdcm_fit() is a convenience wrapper that assembles the inputs from a list of dcm_estimate() fits (the posterior Ep/Cp restricted to a chosen parameter field) and a between-subject design.
  • narps_dcm: subject-level DCM summaries for 48 subjects (with group/gender/age covariates), derived from the openly shared NARPS dataset. It is the runnable real-data example for rsdcm().
  • Progress is reported via message() and is silenceable, matching the rest of the package.

Dynamic Causal Modelling for fMRI (R port of SPM25)

  • dcm_estimate(), dcm_nlsi_GN(), dcm_int() ported from SPM25 with optimizations: propagator caching in the bilinear integrator, identity-projection fast path in dcm_diff(), diagonal fast paths in dcm_inv() / dcm_logdet(). Roughly 20x faster end-to-end than a literal port on representative DCMs.
  • toy_dcm dataset (three regions, 482 scans) for documentation, smoke-testing, and examples.
  • Vignette introduction with a worked end-to-end example.
  • Help pages for all exported functions.

Parametric Empirical Bayes (PEB)

  • Hierarchical (group-level) modelling of DCM parameters across subjects, ported from SPM25's spm_dcm_peb:
  • dcm_peb_prepare() / dcm_peb_run(): prepare and fit a second- or third-level PEB by variational Laplace.
  • dcm_peb_of_pebs(): third-level PEB-of-PEBs over a directory of subject PEBs, with a between-subject design.
  • dcm_peb_design(): build the group-level design matrix.
  • dcm_peb_files() / dcm_peb_load(): locate and load subject PEBs from .rds or MATLAB .mat files (.mat needs the suggested R.matlab package).
  • dcm_peb_of_pebs() does not write to disk unless a save_path is supplied.

Naming

Ported SPM routines keep the dcm_ prefix (from spm_), to avoid

colliding with an installed SPM-derived package and to make it obvious

which functions come from here: spm_dcm_estimate becomes dcm_estimate,

spm_nlsi_GN becomes dcm_nlsi_GN, spm_int becomes dcm_int, and so on.

Supported model variants

  • This release implements only the deterministic, single-state fMRI DCM (non-linear DCM, via a non-empty d array, is also supported).
  • The two-state, stochastic, and spectral / cross-spectral-density (`induced`) variants are not yet implemented. dcm_estimate() stops with an informative error if any of these options is switched on, instead of silently running the deterministic model. They are planned for a future update.

Behavioural changes vs. the MATLAB original

  • Progress messages from dcm_nlsi_GN() use message() and can be silenced with suppressMessages().
  • dcm_estimate() does not write to disk by default. Pass save = TRUE together with a file path to recover the SPM25 behaviour.
  • The previous .spm_env global is replaced by a package-internal environment whose mutable settings are exposed through rsdcm_options().