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.

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

Cite the paper and the archived software:

@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.XXXXXXX},
  url       = {https://rsmodel.org}
}

License

MIT

Metadata

Release files for rsmodel 0.1.0

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.0
File Size Uploaded
rsmodel-0.1.0.tar.gz 10.8 kB Details

Built distribution (wheel)

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

Total release size: 23.6 kB

Release files / rsmodel-0.1.0.tar.gz

Download URL rsmodel-0.1.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c322308a79fd00ea1c6380cfadb3c6309dbe3a0ffc79e12757d8f0112f893ea7
BLAKE2b-256 checksum
How to use checksums
7c22c0e535c54543e09b5868289d1b90aa5adfddb5bad956609c8f5806f9cae3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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

Download URL rsmodel-0.1.0-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5597adf6767f8c79519df3ea2df8b2525e5bf1eac57318a49867eb99c6a84c54
BLAKE2b-256 checksum
How to use checksums
3f572cf021bc2c0c48ad39b8af69c6b332d432925b3f5f5f009017ddd23c38e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.1.5

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

This release

0.1.0 This release

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