simace.phenotyping¶
phenotype¶
simace.phenotyping.phenotype
¶
Phenotype simulation for two correlated traits.
Each trait is simulated by one of the four model families registered in
simace.phenotyping.models:
frailty— proportional hazards frailty (baseline hazards live insimace.phenotyping.hazards).cure_frailty— mixture cure model: threshold determines case status, frailty determines onset time among cases.adult— ADuLT age-dependent liability threshold.first_passage— inverse-Gaussian first-passage time.
Adding a new model is a single new file under
simace/phenotyping/models/ plus one entry in
simace/phenotyping/models/__init__.py's MODELS dict.
run_phenotype
¶
run_phenotype(pedigree, *, G_pheno, seed, standardize, phenotype_model1, phenotype_model2, beta1, beta_sex1, phenotype_params1, beta2, beta_sex2, phenotype_params2)
Simulate phenotype event times for two correlated traits.
Per-trait prevalence (for adult / cure_frailty) lives inside
phenotype_params{N}; frailty / first_passage do not carry one.
| PARAMETER | DESCRIPTION |
|---|---|
pedigree
|
DataFrame with
TYPE:
|
G_pheno
|
number of trailing generations to phenotype.
TYPE:
|
seed
|
RNG seed (trait 2 uses
TYPE:
|
standardize
|
global liability-standardization mode applied to
threshold-style consumers (
TYPE:
|
phenotype_model1
|
trait-1 model family (
TYPE:
|
phenotype_model2
|
trait-2 model family (same options).
TYPE:
|
beta1
|
trait-1 liability → log-hazard slope.
TYPE:
|
beta_sex1
|
trait-1 sex → log-hazard slope.
TYPE:
|
phenotype_params1
|
trait-1 model-specific parameter dict (e.g.
TYPE:
|
beta2
|
trait-2 liability → log-hazard slope.
TYPE:
|
beta_sex2
|
trait-2 sex → log-hazard slope.
TYPE:
|
phenotype_params2
|
trait-2 model-specific parameter dict.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
Phenotype DataFrame with columns |
DataFrame
|
plus the preserved pedigree columns. |
Source code in simace/phenotyping/phenotype.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
cli
¶
Command-line entry point for phenotype simulation.
Eager-registration scheme: every model's flag set is registered up
front so --help shows them all in clearly-labeled per-family
argument groups. Each model's from_cli rejects flags belonging to
a different family when invoked alongside that model's selection.
Source code in simace/phenotyping/phenotype.py
threshold¶
simace.phenotyping.threshold
¶
Liability threshold phenotype model for two correlated traits.
Converts liability to binary affected status using a probit threshold
derived from prevalence: threshold = ndtri(1 - K). Standardization
is controlled by the global standardize flag with three modes:
"global"(default) — z-score across the whole cohort once, then compare tondtri(1 - K). Preserves prevalence at K only when the cohort liability is already centered with unit variance."per_generation"— z-score within each generation independently before comparison; preserves K per generation regardless of how liability variance drifts across generations."none"— compare raw liability to the N(0,1)-scale threshold; realised prevalence drifts with the liability variance.
For sex-specific prevalence dicts ({"female": K_f, "male": K_m}),
liability is standardized once across both sexes (per the selected mode);
sex-shifted liability means therefore translate into sex-specific
realised prevalences within each generation.
No time-to-event or censoring -- purely binary outcome.
apply_threshold
¶
Apply liability threshold model per generation.
The threshold is ndtri(1 - K) where K is the prevalence. Liability
is standardized once according to standardize ("none", "global",
or "per_generation"); the per-generation comparison then uses the
already-standardized values. Bools accepted for back-compat
(True → "global", False → "none").
| PARAMETER | DESCRIPTION |
|---|---|
liability
|
array of liability values
TYPE:
|
generation
|
array of generation labels (same length as liability)
TYPE:
|
prevalence
|
fraction affected per generation — either a single float applied to all generations, or a dict mapping generation number to prevalence (e.g. {0: 0.05, 1: 0.08, 2: 0.10})
TYPE:
|
standardize
|
standardization mode for liability before thresholding
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
affected
|
boolean array (True = affected)
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
if any prevalence value is not in (0, 1), or if a dict is provided but is missing entries for observed generations |
Source code in simace/phenotyping/threshold.py
run_threshold
¶
Orchestrate threshold phenotype from pedigree and per-trait params.
Prevalence is extracted from the per-trait phenotype_params{N} dicts
(the canonical home for adult / cure_frailty model prevalence after PR3).
Traits whose primary model doesn't carry one (frailty / first_passage)
fall back to a documented default so the model-agnostic threshold path
still has a prevalence to use.
| PARAMETER | DESCRIPTION |
|---|---|
pedigree
|
DataFrame with pedigree data.
TYPE:
|
phenotype_params1
|
trait-1 model-specific param dict. Its
TYPE:
|
phenotype_params2
|
trait-2 model-specific param dict (same shape
options as
TYPE:
|
G_pheno
|
number of trailing generations to phenotype.
TYPE:
|
standardize
|
standardization mode for liability before thresholding;
one of
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
phenotype DataFrame |
Source code in simace/phenotyping/threshold.py
cli
¶
Command-line interface for threshold phenotype simulation.
Source code in simace/phenotyping/threshold.py
hazards¶
simace.phenotyping.hazards
¶
Baseline hazard registry for parametric survival models.
Each baseline hazard supplies a vectorized inverter that converts -log(U) draws (Exp(1)) and a liability array into event times under the proportional-hazards frailty model:
L = additive genetic + shared + unique liability
z = exp(scaled_beta * (L - mean))
S(t | z) = exp(-H0(t) * z)
t = H0^{-1}(-log(U) / z)
compute_event_times is the public dispatch over the registry. The numba
kernels and per-distribution wrappers stay module-private; consumers should
go through compute_event_times (or, for tooling that needs the dispatch
table itself, BASELINE_HAZARDS).
Supported distributions and required params keys:
"weibull" : {"scale": s, "rho": rho}
"exponential" : {"rate": lam} | {"scale": s}
"gompertz" : {"rate": b, "gamma": g}
"lognormal" : {"mu": mu, "sigma": sigma}
"loglogistic" : {"scale": alpha, "shape": k}
"gamma" : {"shape": k, "scale": theta}
validate_hazard_params
¶
Validate distribution name and required hazard_params keys.
Exponential accepts either rate or scale as the canonical key;
others must contain every key listed in BASELINE_PARAMS[distribution].
Source code in simace/phenotyping/hazards.py
add_hazard_cli_args
¶
Register --{name}-distribution{trait} + one flag per HAZARD_FLAG_ROOTS.
name is the kebab-form model name (e.g. "frailty", "cure-frailty").
Returns the argument group so callers can attach model-specific flags
(e.g. cure_frailty's --cure-frailty-prevalence{trait}).
Source code in simace/phenotyping/hazards.py
parse_hazard_cli
¶
Pull hazard-distribution + per-param values from argparse Namespace.
name is the kebab-form model name; the snake form is derived for attribute lookup.
Returns (distribution, hazard_params). Raises if the distribution flag is missing
or any required per-distribution param flag is unset.
Source code in simace/phenotyping/hazards.py
hazard_cli_flag_attrs
¶
Return the argparse attrs registered by add_hazard_cli_args.
Source code in simace/phenotyping/hazards.py
add_standardize_hazard_cli_arg
¶
Register --{name}-standardize-hazard{trait} flag.
The flag is namespaced per model so foreign-flag detection
(:func:check_no_foreign_flags) cleanly distinguishes overrides
intended for one model from those intended for another.
Source code in simace/phenotyping/hazards.py
standardize_hazard_cli_attr
¶
Return the argparse attribute name for the standardize_hazard CLI flag.
coerce_standardize_mode
¶
Resolve a user-supplied standardize value to one of the canonical modes.
Accepts the legacy bool form (True → "global", False → "none")
or one of the three string modes. Raises ValueError otherwise.
Source code in simace/phenotyping/hazards.py
resolve_hazard_mode
¶
Pick the mode used for hazard-step beta/L scaling.
standardize_hazard is the per-trait override stored inside
phenotype_params{N}. None means "inherit from the global
standardize flag". Bools accepted on either argument for the same
legacy reason as coerce_standardize_mode.
Source code in simace/phenotyping/hazards.py
standardize_liability
¶
Return liability transformed per mode.
Modes
"none"— returned unchanged."global"—(L - L.mean()) / L.std()across all rows."per_generation"— same z-score applied within each uniquegenerationvalue;generationmust be supplied.
A degenerate group (singleton or all-equal liability) gets
L - mean rather than NaN; the caller's downstream comparison
against an N(0,1) threshold then reduces to the centered raw value.
Source code in simace/phenotyping/hazards.py
standardize_beta
¶
Return per-individual (mean, scaled_beta) arrays of length n.
Modes
"none"—mean[i] = 0,scaled_beta[i] = betaeverywhere."global"—mean[i] = L.mean(),scaled_beta[i] = beta/L.std()broadcast to all rows (scaled_beta = 0when std is degenerate)."per_generation"— per individual filled from their generation's mean andbeta / std_g;generationmust be supplied.
Returning arrays (not scalars) lets callers slice mean[mask][0] /
scaled_beta[mask][0] inside an iter_generation_groups loop and
pass the per-group scalars to compute_event_times without branching.
Source code in simace/phenotyping/hazards.py
iter_generation_groups
¶
Yield boolean masks for the per-group loop pattern in model simulate().
Under "none" or "global" yields a single full-coverage mask, so
the caller's loop runs once over all rows. Under "per_generation"
yields one mask per unique value of generation.
Source code in simace/phenotyping/hazards.py
compute_event_times
¶
Convert -log(U) draws to event times under the named baseline hazard.
| PARAMETER | DESCRIPTION |
|---|---|
neg_log_u
|
-log(U) draws, U ~ Uniform(0, 1], shape (n,).
TYPE:
|
liability
|
quantitative liability, shape (n,).
TYPE:
|
mean
|
liability mean (used when standardize=True; pass 0.0 otherwise).
TYPE:
|
scaled_beta
|
liability coefficient on log-hazard (already divided by std if standardize=True).
TYPE:
|
distribution
|
baseline hazard name; one of
TYPE:
|
params
|
distribution-specific parameter dict; see
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ndarray
|
Event-time array, shape (n,), clamped to |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
unknown |
KeyError
|
missing required parameter for the selected distribution. |
Source code in simace/phenotyping/hazards.py
models¶
simace.phenotyping.models
¶
Phenotype model registry.
To add a new phenotype model:
- Write a new module under
simace/phenotyping/models/defining a class that subclassesPhenotypeModel(see_base.py). - Implement the abstract methods (
from_config,add_cli_args,from_cli,cli_flag_attrs,to_params_dict,simulate). - Import the class here and add it to the
MODELSdict below.
That's the entire surface — there is no auto-discovery and no decorator. The hand-authored dict is the single source of truth for which model names the dispatcher accepts.
PhenotypeModel
¶
Bases: ABC
Abstract base class for phenotype model families.
Subclasses are frozen dataclasses; their fields are the model's typed
parameters. Validation happens in __post_init__.
from_config
abstractmethod
classmethod
¶
Build an instance from the simulation parameter dict for trait trait_num.
add_cli_args
abstractmethod
classmethod
¶
Register this model's CLI flags on parser for the given trait.
from_cli
abstractmethod
classmethod
¶
Build an instance from parsed CLI args for the given trait.
Must raise ValueError (with trait context) if flags belonging
to another family are populated alongside this model's selection,
or if a required flag for this model is missing.
Source code in simace/phenotyping/models/_base.py
cli_flag_attrs
abstractmethod
classmethod
¶
Return the argparse attribute names this model owns for the given trait.
Used by sibling models' from_cli to detect foreign-flag conflicts.
Source code in simace/phenotyping/models/_base.py
to_params_dict
abstractmethod
¶
simulate
abstractmethod
¶
Simulate event times for one trait.
standardize is the global liability-standardization mode
("none" | "global" | "per_generation"); legacy True/False
bools are accepted via the same shim used at config-load.
Concrete subclasses route standardize differently:
- Threshold-style models (
threshold,adult.ltm) consume it directly to standardize liability before the threshold comparison. - Hazard-bearing models (
frailty,cure_frailty,first_passage,adult.cox) carry an additional per-trait fieldstandardize_hazard(defaulting toNone→ inherit) and resolve it via :func:simace.phenotyping.hazards.resolve_hazard_modefor the hazard step.cure_frailtyis the only model that honors both knobs (threshold step + hazard step).
Source code in simace/phenotyping/models/_base.py
AdultModel
dataclass
¶
AdultModel(method, prevalence, cip_x0=50.0, cip_k=0.2, beta=1.0, beta_sex=0.0, standardize_hazard=None)
Bases: PhenotypeModel
ADuLT phenotype model.
| PARAMETER | DESCRIPTION |
|---|---|
method
|
TYPE:
|
prevalence
|
case fraction K (scalar, per-generation, or sex-specific).
TYPE:
|
cip_x0
|
logistic CIP midpoint age (default 50.0).
TYPE:
|
cip_k
|
logistic CIP growth rate (default 0.2).
TYPE:
|
beta
|
liability scaling factor on the probit (ltm) or log-hazard (cox) scale (1.0 = no scaling).
TYPE:
|
beta_sex
|
sex coefficient (0.0 = no effect).
TYPE:
|
standardize_hazard
|
per-trait override for the hazard-step L
standardization mode under
TYPE:
|
CureFrailtyModel
dataclass
¶
CureFrailtyModel(distribution, prevalence, hazard_params=dict(), beta=1.0, beta_sex=0.0, standardize_hazard=None)
Bases: PhenotypeModel
Mixture cure-frailty model.
| PARAMETER | DESCRIPTION |
|---|---|
distribution
|
baseline hazard for cases (see
TYPE:
|
hazard_params
|
dict of distribution-specific parameter values.
TYPE:
|
prevalence
|
case fraction; scalar, per-generation dict, or sex-specific dict.
TYPE:
|
beta
|
coefficient on liability in the log-hazard among cases.
TYPE:
|
beta_sex
|
coefficient on sex in the log-hazard (0 = no effect).
TYPE:
|
standardize_hazard
|
per-trait override for the case-onset hazard step.
TYPE:
|
FirstPassageModel
dataclass
¶
Bases: PhenotypeModel
First-passage-time phenotype model.
| PARAMETER | DESCRIPTION |
|---|---|
drift
|
drift rate μ; must be non-zero. Negative drift → toward boundary (everyone onsets). Positive drift → emergent cure fraction.
TYPE:
|
shape
|
y0² (initial distance from boundary, squared).
TYPE:
|
beta
|
coefficient on liability for log(y0); positive β → worse.
TYPE:
|
beta_sex
|
coefficient on sex for log(y0) (0 = no effect).
TYPE:
|
FrailtyModel
dataclass
¶
Bases: PhenotypeModel
Frailty phenotype model.
| PARAMETER | DESCRIPTION |
|---|---|
distribution
|
baseline hazard name (see
TYPE:
|
hazard_params
|
dict of distribution-specific parameter values.
TYPE:
|
beta
|
coefficient on liability in the log-hazard.
TYPE:
|
beta_sex
|
coefficient on sex in the log-hazard (0 = no effect).
TYPE:
|
standardize_hazard
|
per-trait override for the hazard-step standardization
mode (
TYPE:
|
models.frailty¶
simace.phenotyping.models.frailty
¶
Proportional-hazards frailty phenotype model.
Per-individual onset time is drawn from a parametric baseline hazard modulated by an exp(beta * L) frailty multiplier. Liability translates into earlier onset for higher beta * L.
FrailtyModel
dataclass
¶
Bases: PhenotypeModel
Frailty phenotype model.
| PARAMETER | DESCRIPTION |
|---|---|
distribution
|
baseline hazard name (see
TYPE:
|
hazard_params
|
dict of distribution-specific parameter values.
TYPE:
|
beta
|
coefficient on liability in the log-hazard.
TYPE:
|
beta_sex
|
coefficient on sex in the log-hazard (0 = no effect).
TYPE:
|
standardize_hazard
|
per-trait override for the hazard-step standardization
mode (
TYPE:
|
models.cure_frailty¶
simace.phenotyping.models.cure_frailty
¶
Mixture cure-frailty phenotype model.
Liability above a threshold sets case status (WHO has the disease); a proportional hazards frailty model with a configurable baseline hazard determines onset time among cases (WHEN). Controls are censored at 1e6.
CureFrailtyModel
dataclass
¶
CureFrailtyModel(distribution, prevalence, hazard_params=dict(), beta=1.0, beta_sex=0.0, standardize_hazard=None)
Bases: PhenotypeModel
Mixture cure-frailty model.
| PARAMETER | DESCRIPTION |
|---|---|
distribution
|
baseline hazard for cases (see
TYPE:
|
hazard_params
|
dict of distribution-specific parameter values.
TYPE:
|
prevalence
|
case fraction; scalar, per-generation dict, or sex-specific dict.
TYPE:
|
beta
|
coefficient on liability in the log-hazard among cases.
TYPE:
|
beta_sex
|
coefficient on sex in the log-hazard (0 = no effect).
TYPE:
|
standardize_hazard
|
per-trait override for the case-onset hazard step.
TYPE:
|
models.adult¶
simace.phenotyping.models.adult
¶
ADuLT phenotype model.
Two sub-methods, selected by method:
ltm— liability threshold model: case status from raw liability vs. threshold; case onset age via logistic-CIP transform of the case CIR computed from a probit scaling of liability + sex.cox— Weibull(shape=2) proportional hazards: case status by rank/(N+1) capped at K; case onset age via logistic CIP inverse.
Both share the CIP shape parameters cip_x0 and cip_k. Reference:
Pedersen et al., Nat Commun 2023 (ADuLT).
Standardization routing is asymmetric across the two sub-methods:
method="ltm"is a threshold-on-liability model. It honors the globalstandardizeflag for the liability z-score and rejectsstandardize_hazardin its params.method="cox"is a hazard-on-liability model. It honorsstandardize_hazard(defaulting to the globalstandardizewhen unset) for the L scaling that feedsnp.exp(beta * L).
Toggling method therefore silently changes which knob controls L
scaling for that trait. The validation in __post_init__ surfaces this
in the error message when the field is set on an LTM-method instance.
AdultModel
dataclass
¶
AdultModel(method, prevalence, cip_x0=50.0, cip_k=0.2, beta=1.0, beta_sex=0.0, standardize_hazard=None)
Bases: PhenotypeModel
ADuLT phenotype model.
| PARAMETER | DESCRIPTION |
|---|---|
method
|
TYPE:
|
prevalence
|
case fraction K (scalar, per-generation, or sex-specific).
TYPE:
|
cip_x0
|
logistic CIP midpoint age (default 50.0).
TYPE:
|
cip_k
|
logistic CIP growth rate (default 0.2).
TYPE:
|
beta
|
liability scaling factor on the probit (ltm) or log-hazard (cox) scale (1.0 = no scaling).
TYPE:
|
beta_sex
|
sex coefficient (0.0 = no effect).
TYPE:
|
standardize_hazard
|
per-trait override for the hazard-step L
standardization mode under
TYPE:
|
models.first_passage¶
simace.phenotyping.models.first_passage
¶
First-passage time phenotype model.
A latent health process Y(t) = y0 + driftt + W(t) starts at y0 = sqrt(shape) * exp(-scaled_beta(L - mean) - beta_sexsex). Disease onset is the first time Y(t) ≤ 0. When drift < 0 the process hits the boundary in finite time (everyone eventually onsets); when drift > 0 an emergent cure fraction P(never hit) = 1 - exp(-2y0*drift) arises.
References
Lee & Whitmore 2006 (threshold regression). Aalen & Gjessing 2001 (first-passage models in survival).
FirstPassageModel
dataclass
¶
Bases: PhenotypeModel
First-passage-time phenotype model.
| PARAMETER | DESCRIPTION |
|---|---|
drift
|
drift rate μ; must be non-zero. Negative drift → toward boundary (everyone onsets). Positive drift → emergent cure fraction.
TYPE:
|
shape
|
y0² (initial distance from boundary, squared).
TYPE:
|
beta
|
coefficient on liability for log(y0); positive β → worse.
TYPE:
|
beta_sex
|
coefficient on sex for log(y0) (0 = no effect).
TYPE:
|
bimodal_phenotype (prototype)¶
simace.phenotyping._prototypes.bimodal_phenotype
¶
Bimodal phenotype models (prototype).
Three models that produce bimodal age-of-onset distributions
- mixture_cip: Two logistic CIP components, shared β
- mixture_cure_frailty: Two cure-frailty hazards, shared β
- two_threshold: Two liability thresholds with separate CIP per stratum
Standardization: each function accepts standardize as one of
"none", "global", or a legacy bool (True → "global",
False → "none"). "per_generation" is not supported here —
these prototypes do not take a generation array.
phenotype_mixture_cip
¶
phenotype_mixture_cip(liability, prevalence, beta=1.0, pi=0.5, cip_x0_1=10.0, cip_k_1=0.3, cip_x0_2=40.0, cip_k_2=0.2, seed=42, standardize='global', sex=None, beta_sex=0.0)
Mixture of two logistic CIP curves with shared liability threshold.
Each case is randomly assigned to component 1 (probability π) or component 2 (probability 1−π). Both components share the same prevalence K and liability scaling (β, β_sex), but have different CIP midpoints (x₀) and steepness (k), producing bimodal onset.
| PARAMETER | DESCRIPTION |
|---|---|
liability
|
quantitative liability, shape (n,)
TYPE:
|
prevalence
|
population prevalence K; scalar or per-individual array
TYPE:
|
beta
|
probit scaling factor for liability
TYPE:
|
pi
|
mixing weight for component 1 (0–1)
TYPE:
|
cip_x0_1
|
logistic CIP midpoint for component 1 (early)
TYPE:
|
cip_k_1
|
logistic CIP growth rate for component 1
TYPE:
|
cip_x0_2
|
logistic CIP midpoint for component 2 (late)
TYPE:
|
cip_k_2
|
logistic CIP growth rate for component 2
TYPE:
|
seed
|
random seed for component assignment
TYPE:
|
standardize
|
standardization mode for liability (
TYPE:
|
sex
|
binary sex covariate (0/1), shape (n,), or None
TYPE:
|
beta_sex
|
probit-scale coefficient for sex
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ndarray
|
Array of simulated event times, shape (n,) |
Source code in simace/phenotyping/_prototypes/bimodal_phenotype.py
phenotype_mixture_cure_frailty
¶
phenotype_mixture_cure_frailty(liability, prevalence, beta, pi, baseline, hazard_params_1, hazard_params_2, seed, standardize='global', sex=None, beta_sex=0.0)
Mixture of two cure-frailty components with shared threshold.
Cases (L > threshold) are randomly assigned to component 1 (prob π) or component 2 (prob 1−π). Each component has its own baseline hazard parameters, producing different onset timing distributions.
| PARAMETER | DESCRIPTION |
|---|---|
liability
|
quantitative liability, shape (n,)
TYPE:
|
prevalence
|
population prevalence K
TYPE:
|
beta
|
effect of liability on log-hazard among cases
TYPE:
|
pi
|
mixing weight for component 1
TYPE:
|
baseline
|
baseline hazard model name (shared)
TYPE:
|
hazard_params_1
|
hazard parameters for component 1
TYPE:
|
hazard_params_2
|
hazard parameters for component 2
TYPE:
|
seed
|
random seed
TYPE:
|
standardize
|
standardization mode for liability (
TYPE:
|
sex
|
binary sex covariate (0/1), shape (n,), or None
TYPE:
|
beta_sex
|
effect of sex on log-hazard
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ndarray
|
Array of simulated event times, shape (n,) |
Source code in simace/phenotyping/_prototypes/bimodal_phenotype.py
phenotype_two_threshold
¶
phenotype_two_threshold(liability, prevalence_early, prevalence_late, beta=1.0, cip_x0_1=10.0, cip_k_1=0.3, cip_x0_2=40.0, cip_k_2=0.2, seed=42, standardize='global', sex=None, beta_sex=0.0)
Two-threshold liability model with separate CIP per stratum.
High-liability individuals (L > τ₁) are early-onset cases mapped through CIP₁. Moderate-liability individuals (τ₂ < L ≤ τ₁) are late-onset cases mapped through CIP₂. This preserves a single liability dimension while producing bimodal age-of-onset.
| PARAMETER | DESCRIPTION |
|---|---|
liability
|
quantitative liability, shape (n,)
TYPE:
|
prevalence_early
|
K_early (fraction with L > τ₁)
TYPE:
|
prevalence_late
|
K_late (fraction with τ₂ < L ≤ τ₁); total prevalence = K_early + K_late
TYPE:
|
beta
|
probit scaling factor for liability
TYPE:
|
cip_x0_1
|
logistic CIP midpoint for early component
TYPE:
|
cip_k_1
|
logistic CIP growth rate for early component
TYPE:
|
cip_x0_2
|
logistic CIP midpoint for late component
TYPE:
|
cip_k_2
|
logistic CIP growth rate for late component
TYPE:
|
seed
|
unused (deterministic model)
TYPE:
|
standardize
|
standardization mode for liability (
TYPE:
|
sex
|
binary sex covariate (0/1), shape (n,), or None
TYPE:
|
beta_sex
|
probit-scale coefficient for sex
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ndarray
|
Array of simulated event times, shape (n,) |