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

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

Built distribution (wheel)

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

Total release size: 23.6 kB

Release files / rsmodel-0.1.2.tar.gz

Download URL rsmodel-0.1.2.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
efbca5243c3dda04bc9dbd891654f4ff6e7907952cdd8e737635af2a1c291f5b
BLAKE2b-256 checksum
How to use checksums
5103a443249ca67d6883bb71b677d6073fdb9ac9d1c17789fdb5c1a63426b0cb
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.2-py3-none-any.whl

Download URL rsmodel-0.1.2-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ffd89cf1343574ced32b72b62fc827812d545c0ef8eee2af5ebe25104dba1c45
BLAKE2b-256 checksum
How to use checksums
a633fdd063213572441ae88fc1ea2098f4965993737cffe3ec9f9874905c71c0
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

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

This release

0.1.2 This release

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