| Title: | NHS Cancer Waiting-Time Analysis, Benchmarking and Multilevel Modelling |
|---|---|
| Description: | Provides tools for importing, harmonising, cleaning, analysing, benchmarking and visualising National Health Service (NHS) England Cancer Waiting Times data. The package supports national performance monitoring, provider-level benchmarking and cancer pathway comparisons through key performance indicator summaries, provider filtering, clustering analyses, mixed-effects regression models, variance decomposition, intraclass correlation coefficient estimation, adjusted provider performance estimation and sensitivity analyses. Functions are included for exploratory analysis, publication-ready visualisations and spreadsheet exports, supporting reproducible health services research, cancer services evaluation, quality improvement and assessment of waiting-time performance across healthcare organisations. |
| Authors: | Muhammad Zahir Khan [aut, cre] (ORCID: <https://orcid.org/0009-0005-7645-8960>) |
| Maintainer: | Muhammad Zahir Khan <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.1 |
| Built: | 2026-06-20 09:18:58 UTC |
| Source: | https://github.com/zerish12/nhscancerwaits |
Calculates the intraclass correlation coefficient from a fitted mixed-effects model.
calculate_icc(model)calculate_icc(model)
model |
A fitted mixed-effects model from |
A data frame with provider variance, residual variance, total variance and ICC.
Calculates the average silhouette score for provider clusters.
calculate_silhouette_score(clustered_data)calculate_silhouette_score(clustered_data)
clustered_data |
Data frame from |
Average silhouette score.
Returns standard model diagnostics using the performance package.
check_cwt_model(model)check_cwt_model(model)
model |
A fitted mixed-effects model. |
A model diagnostic object.
Standardises column names, provider fields, reporting dates, performance values and activity denominators.
clean_cwt_data(data)clean_cwt_data(data)
data |
A data frame of NHS Cancer Waiting-Time records. |
A cleaned data frame.
Groups providers into performance clusters using provider-level summaries.
cluster_providers( data, provider_var = "provider_code", performance_var = "performance_percent", activity_var = "total_treated", k = 3 )cluster_providers( data, provider_var = "provider_code", performance_var = "performance_percent", activity_var = "total_treated", k = 3 )
data |
A cleaned and filtered cancer waiting-time data frame. |
provider_var |
Provider column. Default is |
performance_var |
Performance percentage column. Default is |
activity_var |
Activity denominator column. Default is |
k |
Number of clusters. Default is |
A data frame containing provider summaries and cluster labels.
Exports one or more analysis tables to an Excel workbook.
export_excel_tables(tables, path = "nhscancerwaits_outputs.xlsx")export_excel_tables(tables, path = "nhscancerwaits_outputs.xlsx")
tables |
A named list of data frames. |
path |
Output Excel file path. Default is |
The output file path, invisibly.
Exports adjusted provider effects or provider ranking tables to Excel.
export_provider_rankings(provider_rankings, path = "provider_rankings.xlsx")export_provider_rankings(provider_rankings, path = "provider_rankings.xlsx")
provider_rankings |
A provider ranking data frame. |
path |
Output Excel file path. Default is |
The output file path, invisibly.
Extract Fixed Effects from Mixed Model
extract_model_effects(model)extract_model_effects(model)
model |
A fitted mixed-effects model. |
A data frame of fixed-effect estimates.
Extracts provider-specific random effects from a fitted mixed-effects model.
extract_provider_effects(model, provider_name = "provider_code")extract_provider_effects(model, provider_name = "provider_code")
model |
A fitted model from fit_cwt_mixed_model(). |
provider_name |
Name of provider grouping variable. |
A data frame of adjusted provider effects.
Keeps providers with sufficient activity, repeated observations and stable performance values.
filter_providers( data, provider_var = "provider_code", activity_var = "total_treated", performance_var = "performance_percent", min_mean_activity = 20, min_observations = 5, max_cv = 0.5 )filter_providers( data, provider_var = "provider_code", activity_var = "total_treated", performance_var = "performance_percent", min_mean_activity = 20, min_observations = 5, max_cv = 0.5 )
data |
A cleaned cancer waiting-time data frame. |
provider_var |
Provider code column. Default is |
activity_var |
Activity denominator column. Default is |
performance_var |
Performance percentage column. Default is |
min_mean_activity |
Minimum mean activity per provider. |
min_observations |
Minimum number of observations per provider. |
max_cv |
Maximum coefficient of variation. |
A filtered data frame.
Fits a random-intercept mixed-effects model with provider as the grouping variable.
fit_cwt_mixed_model( data, performance_var = "performance_percent", month_var = "month_index", pathway_var = "cancer_type", provider_var = "provider_code" )fit_cwt_mixed_model( data, performance_var = "performance_percent", month_var = "month_index", pathway_var = "cancer_type", provider_var = "provider_code" )
data |
A cleaned and filtered cancer waiting-time data frame. |
performance_var |
Outcome column. Default is |
month_var |
Month index column. Default is |
pathway_var |
Cancer pathway column. Default is |
provider_var |
Provider column. Default is |
A fitted lmerMod model object.
Reads one or more NHS Cancer Waiting-Time CSV files and combines them into a single data frame.
load_cwt_data(files)load_cwt_data(files)
files |
Character vector of CSV file paths. |
A data frame containing combined cancer waiting-time records.
Reads one or more NHS Cancer Waiting-Time Excel files and combines them into a single data frame.
load_cwt_excel(files, sheet = 1, .name_repair = "unique")load_cwt_excel(files, sheet = 1, .name_repair = "unique")
files |
Character vector of Excel file paths. |
sheet |
Sheet name or sheet number. Default is |
.name_repair |
Passed to |
A combined tibble with a source_file column.
Creates a provider-by-month performance table.
pivot_provider_months( data, provider_var = "provider_code", month_var = "reporting_date", performance_var = "performance_percent" )pivot_provider_months( data, provider_var = "provider_code", month_var = "reporting_date", performance_var = "performance_percent" )
data |
A cleaned cancer waiting-time data frame. |
provider_var |
Provider column. |
month_var |
Month column. |
performance_var |
Performance column. |
A wide provider-by-month table.
Creates a monthly performance trend plot.
plot_national_trends( data, month_var = "reporting_date", performance_var = "performance_percent", group_var = "standard" )plot_national_trends( data, month_var = "reporting_date", performance_var = "performance_percent", group_var = "standard" )
data |
A cleaned cancer waiting-time data frame. |
month_var |
Reporting date column. Default is |
performance_var |
Performance percentage column. Default is |
group_var |
Grouping column. Default is |
A ggplot object.
Creates a horizontal plot of adjusted predicted performance by cancer pathway.
plot_pathway_predictions( pathway_predictions, pathway_var = "cancer_type", prediction_var = "predicted_performance" )plot_pathway_predictions( pathway_predictions, pathway_var = "cancer_type", prediction_var = "predicted_performance" )
pathway_predictions |
Data frame from |
pathway_var |
Cancer pathway column. Default is |
prediction_var |
Predicted performance column. Default is |
A ggplot object.
Creates a scatter plot of provider clusters.
plot_provider_clusters(clustered_data)plot_provider_clusters(clustered_data)
clustered_data |
Data frame from |
A ggplot object.
Creates a ranked plot of adjusted provider effects.
plot_provider_effects( provider_effects, provider_var = "provider_code", effect_var = "adjusted_effect" )plot_provider_effects( provider_effects, provider_var = "provider_code", effect_var = "adjusted_effect" )
provider_effects |
Data frame from |
provider_var |
Provider column. Default is |
effect_var |
Adjusted effect column. Default is |
A ggplot object.
Generates adjusted predicted performance for each cancer pathway from a fitted mixed-effects model.
predict_pathway_performance( model, data, pathway_var = "cancer_type", month_var = "month_index", provider_var = "provider_code" )predict_pathway_performance( model, data, pathway_var = "cancer_type", month_var = "month_index", provider_var = "provider_code" )
model |
A fitted model from |
data |
The data frame used to fit the model. |
pathway_var |
Cancer pathway column. Default is |
month_var |
Month index column. Default is |
provider_var |
Provider column. Default is |
A data frame with adjusted predicted pathway performance.
Runs mixed-effects models across alternative provider-filtering thresholds. If a cohort is too small or a model fails, the function returns a row with status information rather than stopping.
run_sensitivity_analysis( data, cohorts = data.frame(cohort = c("Main cohort", "No outlier removal", "Stricter cohort"), min_mean_activity = c(20, 20, 30), min_observations = c(5, 5, 5), max_cv = c(0.5, 0.75, 0.5)), provider_var = "provider_code", activity_var = "total_treated", performance_var = "performance_percent", month_var = "month_index", pathway_var = "cancer_type", min_providers = 3, min_rows = 20 )run_sensitivity_analysis( data, cohorts = data.frame(cohort = c("Main cohort", "No outlier removal", "Stricter cohort"), min_mean_activity = c(20, 20, 30), min_observations = c(5, 5, 5), max_cv = c(0.5, 0.75, 0.5)), provider_var = "provider_code", activity_var = "total_treated", performance_var = "performance_percent", month_var = "month_index", pathway_var = "cancer_type", min_providers = 3, min_rows = 20 )
data |
A cleaned cancer waiting-time data frame. |
cohorts |
A data frame defining sensitivity cohorts. |
provider_var |
Provider column. Default is |
activity_var |
Activity denominator column. Default is |
performance_var |
Performance column. Default is |
month_var |
Month index column. Default is |
pathway_var |
Cancer pathway column. Default is |
min_providers |
Minimum number of providers required to fit a model. |
min_rows |
Minimum number of rows required to fit a model. |
A data frame summarising model results across cohorts.
Calculates summary statistics for cancer waiting-time performance.
summarise_kpis( data, group_var = "standard", performance_var = "performance_percent" )summarise_kpis( data, group_var = "standard", performance_var = "performance_percent" )
data |
A cleaned cancer waiting-time data frame. |
group_var |
Column used to group results. Default is |
performance_var |
Performance percentage column. Default is |
A summary data frame.
Summarise Cancer Pathway Performance
summarise_pathways( data, pathway_var = "cancer_type", performance_var = "performance_percent" )summarise_pathways( data, pathway_var = "cancer_type", performance_var = "performance_percent" )
data |
A cleaned cancer waiting-time data frame. |
pathway_var |
Cancer pathway column. |
performance_var |
Performance column. |
Pathway-level summary table.
Summarise Provider Performance
summarise_providers( data, provider_var = "provider_code", performance_var = "performance_percent", activity_var = "total_treated" )summarise_providers( data, provider_var = "provider_code", performance_var = "performance_percent", activity_var = "total_treated" )
data |
A cleaned cancer waiting-time data frame. |
provider_var |
Provider column. |
performance_var |
Performance column. |
activity_var |
Activity column. |
Provider-level summary table.