FunnelPlotR
Funnel plots for comparing institutional performance, with overdispersion adjustment
Science Score: 49.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 7 DOI reference(s) in README -
○Academic publication links
-
✓Committers with academic emails
1 of 8 committers (12.5%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (17.1%) to scientific vocabulary
Keywords
funnel-plots
ggplot2
nhs-r-community
overdispersion
r
statistics
visualization
Last synced: 6 months ago
·
JSON representation
Repository
Funnel plots for comparing institutional performance, with overdispersion adjustment
Basic Info
- Host: GitHub
- Owner: nhs-r-community
- License: other
- Language: R
- Default Branch: main
- Homepage: https://nhs-r-community.github.io/FunnelPlotR/
- Size: 73.9 MB
Statistics
- Stars: 61
- Watchers: 4
- Forks: 13
- Open Issues: 4
- Releases: 10
Topics
funnel-plots
ggplot2
nhs-r-community
overdispersion
r
statistics
visualization
Created about 7 years ago
· Last pushed 6 months ago
Metadata Files
Readme
Changelog
License
Code of conduct
README.Rmd
---
output:
github_document:
html_preview: false
dev: png
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
fig.retina=3
)
```
# Funnel Plots for Comparing Institutional Performance
[](https://www.repostatus.org/#active/)
[](https://cran.r-project.org/package=FunnelPlotR)
[](https://cran.r-project.org/package=FunnelPlotR)
[](https://github.com/nhs-r-community/FunnelPlotR/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/nhs-r-community/FunnelPlotR)
## Funnel Plots
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)](https://doi.org/10.1111/j.1467-985X.2011.01010.x)
[Funnel plots for comparing institutional performance. Spiegelhalter (2005)](https://doi.org/10.1002/sim.1970)
[Handling over-dispersion of performance indicators. Spiegelhalter (2005)](https://dx.doi.org/10.1136/qshc.2005.013755)
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](https://digital.nhs.uk/data-and-information/publications/ci-hub/summary-hospital-level-mortality-indicator-shmi/)
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](https://nhs-r-community.github.io/FunnelPlotR/CODE_OF_CONDUCT.html).
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:
```{r install, eval=FALSE}
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.
```{r remotes, eval=FALSE}
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.
```{r data, warning=FALSE, message=FALSE}
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)
```
Now we have a regression that we can use to get a predicted `los` that we will compare to observed `los`:
```{r, prediction}
medpar$prds <- predict(mod, type="response")
```
We can build a funnel plot object with standard Poisson limits, and outliers labelled.
```{r fig.align='center', fig.retina=5, warning=FALSE, collapse=TRUE, funnel1, message=FALSE, eval=TRUE}
a <- funnel_plot(medpar, numerator = los, denominator = prds, group = 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)
```
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:
```{r, ODcheck, message=FALSE}
sum(mod$weights * mod$residuals^2)/mod$df.residual
```
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:
```{r, funnel2, message=FALSE, fig.align='center', fig.retina=5, collapse=TRUE, warning=FALSE, eval=TRUE}
b <- funnel_plot(medpar, numerator = los, denominator = prds, group = 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)
```
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
Owner
- Name: NHS-R Community
- Login: nhs-r-community
- Kind: organization
- Email: nhs.rcommunity@nhs.net
- Location: United Kingdon
- Website: https://nhsrcommunity.com
- Twitter: nhsrcommunity
- Repositories: 26
- Profile: https://github.com/nhs-r-community
A community for analysts and data scientists working in the UK's Health Sector and using R
GitHub Events
Total
- Issues event: 1
- Watch event: 2
- Delete event: 2
- Push event: 12
- Pull request review event: 2
- Pull request event: 4
- Fork event: 1
Last Year
- Issues event: 1
- Watch event: 2
- Delete event: 2
- Push event: 12
- Pull request review event: 2
- Pull request event: 4
- Fork event: 1
Committers
Last synced: over 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Chris Mainey | c****y@g****m | 272 |
| Andrew Johnson | a****n@p****u | 20 |
| Chris Mainey | c****y@n****t | 18 |
| Chris Mainey | c****1@n****t | 18 |
| Chris Mainey | 3****y | 10 |
| Alan Haynes | a****s | 2 |
| BassEngD | 5****D | 2 |
| Chris Mainey | c****y@u****k | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 27
- Total pull requests: 20
- Average time to close issues: about 2 months
- Average time to close pull requests: 6 days
- Total issue authors: 6
- Total pull request authors: 5
- Average comments per issue: 0.78
- Average comments per pull request: 0.6
- Merged pull requests: 20
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 2
- Average time to close issues: N/A
- Average time to close pull requests: 11 days
- Issue authors: 0
- Pull request authors: 2
- Average comments per issue: 0
- Average comments per pull request: 0.5
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- chrismainey (15)
- andrjohns (4)
- simonthelwall (3)
- CocklingH (3)
- aghaynes (1)
- StatsRhian (1)
- BassEngD (1)
Pull Request Authors
- chrismainey (17)
- teunbrand (2)
- andrjohns (1)
- StatsRhian (1)
- BassEngD (1)
- aghaynes (1)
Top Labels
Issue Labels
enhancement (2)
bug (1)
Pull Request Labels
bug (1)
enhancement (1)
Packages
- Total packages: 1
-
Total downloads:
- cran 618 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 11
- Total maintainers: 1
cran.r-project.org: FunnelPlotR
Funnel Plots for Comparing Institutional Performance
- Homepage: https://nhs-r-community.github.io/FunnelPlotR/
- Documentation: http://cran.r-project.org/web/packages/FunnelPlotR/FunnelPlotR.pdf
- License: MIT + file LICENSE
-
Latest release: 0.6.0
published 7 months ago
Rankings
Stargazers count: 7.8%
Forks count: 8.3%
Average: 23.1%
Dependent packages count: 29.8%
Downloads: 34.2%
Dependent repos count: 35.5%
Maintainers (1)
Last synced:
6 months ago
Dependencies
DESCRIPTION
cran
- dplyr * imports
- ggplot2 * imports
- ggrepel * imports
- scales * imports
- COUNT * suggests
- Cairo * suggests
- covr * suggests
- knitr * suggests
- rmarkdown * suggests
- testthat >= 3.0.0 suggests
- tidyr * suggests
.github/workflows/pkgdown.yaml
actions
- actions/cache v2 composite
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v3 composite
- actions/upload-artifact v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/R-CMD-check.yaml
actions
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/upload-artifact main composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
.github/workflows/rhub.yaml
actions
- r-hub/actions/checkout v1 composite
- r-hub/actions/platform-info v1 composite
- r-hub/actions/run-check v1 composite
- r-hub/actions/setup v1 composite
- r-hub/actions/setup-deps v1 composite
- r-hub/actions/setup-r v1 composite