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.22018288},
url = {https://rsmodel.org}
}
License
MIT
Metadata
Release files for rsmodel 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rsmodel-0.1.3.tar.gz | 10.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rsmodel-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.6 kB
Release files / rsmodel-0.1.3.tar.gz
| Download URL | rsmodel-0.1.3.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f370a2782f71079a9632afe066913095bb8c720341f0d6985b96a4121cf0059b
|
|
BLAKE2b-256 checksum How to use checksums |
227ab1c5f2948d03e964a13bc00c1983873cecc483292b935aaca6750282382a
|
| 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.3-py3-none-any.whl
| Download URL | rsmodel-0.1.3-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ee7503a31b799eaa2cf043b70ab4b4c4ee400980c8d52d707ac3b87e3fe0c429
|
|
BLAKE2b-256 checksum How to use checksums |
9b1735becb26157444454bc1ac97637064dc70ea09faf2e3ece95d95f6511d95
|
| 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}
|