Model classes
This page documents a family of fully parametric survival models built on a shared general hazard (GH) structure,
\[h(t \mid {\bf x}) = h_0\!\left(t \exp\{\tilde{\bf x}^{\top}\alpha\};\, \theta\right) \exp\{{\bf x}^{\top}\beta\},\]
in which a baseline hazard $h_0(\cdot;\theta)$ is modulated on both the time scale (through $\tilde{\bf x}^{\top}\alpha$) and the hazard scale (through ${\bf x}^{\top}\beta$). The four hazard structures below differ only in which linear predictors enter the baseline: GeneralHazard is the general form, and ProportionalHazard, AcceleratedFaillureTime, and AcceleratedHazard constrain it. Each can be constructed directly from parameters or fitted from data via the fit interface (see Illustrative example). The baseline hazards that supply $h_0$ are listed on the next page; any continuous distribution complying with the Distributions.jl API can serve as $h_0$.
General Hazard
The GH model is formulated in terms of the hazard structure
\[h(t; \alpha, \beta, \theta, {\bf x}) = h_0\left(t \exp\{\tilde{\bf x}^{\top}\alpha\}; \theta\right) \exp\{{\bf x}^{\top}\beta\}.\]
where ${\bf x}\in{\mathbb R}^p$ are the covariates that affect the hazard level; $\tilde{\bf x} \in {\mathbb R}^q$ are the covariates that affect the time level (typically $\tilde{\bf x} \subset {\bf x}$); $\alpha \in {\mathbb R}^q$ and $\beta \in {\mathbb R}^p$ are the regression coefficients; and $\theta \in \Theta$ is the vector of parameters of the baseline hazard $h_0(\cdot)$.
This hazard structure leads to an identifiable model as long as the baseline hazard is not a hazard associated with a member of the Weibull family of distributions [5].
SurvivalModels.GeneralHazardModel — Type
GeneralHazardModel{Method, B}A flexible parametric survival model supporting Proportional Hazards (PH), Accelerated Failure Time (AFT), Accelerated Hazards (AH), and General Hazards (GH) structures.
Fields
T: Vector of observed times.Δ: Vector of event indicators (true if event, false if censored).baseline: Baseline distribution (e.g.,Weibull()).X1: Covariate matrix for the first linear predictor (e.g., PH/AFT).X2: Covariate matrix for the second linear predictor (e.g., AH/GH).α: Coefficient vector forX2.β: Coefficient vector forX1.
Construction
You can construct a model directly by providing all parameters:
model = GeneralHazardModel(
GHMethod(),
T, Δ, Weibull(1.0, 2.0),
X1, X2,
α, β
)or fit it from data using the fit interface.
Supported methods:
ProportionalHazard: For PH models.AcceleratedFaillureTime: For AFT models.AcceleratedHazard: For AH models.GeneralHazard: For full GH models.
SurvivalModels.GeneralHazard — Type
GeneralHazard(T, Δ, baseline, X1, X2)
fit(GeneralHazard, @formula(Surv(T, Δ) ~ x1 + x2), @formula(Surv(T, Δ) ~ z1 + z2), df)
fit(GeneralHazard, @formula(Surv(T, Δ) ~ x1 + x2), df)Fit a General Hazard (GH) model with a specified baseline distribution and covariates.
Hazard function
\[h(t \,|\, x, z) = h_0\left(t \exp(z^\top \alpha)\right) \exp(x^\top \beta)\]
Maximum likelihood estimation in General Hazards models using provided baseline distribution, provided hazard structure (through the method argument), provided design matrices..
Parameters T,Δ represent observed times and statuses, while X1, X2 should contain covariates. The number of columns in design matrices can be zero.
Hazard structures are defined by the method, which should be <:AbstractGHMethod, available possibilities are PHMethod(), AFTMethod(), AHMethod() and GHMethod().
The baseline distribution should be provided as a <:Distributions.ContinuousUnivariateDistribution object from Distributions.jl or compliant, e.g. from SurvivalDistributions.jl.
T: Vector of observed times.Δ: Vector of event indicators (1=event, 0=censored).baseline: Baseline distribution (e.g., Weibull()).X1,X2: Covariate matrices.
You can also use the fit() interface with:
- Two formulas (for
X1andX2): for full GH models. - One formula: for PH, AFT, or AH models (the unused matrix will be ignored).
Example: Direct usage
using SurvivalModels, Distributions, Optim
T = [2.0, 3.0, 4.0, 5.0, 8.0]
Δ = [1, 1, 0, 1, 0]
X1 = [1.0 2.0; 2.0 1.0; 3.0 1.0; 4.0 2.0; 5.0 1.0]
X2 = [1.0 0.0; 0.0 1.0; 1.0 1.0; 0.0 0.0; 1.0 1.0]
model = GeneralHazard(T, Δ, Weibull, X1, X2)Example: Using the fit() interface
using SurvivalModels, DataFrames, Distributions, Optim, StatsModels
df = DataFrame(time=T, status=Δ, x1=X1[:,1], x2=X1[:,2], z1=X2[:,1], z2=X2[:,2])
model = fit(GeneralHazard, @formula(Surv(time, status) ~ x1 + x2), @formula(Surv(time, status) ~ z1 + z2), df)
# Or for PH/AFT/AH models:
model_ph = fit(ProportionalHazard, @formula(Surv(time, status) ~ x1 + x2), df)References:
Proportional Hazards
The PH model is formulated in terms of the hazard structure
\[h(t; \beta, \theta, {\bf x}) = h_0\left(t ; \theta\right) \exp\{{\bf x}^{\top}\beta\}.\]
where ${\bf x}\in{\mathbb R}^p$ are the available covariates; $\beta \in {\mathbb R}^p$ are the regression coefficients; and $\theta \in \Theta$ is the vector of parameters of the baseline hazard $h_0(\cdot)$.
SurvivalModels.ProportionalHazard — Type
ProportionalHazard(T, Δ, baseline, X1, X2)
fit(ProportionalHazard, @formula(Surv(T, Δ) ~ x1 + x2), df)Fit a Proportional Hazards (PH) model with a specified baseline distribution and covariates.
Hazard function
\[h(t \,|\, x) = h_0(t) \exp(x^\top \beta)\]
T: Vector of observed times.Δ: Vector of event indicators (1=event, 0=censored).baseline: Baseline distribution (e.g., Weibull()).X1,X2: Covariate matrices (onlyX1is used in PH).
You can also use the fit() interface with a formula and DataFrame.
Accelerated Failure Time
The AFT model is formulated in terms of the hazard structure
\[h(t; \beta, \theta, {\bf x}) = h_0\left(t \exp\{{\bf x}^{\top}\beta\}; \theta\right) \exp\{{\bf x}^{\top}\beta\}.\]
where ${\bf x}\in{\mathbb R}^p$ are the available covariates; $\beta \in {\mathbb R}^p$ are the regression coefficients; and $\theta \in \Theta$ is the vector of parameters of the baseline hazard $h_0(\cdot)$.
SurvivalModels.AcceleratedFaillureTime — Type
AcceleratedFaillureTime(T, Δ, baseline, X1, X2)
fit(AcceleratedFaillureTime, @formula(Surv(T, Δ) ~ x1 + x2), df)Fit an Accelerated Failure Time (AFT) model with a specified baseline distribution and covariates.
Hazard function
\[h(t \,|\, x) = h_0\left(t \exp(x^\top \beta)\right) \exp(x^\top \beta)\]
T: Vector of observed times.Δ: Vector of event indicators (1=event, 0=censored).baseline: Baseline distribution (e.g., Weibull()).X1,X2: Covariate matrices (onlyX1is used in AFT).
You can also use the fit() interface with a formula and DataFrame.
Accelerated Hazards
The AH model is formulated in terms of the hazard structure
\[h(t; \alpha, \theta, \tilde{\bf x}) = h_0\left(t \exp\{\tilde{\bf x}^{\top}\alpha\}; \theta\right) .\]
where $\tilde{\bf x}\in{\mathbb R}^q$ are the available covariates; $\alpha \in {\mathbb R}^q$ are the regression coefficients; and $\theta \in \Theta$ is the vector of parameters of the baseline hazard $h_0(\cdot)$.
SurvivalModels.AcceleratedHazard — Type
AcceleratedHazard(T, Δ, baseline, X1, X2)
fit(AcceleratedHazard, @formula(Surv(T, Δ) ~ x1 + x2), df)Fit an Accelerated Hazard (AH) model with a specified baseline distribution and covariates.
Hazard function
\[h(t \,|\, z) = h_0\left(t \exp(z^\top \alpha)\right)\]
T: Vector of observed times.Δ: Vector of event indicators (1=event, 0=censored).baseline: Baseline distribution (e.g., Weibull()).X1,X2: Covariate matrices (onlyX2is used in AH).
You can also use the fit() interface with a formula and DataFrame.