All Projects → nhs-r-community → FunnelPlotR

nhs-r-community / FunnelPlotR

Licence: Unknown, MIT licenses found Licenses found Unknown LICENSE MIT LICENSE.md
Funnel plots for comparing institutional performance, with overdispersion adjustment

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to FunnelPlotR

metallicaRt
R package of colour palettes based on Metallica studio album covers.
Stars: ✭ 18 (-53.85%)
Mutual labels:  ggplot2
Manu
This package provides colour palettes derived from birds native to New Zealand
Stars: ✭ 70 (+79.49%)
Mutual labels:  ggplot2
ggQC
ggQC
Stars: ✭ 43 (+10.26%)
Mutual labels:  ggplot2
emojifont
🍭Emoji and fontawesom in both base and ggplot2 graphics
Stars: ✭ 61 (+56.41%)
Mutual labels:  ggplot2
compbench
⌛ Benchmark and visualization of various compression algorithms
Stars: ✭ 21 (-46.15%)
Mutual labels:  ggplot2
value-investing-studies
Data Analysis Studies on Value Investing
Stars: ✭ 66 (+69.23%)
Mutual labels:  ggplot2
hockeystick
Download and Visualize Essential Global Heating Data in R
Stars: ✭ 42 (+7.69%)
Mutual labels:  ggplot2
ggbg
Miscellaneous Ggplot2 Extensions
Stars: ✭ 21 (-46.15%)
Mutual labels:  ggplot2
PlotsOfData
Shiny App for comparison of samples
Stars: ✭ 47 (+20.51%)
Mutual labels:  ggplot2
gameofthrones
🎨 Game of Thrones inspired palette for R
Stars: ✭ 69 (+76.92%)
Mutual labels:  ggplot2
sportyR
R package for drawing regulation playing surfaces for several sports
Stars: ✭ 84 (+115.38%)
Mutual labels:  ggplot2
grcdr
A collection of ggplot2 extensions and scripts for graphics in R
Stars: ✭ 14 (-64.1%)
Mutual labels:  ggplot2
r-whatsapp-analysis-parte1
Análisis de texto y visualización de datos con R, de conversaciones de WhatsApp, primer parte. Uso de librería rwhatsapp.
Stars: ✭ 22 (-43.59%)
Mutual labels:  ggplot2
kushner eb5 census
Jared Kushner and his partners used a program meant for job-starved areas to build a luxury skyscraper
Stars: ✭ 49 (+25.64%)
Mutual labels:  ggplot2
stmprinter
Print multiple stm model dashboards to a pdf file for inspection
Stars: ✭ 34 (-12.82%)
Mutual labels:  ggplot2
30DayMapChallenge
My contributions to the #30DayMapChallenge 2019, a daily challenge focusing on spatial visualizations happening throughout November.
Stars: ✭ 170 (+335.9%)
Mutual labels:  ggplot2
gganonymize
Anonymize the labels and text in a ggplot2
Stars: ✭ 42 (+7.69%)
Mutual labels:  ggplot2
ggHoriPlot
A user-friendly, highly customizable R package for building horizon plots in ggplot2
Stars: ✭ 115 (+194.87%)
Mutual labels:  ggplot2
NBA-Shot-Charts
Create NBA shot charts using data scrapped from stats.nba.com and R package ggplot2.
Stars: ✭ 33 (-15.38%)
Mutual labels:  ggplot2
PlotTwist
PlotTwist - a web app for plotting and annotating time-series data
Stars: ✭ 21 (-46.15%)
Mutual labels:  ggplot2

Funnel Plots for Comparing Institutional Performance

Project Status: Active – The project has reached a stable, usable state and is being actively developed. CRAN version Codecov test coverage R-CMD-check

Funnel Plots

This package is the newer version of the older CMFunnels package. Development work will focus on this package from now on.

This is an implementation of the funnel plot processes, and overdispersion methods described in:
Statistical methods for healthcare regulation: rating, screening and surveillance. Spiegelhalter et al (2012)
Funnel plots for comparing institutional performance. Spiegelhalter (2005)
Handling over-dispersion of performance indicators. Spiegelhalter (2005)

It draws funnel plots using ggplot2 and allows users to specify whether they want to adjust the funnel plot limits for ‘overdispersion.’ This adjustment makes the assumption that we are dealing with clusters of values (means) at institutions that are themselves arranged around a global mean. We then have ‘within’ institution variation and ‘between institution’ variation. The process assessed the expected variance in our data, and where it is greater than that expected by the Poisson distribution, uses the difference as a scaling factor. It is then used in an additive fashion, after an adjustment for outliers by either Winsorised or truncated (with a default 10% at each end of the distribution.)

Methods are based on those presented in Spiegelhalter’s papers and the Care Quality Commission’s Intelligent Monitoring methodology documents, with methods for proportions, ratios of counts and indirectly standardised ratios. There is a also a variant method for standardised ratios, used in the NHS’ Summary Hospital Mortality Indicator’
Summary Hospital-level Mortality Indicator, NHS Digital, SHMI specification

This variant uses a log-transformation and truncation of the distribution for calculating overdispersion, whereas Spiegelhalter’s methods use a square-root and Winsorisation.

Contributions are welcome. Please note that the ‘FunnelPlotR’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

More information available at https://nhs-r-community.github.io/FunnelPlotR/

Installation

You can install from CRAN:

install.packages("FunnelPlotR")

You can install the development version directly from GitHub using the remotes (or devtools) package. Please be aware that, although I endeavour have help files up-to-date, this version may different from the one on CRAN. Please consult the help documentation if you get error messages.

remotes::install_github("https://github.com/nhs-r-community/FunnelPlotR")

Summary of Use

We will load the medpar dataset from Hilbe’s COUNT package. This is based on 1991 Medicare files for the state of Arizona (Hilbe, Joseph M (2014), Modeling Count Data, Cambridge University Press). We will first load the data and build a simple predictive model using a Poisson GLM.

library(FunnelPlotR)
library(COUNT)
library(ggplot2)

# lets use the 'medpar' dataset from the 'COUNT' package. Little reformatting needed
data(medpar)
medpar$provnum<-factor(medpar$provnum)
medpar$los<-as.numeric(medpar$los)

mod<- glm(los ~ hmo + died + age80 + factor(type), family="poisson", data=medpar)
summary(mod)
#> 
#> Call:
#> glm(formula = los ~ hmo + died + age80 + factor(type), family = "poisson", 
#>     data = medpar)
#> 
#> Deviance Residuals: 
#>     Min       1Q   Median       3Q      Max  
#> -5.7309  -1.9554  -0.5529   0.9717  14.5487  
#> 
#> Coefficients:
#>               Estimate Std. Error z value Pr(>|z|)    
#> (Intercept)    2.26875    0.01246 182.011  < 2e-16 ***
#> hmo           -0.07637    0.02393  -3.192  0.00142 ** 
#> died          -0.24574    0.01826 -13.458  < 2e-16 ***
#> age80         -0.02141    0.02050  -1.045  0.29617    
#> factor(type)2  0.24921    0.02099  11.871  < 2e-16 ***
#> factor(type)3  0.74869    0.02627  28.496  < 2e-16 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> (Dispersion parameter for poisson family taken to be 1)
#> 
#>     Null deviance: 8901.1  on 1494  degrees of freedom
#> Residual deviance: 7977.7  on 1489  degrees of freedom
#> AIC: 13705
#> 
#> Number of Fisher Scoring iterations: 5

Now we have a regression that we can use to get a predicted los that we will compare to observed los:

medpar$prds<- predict(mod, type="response")



We can build a funnel plot object with standard Poisson limits, and outliers labelled.

a<-funnel_plot(numerator=medpar$los, denominator=medpar$prds, group = medpar$provnum, 
            title = 'Length of Stay Funnel plot for `medpar` data', data_type="SR", limit=99,
            draw_unadjusted = TRUE, draw_adjusted = FALSE, label="outlier")
print(a)

#> A funnel plot object with 54 points of which 25 are outliers. 
#> Plot is not adjusted for overdispersion.



That looks like too many outliers! There is more variation in our data than we would expect, and this is referred to as: overdispersion. So lets check for it:
The following ratio should be 1 if our data are conforming to Poisson distribution assumption (conditional mean = variance). If it is greater than 1, we have overdispersion:

sum(mod$weights * mod$residuals^2)/mod$df.residual
#> [1] 6.240519

This suggest the variance is 6.24 times the condition mean, and definitely overdispersed. This is a huge topic, but applying overdispersed limits using either SHMI or Spiegelhalter methods adjust for this by inflating the limits:

b<-funnel_plot(numerator=medpar$los, denominator=medpar$prds, group = medpar$provnum, data_type = "SR",
            title = 'Length of Stay Funnel plot for `medpar` data', draw_unadjusted = FALSE,
            draw_adjusted = TRUE, sr_method = "SHMI", label="outlier", limit=99)

print(b)

#> A funnel plot object with 54 points of which 9 are outliers. 
#> Plot is adjusted for overdispersion.



These methods can be used for any similar indicators, e.g. standardised mortality ratios, readmissions etc.

Please read the package documentation for more info, at: https://nhs-r-community.github.io/FunnelPlotR/

Funnel Plot HEX sticker/logo by Paul Chipperfield, check him out at: https://themightychip.com/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].