QI Matrix

library(qiverse.qimatrix)
library(qiverse.data)

This package provides functions to prepare data ready for the SPC Funnel Matrix, and display this using flextable.

Prepare SPC Funnel Matrix

The data that feeds into the SPC Funnel Matrix visual requires preparation using the spc_funnel_matrix_prep_data function. This takes the following inputs:

  • indicator - A vector to denote the indicator group. Used to calculate aggregate SPC and Funnel Plots
  • group - A vector of group names. Used to aggregate and group points on plots
  • period_end - A date (or character of format “yyyy-mm-dd”) for the end date of the period.
  • period_start - A date (or character of format “yyyy-mm-dd”) for the start date of the period.
  • numerator - A vector of the numerator. Used to calculate the value for SPC and Funnel plots
  • denominator - A vector of the denominator Used to calculate the value for SPC and Funnel plots
  • multiplier - Scale relative risk and funnel by this factor.
  • better_is - A string identifying the direction that is favourable for the indicator. “Higher” for points below the lower control limit to be unfavourable, “Lower” for points above the upper control limit to be unfavourable, and “Neutral” if the direction is not stated.
  • parent_group_name - A vector of parent group names which are to be displayed in the tooltip. These are the major categories for the groups.
  • parent_indicator - A vector used for indicator grouping. i.e. grouping together maternity related indicators into a Maternity group.
  • spc_chart_type - A string identifying the type of spc chart.
  • funnel_chart_type - A string identifying the type of funnel plot.
  • indicator_name - A vector of descriptive names for indicator.
  • group_name - A vector of descriptive names for groups Default group variable
  • funnel_data_points - A vector of “Yes” or NA, marks which data points are included in the funnel plot calculation.

An example of this is shown below using the example_spc_data dataset:

head(example_spc_data)
#>                       indicator  group period_end period_start numerator
#>                          <char> <char>     <Date>       <Date>     <int>
#> 1: Standardised Mortality Ratio      A 2021-01-31   2021-01-01         6
#> 2: Standardised Mortality Ratio      A 2021-02-28   2021-02-01         4
#> 3: Standardised Mortality Ratio      A 2021-03-31   2021-03-01         4
#> 4: Standardised Mortality Ratio      A 2021-04-30   2021-04-01         4
#> 5: Standardised Mortality Ratio      A 2021-05-31   2021-05-01         8
#> 6: Standardised Mortality Ratio      A 2021-06-30   2021-06-01         4
#>    denominator multiplier better_is spc_chart_type funnel_chart_type
#>          <num>      <num>    <char>         <char>            <char>
#> 1:    4.379261        100     Lower              i                SR
#> 2:    3.778151        100     Lower              i                SR
#> 3:    4.398701        100     Lower              i                SR
#> 4:    4.913439        100     Lower              i                SR
#> 5:    4.950847        100     Lower              i                SR
#> 6:    3.115129        100     Lower              i                SR

The dataset is then passed to the spc_funnel_matrix_prep_data function to prepare the data for the SPC Funnel Matrix:

spc_funnel_matrix_data <- spc_funnel_matrix_prep_data(
  indicator = example_spc_data$indicator,
  group = example_spc_data$group,
  period_end = example_spc_data$period_end,
  period_start = example_spc_data$period_start,
  numerator = example_spc_data$numerator,
  denominator = example_spc_data$denominator,
  multiplier = example_spc_data$multiplier,
  better_is = example_spc_data$better_is,
  overdispersion = FALSE,
  parent_group_name = "All",
  parent_indicator = "All",
  spc_chart_type = example_spc_data$spc_chart_type,
  funnel_chart_type = example_spc_data$funnel_chart_type,
  funnel_data_points = "Yes"
)
#> Funnel Patterns Completed 
#> SPC Data Validated 
#> Start SPC Pattern Detection 
#> SPC Patterns Completed 
#> Funnel Patterns Completed 
#> SPC Data Validated 
#> Start SPC Pattern Detection 
#> SPC Patterns Completed

Charting SPC Funnel Matrix in Flextable

This package provides a function to plot the SPC Funnel Matrix output using flextable. An example of this is as follows:

spc_funnel_matrix_flextable(data = spc_funnel_matrix_data)
#> Warning in `[.data.table`(spans_dataset, runs_types_lst$is_raster == TRUE, :
#> Coercing 'list' RHS to 'character' to match the type of column 17 named 'txt'.

Better than Expected
(Favourable Funnel Plot Outlier)

Within Expectations
(Within Funnel Limits)

Worse than Expected
(Unfavourable Funnel Plot Outlier

character(0)

character(0)

character(0)

character(0)
Improving
(Favourable SPC Patterns)

Pressure Injury - B (ⓣ)

Caesarean Section - B (ⓣ)
Falls - D (ⓢ)
Falls - J (ⓢ)
Falls - L (ⓢ)
Pressure Injury - D (ⓢ)
Pressure Injury - G (ⓢ)
Pressure Injury - J (ⓢ)
Pressure Injury - L (ⓢ)
Standardised Mortality Ratio - H (≒,ⓢ)
Standardised Mortality Ratio - J (ⓢ)

Crude Mortality - I (≒,ⓢ)
Standardised Mortality Ratio - B (ⓢ)

character(0)
Staying the Same
(No SPC Patterns)

Crude Mortality - A
Crude Mortality - C
Crude Mortality - E
Crude Mortality - G
Crude Mortality - H
Crude Mortality - J
Falls - F
Staff Feel Safe To Speak Up - A
Staff Feel Safe To Speak Up - C
Standardised Mortality Ratio - F

There are 20 indicator and group combinations that have not displayed any SPC patterns or funnel plot outliers in the last twelve months

Crude Mortality - B
Crude Mortality - F
Pressure Injury - H
Staff Feel Safe To Speak Up - L
Standardised Mortality Ratio - D

character(0)
Deteriorating
(Unfavourable SPC Patterns

Crude Mortality - D (ⓣ)

Caesarean Section - C (ⓢ)
Falls - A (≒)
Falls - E (≒,⅔)
Falls - G (≒)
Falls - H (≒,⅔)
Pressure Injury - A (⅔)
Pressure Injury - C (ⓣ)
Pressure Injury - I (≒)
Staff Feel Safe To Speak Up - I (ⓣ)
Standardised Mortality Ratio - G (≒,⅔,ⓢ)
Standardised Mortality Ratio - L (≒)

Caesarean Section - F (ⓣ)
Crude Mortality - L (ⓣ)
Falls - C (ⓣ)
Staff Feel Safe To Speak Up - D (ⓣ)
Staff Feel Safe To Speak Up - E (ⓣ)
Standardised Mortality Ratio - E (≒,ⓢ)