PQStat PQStat User Guide Polski pqstat.pl

Comparing Cox PH regression models with random effect

When to use:

Model comparison serves to choose the set of independent variables, as in comparing Cox PH regression models: we compare a full model with a reduced model, or use automatic selection. The random effect (gamma frailty for the indicated grouping variable) is shared by all compared models – in each of them the variance \(\theta\) is re-estimated, but the group structure remains the same. Selection concerns the independent variables only; whether the random effect is needed is decided by the LR test \(\theta=0\) in the Cox regression with random effect report.

Definitions of measures

Models are compared on the basis of the integrated log-likelihood, the information criteria AIC, AICc, BIC (the smaller, the better) and the likelihood ratio test for nested models: \(2(\ell_{full}-\ell_{reduced})\) follows a \(\chi^2\) distribution with degrees of freedom equal to the number of removed variables.

Out-of-sample evaluation of models

The information criteria and the LR test are determined on the same data on which the models were fitted, which makes the assessment of the models too optimistic. As in comparing Cox PH regression models, the analysis window therefore makes it possible to evaluate the models on observations that did not take part in fitting them (the Validation option): \(k\)-fold cross-validation or a random test set, with the split determined by the Seed. For each model the report then gives \(-2\ln PL\) per event (the validation error; the lower, the better) and Harrell's concordance index C, and in the model selection block – the error of the null model (without variables) and the best model by validation; validation error can also be chosen as the automatic selection criterion. In models with a random effect two additional rules apply:

  • whole groups are split – all the observations of one group (e.g. one patient) go to the same part of the data. The number of folds \(k\) is limited to the number of groups, and the share of the test set means the percentage of groups (the split is not stratified by status here);
  • the prediction for a new group is based on the fixed effects only – the random effect of a group that was not in the training set is unknown, so its expected value is assumed (frailty \(=1\)).
Note! The hazard ratios in a model with a random effect are conditional – they compare observations with the same value of the random effect – and are usually stronger than the effects averaged over the population. Applied to a new group, for which frailty \(=1\) is assumed, they give predictions that are more extreme than the data would warrant, which the out-of-sample partial likelihood clearly „penalises”. With a large variance \(\theta\) and a small number of groups, the validation error of the models with variables may therefore be larger than the error of the null model, even though the variables are significant and Harrell's C clearly exceeds 0.5. Here the validation error serves primarily to compare the models with each other.

How to set up the analysis

Statistics \(\to\) Mixed models \(\to\) Cox PH regression with random effect – comparing models.

We indicate the survival time, the censored variable with the Failure events value, the variables of the full and reduced models (or the automatic selection criterion) and the Grouping variable (ID), shared by all models. Below the list of selection methods there are the fields: Criterion (AIC, AICc, BIC, p (LR / F test) with a threshold, or validation error), Validation (none, k-fold CV, k = with the number of folds, or test set, % = with the share of the test set as a percentage of the groups) and Seed of the random split (the same seed means the same split).

Results and interpretation

The report contains a fit table of the compared models (integrated log-likelihood, AIC, AICc, BIC, \(\theta\) of each model) with the LR test between them, and the coefficient tables of the models with conditional hazard ratios. When validation is switched on, the report additionally contains the Out-of-sample evaluation block (the method of splitting, the seed, the split unit, the error of the null model, the best model by validation), and for each model – \(-2\ln PL\) per event and Harrell's C.

Example 1. continuation of example 1 (kidneyCatheter.pqs file)
In the model of the risk of catheter infection, age turned out to be non-significant. We compare the full model (age and sex) with the reduced model (sex only); the patient random effect in both.

Full model: log-likelihood \(-182.05\), AIC \(=370.11\); model with sex only: \(-182.16\), AIC \(=368.33\). LR test: \(\chi^2=0.22\), \(df=1\), \(p=0.64\) – removing age does not worsen the fit, and the AIC of the simpler model is lower. We choose the model with sex only: \(HR=0.216\) (95% CI: 0.091–0.512), \(\theta=0.388\). For contrast, the model with age only has a log-likelihood of \(-187.86\) and AIC \(=379.72\), hardly better than the model without variables (\(-187.95\)): age alone contributes nothing.

LR test full vs without age: \(\chi^2=0.22\), \(p=0.64\); AIC \(370.11\) vs \(368.33\)
Age can be removed from the model; sex and the patient random effect remain.

Out-of-sample evaluation. We repeat the same comparison, choosing in the Validation field the k-fold CV, k = option with 10 folds (seed 12345). The 38 patients are split – both episodes of the same patient go to the same part of the data.

training setcross-validation (\(k=10\))
modelAIC\(-2\ln PL\) per eventHarrell's C
null8.2956
Model 1 (age, sex)370.118.53220.6723
Model 2 (sex)368.338.44580.6186

The model with sex only has a smaller validation error than the model with age and sex (8.4458 versus 8.5322) – the out-of-sample evaluation confirms that age can be removed. At the same time, the null model has the smallest error (8.2956), although sex is significant in the model and Harrell's C of both models (0.62–0.67) shows that they order new patients better than at random. This is the situation described in the note above: the effect of sex is conditional (strong: \(HR=0.216\) at \(\theta=0.388\)), the sample is small (38 patients, 3–4 in each evaluated part), and frailty \(=1\) is assumed for a new patient, which makes the predictions too extreme. This result does not undermine the importance of sex, but it is a reminder that the predictions of this model for new patients – without knowing their random effect – are uncertain.

cross-validation (\(k=10\), whole groups): \(-2\ln PL\) per event \(=8.53\) (age and sex), \(8.45\) (sex), \(8.30\) (null model)
Validation confirms the removal of age; with such a small sample, however, none of the models predicts the time to infection in new patients better than the null model.