LogNormalAFT<T>
Models & Types · AiDotNet.SurvivalAnalysis
Implements the Log-Normal Accelerated Failure Time (AFT) model for survival analysis.
Inheritance: SurvivalModelBase<T> → LogNormalAFT<T>
For Beginners
The Log-Normal AFT model assumes that the log of survival times follows a normal distribution. This is appropriate when survival times have a bell-curve shape after log-transformation, common in many biomedical and engineering applications.
How It Works
The Model: log(T) = β₀ + β₁X₁ + … + βₚXₚ + σε where ε ~ N(0,1) is standard normal.
Interpretation:
- exp(β) gives the multiplicative effect on median survival time
- A positive coefficient increases survival time (protective)
- A negative coefficient decreases survival time (harmful)
When to use Log-Normal vs Weibull:
- Log-Normal: Hazard first increases then decreases (non-monotonic)
- Weibull: Hazard is monotonic (increasing, decreasing, or constant)
Reference: Lawless (2003), Statistical Models and Methods for Lifetime Data
Example
// age and treatment arm per patient
var features = new Matrix<double>(new double[,]
{
{ 45, 1 }, { 52, 0 }, { 38, 1 }, { 61, 0 }, { 47, 1 }, { 55, 0 }
});
// months each patient was observed
var times = new Vector<double>(new double[] { 5.0, 12.0, 3.0, 18.0, 9.0, 21.0 });
// 1 = the event happened; 0 = censored, still fine when the study ended or lost to follow-up
var events = new Vector<int>(new int[] { 1, 0, 1, 0, 1, 1 });
var result = new AiModelBuilder<double, Matrix<double>, Vector<double>>()
.ConfigureModel(new LogNormalAFT<double>(maxIterations: 100, tolerance: 1e-6))
.Build(features, times, events);
var risk = result.Predict(features);
Constructors
| Constructor | Summary |
|---|---|
LogNormalAFT(int maxIterations, double tolerance) |
Creates a new Log-Normal AFT model. |
Properties
| Property | Summary |
|---|---|
T Intercept { get; set; } |
Gets the intercept term (β₀ = μ). |
T Scale { get; set; } |
Gets the scale parameter (σ). |
Vector<T> Coefficients { get; set; } |
Gets the regression coefficients (β). |
double Tolerance { get; } |
Gets the tolerance for convergence. |
int MaxIterations { get; } |
Gets the maximum iterations for optimization. |
Methods
| Method | Summary |
|---|---|
IFullModel<T, Matrix<T>, Vector<T>> WithParameters(Vector<T> parameters) |
|
Matrix<T> PredictSurvivalProbability(Matrix<T> x, Vector<T> times) |
Predicts survival probabilities at specified times. |
Vector<T> GetBaselineSurvival(Vector<T> times) |
Gets the baseline survival function. |
Vector<T> Predict(Matrix<T> input) |
Predicts median survival time. |
Vector<T> PredictHazardRatio(Matrix<T> x) |
Predicts acceleration factors (hazard ratios at baseline hazard). |