Outcomes
models.Outcomes(data, *, effect='qaly', comparator=None)Probabilistic sensitivity analysis outcomes per intervention per iteration.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| data | pd.DataFrame | DataFrame indexed by a two-level MultiIndex named ("intervention", "iteration"), with a "cost" column and at least the primary effect column. Any additional numeric columns are carried along as disaggregated components. |
required |
| effect | str |
Name of the primary effect column (default "qaly"). |
'qaly' |
| comparator | str | None |
Name of the reference intervention (the PICOTS comparator), or None if no intervention was flagged is_comparator=True. heormodel.cea.ce_plane and heormodel.report.tornado_data fall back to this, then to the first intervention, when their own comparator argument is omitted. |
None |
Example
import pandas as pd from heormodel.models import Outcomes tidy = pd.DataFrame({ … “intervention”: [“A”, “A”, “B”, “B”], … “iteration”: [0, 1, 0, 1], … “cost”: [100.0, 110.0, 200.0, 190.0], … “qaly”: [1.0, 1.1, 1.4, 1.3], … }) out = Outcomes.from_tidy(tidy) out.interventions [‘A’, ‘B’] out.n_iterations 2
Attributes
| Name | Description |
|---|---|
| components | Names of disaggregated component columns beyond cost and primary effect. |
| interventions | Intervention names in first-appearance order. |
| iterations | The shared iteration index. |
| n_iterations | Number of iterations. |
Methods
| Name | Description |
|---|---|
| costs_wide | Costs as an (iterations x interventions) matrix. |
| effects_wide | An effect column as an (iterations x interventions) matrix. |
| from_tidy | Build from a tidy long table (the bring-your-own-outputs entry point). |
| from_wide | Build from two wide tables (iterations x interventions). |
| select | Subset to the given interventions, preserving the iteration index. |
| summary | Mean of every outcome column per intervention. |
costs_wide
models.Outcomes.costs_wide()Costs as an (iterations x interventions) matrix.
Example
import pandas as pd from heormodel.models import Outcomes c = pd.DataFrame({“A”: [1.0], “B”: [2.0]}) e = pd.DataFrame({“A”: [0.1], “B”: [0.2]}) Outcomes.from_wide(c, e).costs_wide().shape (1, 2)
effects_wide
models.Outcomes.effects_wide(column=None)An effect column as an (iterations x interventions) matrix.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| column | str | None |
Effect column name; defaults to the primary effect. | None |
from_tidy
models.Outcomes.from_tidy(
df,
*,
intervention='intervention',
iteration='iteration',
cost='cost',
effect='qaly',
comparator=None,
)Build from a tidy long table (the bring-your-own-outputs entry point).
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | Long table with one row per (intervention, iteration). | required |
| intervention | str |
Column in df holding the intervention label. |
'intervention' |
| iteration | str |
Column in df holding the iteration index. |
'iteration' |
| cost | str |
Column in df holding the cost per iteration. |
'cost' |
| effect | str |
Column in df holding the effect (QALYs by default). |
'qaly' |
| comparator | str | None |
Name of the reference intervention, or None. |
None |
Example
import pandas as pd from heormodel.models import Outcomes df = pd.DataFrame({“arm”: [“A”, “B”], “iter”: [0, 0], … “cost”: [1.0, 2.0], “qaly”: [0.5, 0.6]}) Outcomes.from_tidy(df, intervention=“arm”, iteration=“iter”).n_iterations 1
from_wide
models.Outcomes.from_wide(costs, effects, *, effect='qaly', comparator=None)Build from two wide tables (iterations x interventions).
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| costs | pd.DataFrame | Costs, one column per intervention, indexed by iteration. | required |
| effects | pd.DataFrame | Effects with identical shape/labels. | required |
| effect | str |
Name to give the effect column. | 'qaly' |
| comparator | str | None |
Name of the reference intervention, or None. |
None |
Example
import pandas as pd from heormodel.models import Outcomes c = pd.DataFrame({“A”: [1.0, 2.0], “B”: [3.0, 4.0]}) e = pd.DataFrame({“A”: [0.1, 0.2], “B”: [0.3, 0.4]}) Outcomes.from_wide(c, e).interventions [‘A’, ‘B’]
select
models.Outcomes.select(interventions)Subset to the given interventions, preserving the iteration index.
summary
models.Outcomes.summary()Mean of every outcome column per intervention.
Example
import pandas as pd from heormodel.models import Outcomes c = pd.DataFrame({“A”: [1.0, 3.0]}) e = pd.DataFrame({“A”: [0.1, 0.3]}) float(Outcomes.from_wide(c, e).summary()[“cost”][“A”]) 2.0