Skip to main content

rsmodel

A qualitative, two-state dynamical model of the interaction between depressive symptoms and psychological resilience under external adversity — the resilience–symptom (RS) model:

dr/dt = (-s + (1-s)*r) * (1-r) * r
ds/dt = (e*(1+s-r) - s*r) * (1-s) * s

where r ∈ [0,1] is the resilience level (0 = depleted, 1 = full), s ∈ [0,1] the depressive symptom level (0 = healthy, 1 = severe), and e ∈ [0,1] an external adverse input. The unit square is positively invariant.

This is the reference implementation for

Björn S. Rüffer & Michael Schönlein, A mathematical model for depression and resilience.

Preprint: arXiv:2608.22073 — under review.

Interactive playground, no installation required: https://rsmodel.org

Warning Neither the model nor its time scale is calibrated against clinical data. This is a qualitative model, not a quantitative one, and it does not represent the effects of medication or of any other intervention. It is not a diagnostic or clinical tool.

Install

uv add rsmodel

Usage

from rsmodel import RSModel, Patient
from rsmodel.utils import get_predefined_scenarios

model = RSModel()
model.rhs(_r=0.84, _s=0.67, _e=0.3)         # -> (dr/dt, ds/dt)
model.plot_equilibria()                      # equilibrium manifold over e ∈ [0,1]
model.plot_streamlines(external_input=0.2)   # phase portrait at constant e

patient = Patient(s0=0.67, r0=0.84)
patient.get_stimulus_response(get_predefined_scenarios()["multiple adverse events"])

Symbolic analysis (sympy):

from rsmodel.analysis import compute_jacobian, analyze_corner_equilibria

J = compute_jacobian(RSModel())                     # symbolic 2x2 Jacobian
analyze_corner_equilibria(RSModel(), e_value=0.5)   # stability of the four corners

RS2Model is the variant with the 3*s*r coupling term used for comparison in the paper.

Interactive notebooks

The repository ships three marimo notebooks — an interactive playground (also published at https://rsmodel.org), the full symbolic analysis, and a script that regenerates every figure in the manuscript. See https://github.com/bjoseru/rsmodel for details.

Citation

The manuscript is under review; until it is accepted, cite the arXiv preprint alongside the archived software:

@misc{rueffer_schoenlein_rsmodel_preprint,
  author        = {R{\"u}ffer, Bj{\"o}rn S. and Sch{\"o}nlein, Michael},
  title         = {A mathematical model for depression and resilience},
  year          = {2026},
  eprint        = {2608.22073},
  archivePrefix = {arXiv},
  url           = {https://arxiv.org/abs/2608.22073}
}
@misc{rueffer_schoenlein_rsmodel_software,
  author    = {R{\"u}ffer, Bj{\"o}rn S. and Sch{\"o}nlein, Michael},
  title     = {{rsmodel}: a resilience--symptom dynamical model of depression},
  year      = {2026},
  publisher = {Zenodo},
  doi       = {10.5281/zenodo.22018288},
  url       = {https://rsmodel.org}
}

License

MIT

Metadata

Release files for rsmodel 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rsmodel 0.1.5
File Size Uploaded
rsmodel-0.1.5.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rsmodel 0.1.5
File Interpreter ABI Platform
rsmodel-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 23.9 kB

Release files / rsmodel-0.1.5.tar.gz

Download URL rsmodel-0.1.5.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9676616b8dd6fb7a0459104853cb846c0852ea858e4c079cfa5618baa7bfbd08
BLAKE2b-256 checksum
How to use checksums
c3554e668d609386edd74580c5ab6c4beadb59ddb8e03a66a8c1752742fd2376
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rsmodel-0.1.5-py3-none-any.whl

Download URL rsmodel-0.1.5-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7722665fd7a188fd11d795ca2d1d7764bbf700a1409a0e8561c0f51c9ca7b704
BLAKE2b-256 checksum
How to use checksums
4daa2f3c979a2fedd6990b6f3368f160d9363ca56787b9c1a83c01a0b7f7606e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page