survival prediction
using the best encoded data to fit to our Lifelines WeibullAFT fitter.
Best Encoded Data
Based on the previous section, we will now create our model using the best encoded data using Leave-One-Out encoder. We will fit the data to our Weibull AFT fitter and below is the summary of fitting the model.
weibull aft fitter summary
Ancillary=True, penalizer=0.001,
Scale parameter (λ, lambda): This reflects the life expectancy of a component or system. It can be thought of as a measure of how long an item is expected to last before failure.
Shape parameter (ρ, rho): This describes the failure rate's behavior over time. If ρ > 1, the failure rate increases over time (typical of aging parts). If ρ < 1, the failure rate decreases over time, suggesting early failures are more common and the survivors have a lower rate of failure.
The central squares represent the point estimate of the log(accelerated failure rate) for each parameter in the Weibull model. In other words, they represent the multiplicative effect on the failure rate for each unit increase in the variable, when the effect is logged. For categorical variables, it's the effect of a particular category compared to the baseline.
The horizontal lines represent the 95% confidence intervals (CI) for these estimates. A wider line indicates more uncertainty in the estimate. If the line crosses the vertical dashed line (which represents a log(accelerated failure rate) of 0), it suggests that this particular effect is not statistically significant at the 95% confidence level.
SURVIVAL FUNCTION
Modelling ρρ: When ρρ is modelled as a function of covariates, it suggests that the shape of the survival curve can change with different levels of the covariates. This would mean that not only the scale or time to event changes with different covariate values, but also the nature of the risk over time. For instance, the risk of failure could be more constant over time for some temperatures and more variable for others.
Not modelling ρρ: When ρρ is not modelled (i.e., it is held constant across all levels of the covariates), it is assumed that the pattern of risk over time is the same for all groups, and only the scale or time to event changes. In this case, ρρ is assumed to be the same for all survival functions, so changes in covariates only shift the survival function along the timeline without changing its shape.
Understanding Encoded Variable Impact: It helps in understanding how the encoded categorical variables impact the shape of the survival function. By observing how the survival function changes with different levels of the categorical variables, we can interpret the relative risk associated with each level.
Model Complexity Insight: Including rho_ as a function of covariates adds complexity to the model. Observing the changes in rho_ can help in assessing whether this complexity is justified. If rho_ changes significantly across the levels of the categorical variables, this indicates that the shape of the hazard function varies, which justifies the added model complexity.
Risk Differentiation: By examining the impact on rho_, we can identify if different failure types or types have different risk patterns over time. For instance, one failure type may have an increasing risk over time, whereas another might have a constant risk.
Interaction Effects: It can reveal interaction effects between categorical variables and other covariates. If rho_ changes when considering another covariate, it suggests an interaction effect, which is important for understanding the dynamics of the risk factors involved.
Model Validation and Diagnostics: Comparing models with and without rho_ modelling can serve as a model diagnostic tool. If the inclusion of rho_ significantly alters the survival curves for different levels of a categorical variable, this could indicate that the proportional hazards assumption may not hold, and that a more complex model is needed.
Decision-Making: In practical applications, such as maintenance scheduling or medical treatment planning, knowing how different factors influence the survival function helps in making informed decisions. For example, if a certain failure type significantly decreases the survival probability, preventive actions can be prioritized for systems at risk of that particular failure.
Identifying At-Risk Groups: The graphs can help identify groups that are at higher risk over time, which can be crucial for risk management and resource allocation. If certain types or failure types lead to a much lower survival probability, we can focus our efforts on these at-risk groups.
cumulative hazard
As we focus on understanding how different covariates affect the time until an event of interest occurs, the cumulative hazard function, while more abstract than the survival function, is related to the probability of survival over time and provides insights into the risk dynamics of the subjects under study. We've taken samples from our original dataset and plotted the model with rho and without rho which shows the same behaviour of our survival function. The cumulative hazard function itself doesn't directly predict time to event; instead, it gives a measure of the expected risk accumulation over time.
WEIBULLAFT FITTER WITHOUT RHO
WEIBULLAFT FITTER WITH RHO
WEIBULLAFT FITTER WITH RHO APPLYING PENALTY (SURVIVAL & CUMULATIVE HAZARD)
The plot below compares the reaction of our model when applying penalty and can be used to fine-tune our model. Dashline(DF-2) indicates the model with penalty of 1e-4 and l1_ratio=0.10.
CHECKING THE BASELINE KM VS WEIBULL AFT FITTER
Early Convergence: The Weibull AFT model and the Kaplan-Meier estimate appear to be close to each other at the beginning of the timeline. This suggests that the Weibull model may be capturing the early risk period well.
Divergence Over Time: As time progresses, the Weibull AFT model survival function diverges from the Kaplan-Meier curve, staying relatively flat (near 1.0 survival probability) while the Kaplan-Meier curve shows a decline in survival probability. This divergence indicates that the Weibull AFT model may not be adequately capturing the risk of the event occurring as time increases.
Potential Overestimation of Survival: The Weibull AFT model seems to overestimate survival compared to the non-parametric Kaplan-Meier estimate, especially in the later time periods. This could be a sign that the model's assumptions are not fully consistent with the underlying data distribution or that the effect of covariates is not being captured accurately. This is proven when checking the content of the survival function dataframe by using this code:
# predict new survival function
wf.predict_survival_function(censored_subjects, conditional_after=censored_subjects_last_obs)
Aside from using AFT model, using a univariate parametric model, we tried to get the best model fit for our dataset and the most appropriate fitter is the piecewise exponential fitter. We then use the NelsonAalen fitter to plot the hazard rate against the best model which almost coincide with our data but gives us aggresive prediction of hazard rate approximately beyond 220 units.
PIECEWISE EXPONENTIAL FITTER WITH NelsonAalenFitter(Hazard Rate)
TESTING IF THE WEIBULL AFT FITTER IS FOR THIS DATASET
Weibull Q-Q Plot Analysis
The Weibull Q-Q plot provided should ideally show the empirical quantiles forming a straight line along the fitted Weibull quantiles if the data follows a Weibull distribution. In the plot, the points deviate significantly from the diagonal line, especially at the lower and higher ends of the data, indicating that the Weibull distribution may not be a good fit for our data.
Anderson-Darling Test Result
The Anderson-Darling test result shows a statistic of 110.897, which is considerably higher than the critical values at even the highest significance level listed. Since the test statistic is larger than the critical values, this suggests that we should reject the null hypothesis that the data comes from a Weibull distribution.
Kolmogorov-Smirnov Test Result
The Kolmogorov-Smirnov test gives us a KS statistic and a P-value. The KS statistic is quite high (0.8822), and the P-value is 0.0. A low P-value (typically below 0.05) indicates that the null hypothesis that the data comes from a Weibull distribution should be rejected.
Summary
Both the graphical method and the statistical tests suggest that the Weibull distribution may not be the best model for our data. The significant deviation in the Q-Q plot, along with the results from the Anderson-Darling and the Kolmogorov-Smirnov tests, strongly indicate a mismatch between the data and the Weibull distribution.
It is therefore recommended for this dataset to use the WeibullAFTFitter just to assess and mitigate the risk base on hazard and survival functions and not for prediction its remaining useful life. In this dataset, the Weibull functions can still be adapted in deep learning models but not for existing survival analysis models unless we create our custom regression model.
It is in this effect that Machine Learning (ML), Deep Learning(DL) and Ensemble Models have increasingly been applied and adapted to survival analysis, showcasing their ability to handle complex, multivariate datasets, including those with censoring and non-parametric distributions.