rTisanePy
Authoring generalized linear mixed effects models from conceptual models. Based on rTisane.
rTisanePy lets you:
- Declare variables and specify causal and relational assumptions
- Query for a statistical model from a conceptual model
- Automatically identify confounders (following Cinelli, Forney & Pearl, 2022)
- Infer random effects from nesting and repeated measures
- Select candidate family/link functions based on DV type
Installation
pip install rtisanepy
For development:
pip install -e ".[dev]"
Requires Python 3.10+ and networkx.
Quick Start
from rtisanepy import (
Unit, continuous, categories,
causes, equals, increases,
ConceptualModel,
)
# Declare variables
student = Unit("student", cardinality=100)
classroom = Unit("classroom", cardinality=10)
student = Unit("student", cardinality=100, nests_within=classroom)
tutoring = categories(unit=student, name="Tutoring", cardinality=2)
ses = categories(unit=student, name="SES", order=["lower", "middle", "upper"])
test_score = continuous(unit=student, name="TestScore")
# Build a conceptual model
cm = (
ConceptualModel()
.assume(causes(ses, test_score))
.assume(causes(ses, tutoring))
.hypothesize(causes(tutoring, test_score,
when=equals(tutoring, "in-person"),
then=increases(test_score)))
)
# Query for a statistical model
model = cm.query(iv=tutoring, dv=test_score)
print(model.formula()) # TestScore ~ Tutoring + SES + (1 | classroom)
print(model.family) # Inverse Gaussian
print(model.main_effects) # ['Tutoring', 'SES']
print(model.random_effects) # [RandomIntercept(group=classroom)]
# Override family/link
model2 = model.with_family("Gaussian", link="identity")
API Overview
Variables
| Constructor | Description |
|---|---|
Unit(name, cardinality, nests_within=None) |
Entity (participant, subject) |
Participant(name, cardinality, nests_within=None) |
Alias for Unit |
Time(name, order=None, cardinality=0) |
Time variable |
continuous(unit, name, number_of_instances=1) |
Continuous measure |
counts(unit, name, number_of_instances=1) |
Count measure |
categories(unit, name, *, cardinality=None, order=None) |
Categorical measure (ordered if order given) |
Relationships
| Function | Description |
|---|---|
causes(cause, effect, *, when=None, then=None) |
Directed causal relationship |
relates(lhs, rhs, *, when=None, then=None) |
Undirected (ambiguous) relationship |
nests(base, group) |
Nesting relationship between units |
Comparisons (for when/then annotations)
| Function | Description |
|---|---|
equals(variable, value) |
Variable equals a value |
not_equals(variable, value) |
Variable does not equal a value |
increases(variable) |
Variable increases |
decreases(variable) |
Variable decreases |
ConceptualModel
cm = ConceptualModel()
cm.assume(relationship) # Add assumed relationship (returns self)
cm.hypothesize(relationship) # Add hypothesized relationship (returns self)
cm.interacts(*vars, dv=dv) # Add interaction annotation (returns self)
cm.query(iv=iv, dv=dv) # Infer a StatisticalModel
At least one hypothesized relationship connecting iv and dv is required to query.
StatisticalModel
| Attribute / Method | Description |
|---|---|
.formula() |
R-style formula string |
.main_effects |
List of main effect variable names |
.interaction_effects |
List of interaction terms |
.random_effects |
List of RandomIntercept / RandomSlope |
.family |
Selected family function |
.link |
Selected link function |
.family_candidates |
All candidate family/link pairs |
.summary() |
Machine-readable dict |
.with_family(family, link=None) |
Copy with overridden family/link |
Running Tests
python -m pytest tests/ -v
Citation
If you use rTisanePy in your research, please cite:
@software{rtisanepy,
author = {Eunice Jun},
title = {rTisanePy: A Python Tool for Authoring Statistical Models from Conceptual Models},
url = {https://github.com/emjun/rTisanePy},
year = {2026}
}
References
- Eunice Jun, Edward Misback, Jeffrey Heer, and René Just. 2024. rTisane: Externalizing Conceptual Models for Data Analysis Prompts Reconsideration of Domain Assumptions and Facilitates Statistical Modeling. CHI 2024.
- Eunice Jun, Audrey Seo, Jeffrey Heer, and René Just. 2022. Tisane: Authoring Statistical Models via Formal Reasoning from Conceptual and Data Relationships. CHI 2022.
- Carlos Cinelli, Andrew Forney, and Judea Pearl. 2022. A Crash Course in Good and Bad Controls. Sociological Methods & Research.
Metadata
Release files for rtisanepy 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rtisanepy-0.1.1.tar.gz | 17.4 kB | Without provenance | Details for rtisanepy-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rtisanepy-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for rtisanepy-0.1.1-py3-none-any.whl |
Total release size: 32.8 kB
Release files / rtisanepy-0.1.1.tar.gz
| Download URL | rtisanepy-0.1.1.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e33f0a5034b6d1900a51d9b4d55b4680e04816f7d2e4e56ebcd2faeb6e9fd4c8
|
|
BLAKE2b-256 checksum How to use checksums |
5a3ebcd925e70bc16d718362db33e55f6e1fcf7c2146d4e2afcbebaf07d245a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.0
|
Release files / rtisanepy-0.1.1-py3-none-any.whl
| Download URL | rtisanepy-0.1.1-py3-none-any.whl |
|---|---|
| Size | 15.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf368617d372c39c74359c1de4508da238c958817df23450e8fe7687fa6e35fa
|
|
BLAKE2b-256 checksum How to use checksums |
ec99cfd915055115585ee05328fdd32e186fb5923735584f7c4cba2ff61569af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.0
|
Security for rtisanepy 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.