Table of Contents
Type: Statistical Analysis | Subject: Statistics (R) | Level: Masters | Word Count: ~3200 words
This model statistical analysis report was produced by an Essays UK specialist as reference material for learning purposes only. For support in this field, see our our R programming and statistics specialists.
A postgraduate quantitative methods module requires students to build, check and interpret a binary logistic regression model in R, using a de-identified hospital dataset (N = 420), to identify significant predictors of 30-day unplanned patient readmission and to critically evaluate the fitted model’s overall performance.
Unplanned hospital readmissions within 30 days of discharge are a well-established marker of care quality and a substantial cost pressure on the NHS, with NHS Digital (2023) reporting that emergency readmissions account for a significant share of secondary care activity in England each year. Predictive modelling using routinely collected administrative data offers clinicians, discharge planners and bed managers an evidence-based tool for identifying patients at elevated risk before they leave hospital, so that follow-up calls, community nursing referrals or a short delay to discharge can be targeted where they are most likely to be clinically useful.
Several statistical approaches exist for binary outcome prediction, including logistic regression, classification trees and more complex machine-learning classifiers such as random forests or gradient boosting. Logistic regression remains the most widely used and most interpretable method for this type of task in health services research, because each predictor’s independent contribution to risk can be expressed directly as an odds ratio, and because the resulting coefficients are transparent enough to be scrutinised and defended in a clinical governance setting rather than treated as a statistical “black box” (James et al., 2021).
This analysis uses R (R Core Team, 2023) to fit, check and interpret a binary logistic regression model predicting 30-day readmission from a retrospective, fully anonymised dataset of 420 medical admissions to a single NHS trust, released for teaching purposes with local information governance approval. The dependent variable, readmission_30d, is coded 0 (not readmitted) or 1 (readmitted within 30 days of the index discharge). Six candidate predictors were entered on the basis of prior literature and clinical plausibility: patient age, Charlson Comorbidity Index (CCI), the number of emergency admissions in the preceding 12 months, the length of the index stay, discharge destination, and patient gender.
The research question addressed is therefore: which patient- and admission-level factors significantly predict the odds of 30-day unplanned readmission, and how well does a logistic regression model incorporating these factors discriminate between patients who are and are not subsequently readmitted? All hypothesis tests are interpreted at the conventional α = .05 significance level, and effect sizes are reported as odds ratios with 95% confidence intervals throughout, in line with current reporting guidance for clinical prediction research (Hosmer, Lemeshow and Sturdivant, 2013).
The six candidate predictors were not chosen arbitrarily. Age, comorbidity burden and prior healthcare utilisation are the three factors most consistently reported across the international readmissions literature, while length of stay and discharge destination are routinely available at the point of discharge and therefore have direct operational value for a trust wishing to embed a risk score into existing discharge workflows without requiring additional data collection. Gender was retained as a demographic control variable rather than because strong prior evidence suggested an effect, allowing the analysis to report explicitly on whether it added meaningful predictive value once the clinically motivated predictors were accounted for. More complex classifiers, such as random forests or gradient-boosted trees, were considered but rejected for this particular analysis: with only 420 admissions, a flexible non-parametric model would carry a meaningful risk of overfitting, and the resulting predictions, however accurate on held-out data, would be far harder to explain to a multidisciplinary discharge planning meeting than a small set of interpretable odds ratios.
The dataset (readmit.csv) was imported into R with read.csv() and inspected using str(), summary() and skimr::skim() to confirm variable types, check plausible ranges and screen for coding errors before any modelling was attempted. Of the 420 index admissions, 118 (28.1%) resulted in an unplanned readmission within 30 days of discharge and 302 (71.9%) did not, giving a moderately imbalanced but adequately powered outcome for a logistic model with six predictors. Table 1 summarises the variables entered into the model, their measurement type and their coding scheme.
| Variable | Description | Type | Coding / Range |
|---|---|---|---|
| readmission_30d | Readmitted within 30 days of index discharge | Binary (outcome) | 0 = No, 1 = Yes |
| age | Patient age at admission | Continuous | Years, 18–94 |
| cci | Charlson Comorbidity Index score | Continuous | 0–10 |
| prior_admissions | Emergency admissions in previous 12 months | Count | 0–6 |
| los | Length of the index hospital stay | Continuous | Days, 1–34 |
| discharge_facility | Discharge destination | Binary | 0 = Home, 1 = Care/rehabilitation facility |
| gender | Patient gender | Binary | 0 = Female, 1 = Male |
No variable exceeded 3% missing data on inspection; the nine cases with a missing value on any modelled variable were excluded using listwise deletion, which is the default behaviour of R’s glm() function, leaving an analytic sample of 411 admissions carried forward into the model. Descriptive comparison of the two outcome groups was informative before modelling: patients who were readmitted had a higher mean CCI (M = 3.8, SD = 2.1) than those who were not (M = 2.4, SD = 1.7), a higher mean number of prior admissions (M = 1.9, SD = 1.4 versus M = 0.7, SD = 0.9), and a longer mean length of index stay (M = 8.9 days, SD = 5.6 versus M = 6.1 days, SD = 4.3). These unadjusted group differences motivate, but do not by themselves establish, the multivariable analysis reported below, since several of these variables are correlated with one another and with age.
No formal rebalancing technique, such as random oversampling of the minority (readmitted) class or synthetic minority oversampling (SMOTE), was applied before fitting the model. Although a 28.1% event rate is imbalanced enough to affect classification performance at the default cut-off, it is not so severe as to invalidate the coefficient estimates themselves, and rebalancing techniques can distort the estimated intercept and, in some implementations, bias the estimated odds ratios if applied uncritically; the approach taken here instead was to report the classification performance transparently at the natural cut-off and to discuss threshold adjustment separately in the conclusion, which is the more conservative and more easily audited choice in a clinical setting.
Logistic regression does not require the normality or homogeneity-of-variance assumptions associated with linear models, but it carries its own set of assumptions that were checked systematically before the final model was interpreted. First, with 118 readmission events and six predictors, the events-per-variable (EPV) ratio is approximately 19.7:1 (118 ÷ 6), comfortably exceeding the minimum of 10 events per variable recommended by Peduzzi et al. (1996) for stable, non-overfitted coefficient estimation, so the sample was judged adequate to support a six-predictor model.
Second, multicollinearity among the predictors was assessed using the variance inflation factor via car::vif(model) in R. Table 2 shows that all six predictors returned VIF values well below 1.4, far below the conservative threshold of 5 (and the more permissive threshold of 10) discussed by Tabachnick and Fidell (2019), indicating that multicollinearity was not a material concern in this dataset and that each coefficient can be interpreted as a reasonably independent effect.
| Predictor | Variance Inflation Factor (VIF) |
|---|---|
| Age | 1.08 |
| Charlson Comorbidity Index | 1.21 |
| Prior admissions (12 months) | 1.34 |
| Length of stay | 1.15 |
| Discharge to facility | 1.09 |
| Gender | 1.03 |
Third, the assumption of linearity in the logit for each continuous predictor was tested using the Box-Tidwell procedure, in which interaction terms between each continuous predictor and its natural logarithm were added to an auxiliary model. None of the four interaction terms reached statistical significance (age × ln(age), p = .312; CCI × ln(CCI), p = .184; prior admissions × ln(prior admissions), p = .247; length of stay × ln(length of stay), p = .398), supporting the assumption that each continuous predictor is linearly related to the log-odds of readmission across its observed range (Field, 2018).
Fourth, the assumption of independent observations was satisfied by design, since each row of the dataset represents one unique patient admission with no repeated-measures or clustering structure requiring a mixed-effects extension. Finally, influence diagnostics were run using cooks.distance(model) and rstandard(model) to check for individual cases exerting disproportionate leverage on the fitted coefficients. No case exceeded a Cook’s distance of 0.041, well below the conventional concern threshold of 1.0, and only three standardised residuals exceeded ±2 with none exceeding ±3, indicating that the fitted model was not being unduly driven by a small number of outlying or poorly fitted cases (Hosmer, Lemeshow and Sturdivant, 2013).
One further check specific to small-to-moderate sample logistic regression is complete or quasi-complete separation, which occurs when a predictor, or combination of predictors, perfectly or near-perfectly predicts the outcome and causes coefficient estimates to inflate towards implausibly large values with correspondingly enormous standard errors. Inspection of the coefficient table produced by summary(model) showed no such inflated coefficients or standard errors, and no warning of this kind was returned by R when the model was fitted, so separation was not judged to be a concern for this dataset. Together, these five checks indicate that the assumptions underlying the logistic regression model were reasonably well satisfied and that the coefficient estimates reported in the following section can be interpreted with a reasonable degree of confidence.
The final model was specified and fitted in R as follows:
model <- glm(readmission_30d ~ age + cci + prior_admissions + los + discharge_facility + gender, data = readmit, family = binomial(link = "logit")) summary(model)
Table 3 reports the summary(model) output: the unstandardised coefficient (b, the change in log-odds per unit of the predictor), its standard error, the Wald z statistic, the associated p-value, and the exponentiated coefficient (the odds ratio, OR) with its 95% confidence interval obtained via exp(cbind(OR = coef(model), confint(model))).
| Predictor | b | SE | z | p | OR | 95% CI |
|---|---|---|---|---|---|---|
| (Intercept) | −3.482 | 0.612 | −5.69 | < .001 | — | — |
| Age (years) | 0.021 | 0.009 | 2.33 | .020 | 1.02 | [1.00, 1.04] |
| Charlson Comorbidity Index | 0.284 | 0.071 | 4.00 | < .001 | 1.33 | [1.16, 1.53] |
| Prior admissions (12 months) | 0.512 | 0.104 | 4.92 | < .001 | 1.67 | [1.36, 2.05] |
| Length of stay (days) | 0.038 | 0.017 | 2.24 | .025 | 1.04 | [1.00, 1.08] |
| Discharge to facility (vs home) | 0.601 | 0.244 | 2.46 | .014 | 1.82 | [1.13, 2.94] |
| Male (vs female) | 0.112 | 0.221 | 0.51 | .612 | 1.12 | [0.72, 1.72] |
The overall model fit was assessed using several complementary statistics. The null deviance (intercept-only model) was 486.73 on 410 degrees of freedom, and the residual deviance of the full model was 428.61 on 404 degrees of freedom, giving a likelihood ratio test of χ²(6) = 58.12, p < .001, confirming that the six predictors jointly and significantly improved model fit relative to the null model. Nagelkerke’s pseudo-R² was .187 (McFadden’s pseudo-R² = .119), indicating that the model explains a modest-to-moderate share of the variance in readmission status, which is typical for models built from routinely collected administrative variables alone. The Hosmer-Lemeshow goodness-of-fit test, computed with ten risk deciles, returned χ²(8) = 6.42, p = .601; because this test is non-significant, it indicates that the model is well calibrated and that predicted probabilities do not systematically diverge from observed readmission rates across risk groups.
Table 4 presents the classification performance of the model at the default probability cut-off of .50.
| Observed | Predicted: No | Predicted: Yes | Total |
|---|---|---|---|
| Not readmitted | 270 | 26 | 296 |
| Readmitted | 67 | 48 | 115 |
| Total | 337 | 74 | 411 |
At this cut-off, overall classification accuracy was 77.4% ((270 + 48) / 411), sensitivity (the proportion of true readmissions correctly flagged) was 41.7% (48 / 115), and specificity (the proportion of non-readmissions correctly identified) was 91.2% (270 / 296). The area under the receiver operating characteristic curve, computed with the pROC package, was AUC = .74, 95% CI [.69, .79], which falls within the range that Hosmer, Lemeshow and Sturdivant (2013) describe as acceptable discrimination for a clinical prediction model built from routine data. Figure 1 summarises the adjusted odds ratios and confidence intervals for the five predictors that reached statistical significance in the final model.
Figure 1: Adjusted odds ratios and 95% confidence intervals for the five predictors reaching statistical significance in the final logistic regression model. The dashed vertical line marks OR = 1 (no effect).
It is worth noting the distinction between the likelihood ratio test reported for overall model fit and the individual Wald z tests reported for each coefficient in Table 3: the likelihood ratio test compares the fit of the full model against a restricted model and is generally regarded as the more reliable test for overall significance, whereas the Wald tests, although computationally convenient and standard practice for reporting individual predictors, can behave poorly when a coefficient or its standard error is very large (Field, 2018). No such instability was evident here, since none of the coefficients or standard errors in Table 3 were extreme, so the Wald-based p-values for individual predictors can be interpreted alongside the omnibus likelihood ratio test with reasonable confidence.
The overall model was statistically significant, χ²(6) = 58.12, p < .001, and meaningfully improved the classification of readmission status relative to the null model, although it explained only a modest share of outcome variance (Nagelkerke R² = .187). This is unsurprising and consistent with wider readmission modelling literature: readmission risk is multiply determined by clinical, social, behavioural and health-system factors, only some of which are captured in routinely coded administrative data of the kind used here.
Of the six predictors entered, five reached conventional statistical significance. The Charlson Comorbidity Index was the strongest clinical predictor of readmission, b = 0.284, SE = 0.071, z = 4.00, p < .001, OR = 1.33, 95% CI [1.16, 1.53]. Holding all other variables constant, each one-point increase in comorbidity burden was associated with a 33% increase in the odds of 30-day readmission. In practical terms, a patient with a CCI of 6 has approximately 2.4 times the odds of readmission of an otherwise identical patient with a CCI of 3 (1.33³ ≈ 2.4), underlining comorbidity burden as a primary target for discharge risk stratification tools.
Recent healthcare utilisation was the single strongest predictor overall: each additional emergency admission in the preceding 12 months increased the odds of a further 30-day readmission by 67%, b = 0.512, SE = 0.104, z = 4.92, p < .001, OR = 1.67, 95% CI [1.36, 2.05]. This finding is consistent with a well-established pattern in the readmissions literature whereby recent admission history is often a stronger predictor than any single diagnosis or comorbidity index (Hosmer, Lemeshow and Sturdivant, 2013), and it suggests that patients with two or more emergency admissions in the past year should be flagged automatically for enhanced discharge planning regardless of their presenting complaint.
Patients discharged to a care or rehabilitation facility rather than directly home had 82% higher odds of 30-day readmission than those discharged home, b = 0.601, SE = 0.244, z = 2.46, p = .014, OR = 1.82, 95% CI [1.13, 2.94]. Because discharge destination is also a proxy for underlying frailty and functional dependency that is not fully captured by the Charlson index, this effect should be interpreted as a marker of overall patient vulnerability rather than assumed to be a causal consequence of the discharge pathway itself.
Age was a statistically significant but clinically modest predictor, b = 0.021, SE = 0.009, z = 2.33, p = .020, OR = 1.02, 95% CI [1.00, 1.04]; each additional year of age increased the odds of readmission by only around 2%, equivalent to an odds ratio of roughly 1.23 for a ten-year age gap (1.02¹⁰). Its modest effect size once comorbidity and prior utilisation are controlled suggests that age itself is a weaker independent driver of readmission risk than the accumulated morbidity that tends to accompany it in older patients.
Longer index admissions were also associated with modestly higher readmission odds, b = 0.038, SE = 0.017, z = 2.24, p = .025, OR = 1.04, 95% CI [1.00, 1.08], equivalent to an approximately 8% increase in odds for each additional five days spent in hospital (1.04⁵ ≈ 1.22). This may reflect greater underlying clinical acuity among patients who stay longer rather than a direct causal pathway running from length of stay to readmission risk, and the two explanations cannot be fully disentangled with these cross-sectional administrative data alone.
Gender was not a statistically significant predictor once the other five variables were controlled, b = 0.112, SE = 0.221, z = 0.51, p = .612, OR = 1.12, 95% CI [0.72, 1.72], indicating no reliable difference in adjusted readmission risk between male and female patients in this sample after accounting for comorbidity, prior utilisation, length of stay, discharge destination and age.
Ranking the significant predictors by the magnitude of their adjusted odds ratios is useful for prioritising a discharge planning intervention within realistic staffing constraints: prior admissions (OR = 1.67) and discharge to a care facility (OR = 1.82) carry the largest per-unit effects, followed by comorbidity burden (OR = 1.33), with age (OR = 1.02) and length of stay (OR = 1.04) contributing comparatively small per-unit effects that nonetheless become clinically relevant across the wider range those variables can take in an individual patient. In practice, this ranking suggests that a discharge risk-screening tool built from this model would gain most of its discriminatory value from just three variables, comorbidity burden, prior admission history and discharge destination, with age and length of stay adding smaller, incremental refinements rather than independently driving the classification.
This analysis found that comorbidity burden, recent healthcare utilisation and discharge to a care or rehabilitation facility were the strongest independent predictors of 30-day unplanned readmission in this sample, with age and length of stay contributing smaller but still statistically significant effects, and gender showing no reliable independent association once the other variables were controlled. The final model showed acceptable discrimination (AUC = .74) and good calibration (a non-significant Hosmer-Lemeshow test), supporting its potential use as a first-pass screening tool for identifying patients who may benefit from enhanced discharge planning, provided its outputs are interpreted alongside, rather than instead of, clinical judgement.
Several limitations qualify these conclusions. The retrospective, single-centre design limits generalisability to trusts with a different patient case-mix, discharge pathways or community support infrastructure. Important potential confounders that were not available in this dataset, including social support, medication adherence, primary care access and deprivation, were therefore not tested and may partly explain the model’s modest explained variance. The class imbalance in the outcome (a 28.1% readmission rate) means that the default .50 probability cut-off favours specificity over sensitivity, as reflected in the relatively low sensitivity of 41.7% reported above; a lower cut-off, such as .30, would raise sensitivity at the cost of specificity and should be considered if the clinical priority is to avoid missing at-risk patients rather than to minimise false alarms.
Finally, because the data are cross-sectional and observational, none of the associations reported here can be interpreted causally, and the model has not yet been externally validated on an independent cohort or a different hospital site, which is a necessary next step before any consideration of deployment for real-world clinical decision support (James et al., 2021). Future work should prioritise external validation, explore a clinically appropriate classification threshold rather than the statistical default, and consider incorporating social and primary-care variables to improve discrimination beyond the current AUC of .74.
Field, A. (2018) Discovering Statistics Using IBM SPSS Statistics. 5th edn. London: Sage.
Hosmer, D.W., Lemeshow, S. and Sturdivant, R.X. (2013) Applied Logistic Regression. 3rd edn. Hoboken, NJ: Wiley.
James, G., Witten, D., Hastie, T. and Tibshirani, R. (2021) An Introduction to Statistical Learning with Applications in R. 2nd edn. New York: Springer.
NHS Digital (2023) Emergency Readmissions to Hospital within 30 Days of Discharge. Leeds: NHS Digital.
Peduzzi, P., Concato, J., Kemper, E., Holford, T.R. and Feinstein, A.R. (1996) ‘A simulation study of the number of events per variable in logistic regression analysis’, Journal of Clinical Epidemiology, 49(12), pp. 1373–1379.
R Core Team (2023) R: A Language and Environment for Statistical Computing. Vienna: R Foundation for Statistical Computing.
Tabachnick, B.G. and Fidell, L.S. (2019) Using Multivariate Statistics. 7th edn. Boston: Pearson.
Wickham, H. and Grolemund, G. (2017) R for Data Science. Sebastopol, CA: O’Reilly Media.
Need a Model Statistical Analysis Written to Your Exact Brief?
Our 350+ UK-qualified writers deliver referenced model documents from £15 per 250 words, with free plagiarism and AI-detection reports.
You May Also Like