Title: | Cumulative Sum (CUSUM) Charts for Monitoring of Hospital Performance |
---|---|
Description: | Provides functions for constructing and evaluating CUSUM charts and RA-CUSUM charts with focus on false signal probability. |
Authors: | Lena Hubig [aut, cre] |
Maintainer: | Lena Hubig <[email protected]> |
License: | GPL-2 |
Version: | 0.4.1 |
Built: | 2024-11-21 06:33:47 UTC |
Source: | CRAN |
This function calculates the CUSUM chart for the given sequence of successes and failures
calc_cusum(x, c0, cA)
calc_cusum(x, c0, cA)
x |
vector of outcomes |
c0 |
accepted failure probability |
cA |
smallest detectable failure probability |
Returns matrix of possible sequences
Calculate non-risk-adjusted CUSUM charts for performance data
Provides functions for constructing and evaluating CUSUM charts and RA-CUSUM charts with focus on false signal probability in health care processes.
cusum(failure_probability, patient_outcomes, limit, weights = NULL, odds_multiplier = 2, reset = TRUE)
cusum(failure_probability, patient_outcomes, limit, weights = NULL, odds_multiplier = 2, reset = TRUE)
failure_probability |
Double. Baseline failure probability |
patient_outcomes |
Integer. Vector of binary patient outcomes (0,1) |
limit |
Double. Control limit for signalling performance change |
weights |
Double. Optional vector of weights, if empty, standard CUSUM weights are calculated with weights_t |
odds_multiplier |
Double. Odds multiplier of adverse event under the alternative hypothesis (<1 looks for decreases) |
reset |
Logical. Reset the CUSUM after a signal to 0; defaults to TRUE |
Lena Hubig
# control limit can be obtained with cusum_limit_sim(), # here it is set to an arbitrary value (2.96) # CUSUM of in-control process # simulate patient outcomes set.seed(2046) patient_outcomes <- as.logical(rbinom(n = 100, size = 1, prob = 0.05)) cs_ic <- cusum( failure_probability = 0.05, patient_outcomes, limit = 2.96 ) # CUSUM of out-of-control process # simulate patient outcome set.seed(2046) patient_outcomes <- as.logical(rbinom(n = 100, size = 1, prob = 0.2)) cs_oc <- cusum( failure_probability = 0.05, patient_outcomes, limit = 2.96 )
# control limit can be obtained with cusum_limit_sim(), # here it is set to an arbitrary value (2.96) # CUSUM of in-control process # simulate patient outcomes set.seed(2046) patient_outcomes <- as.logical(rbinom(n = 100, size = 1, prob = 0.05)) cs_ic <- cusum( failure_probability = 0.05, patient_outcomes, limit = 2.96 ) # CUSUM of out-of-control process # simulate patient outcome set.seed(2046) patient_outcomes <- as.logical(rbinom(n = 100, size = 1, prob = 0.2)) cs_oc <- cusum( failure_probability = 0.05, patient_outcomes, limit = 2.96 )
Simulate false signal probability alpha given control limit for CUSUM charts
cusum_alpha_sim(failure_probability, n_patients, odds_multiplier, n_simulation, limit, seed = NULL)
cusum_alpha_sim(failure_probability, n_patients, odds_multiplier, n_simulation, limit, seed = NULL)
failure_probability |
Double. Baseline failure probability |
n_patients |
Integer. Number of patients in monitoring period /sample size |
odds_multiplier |
Double. Odds multiplier of adverse event under the alternative hypothesis (<1 looks for decreases) |
n_simulation |
Integer. Number of simulation runs |
limit |
Double. Control limit for signalling performance change |
seed |
Integer. Seed for RNG |
Returns False signal probability of specified CUSUM chart.
# # control limit can be obtained with cusum_limit_sim(), # here it is set to an arbitrary value (2.96) # simulate false positive probability of CUSUM cusum_alpha_sim( failure_probability = 0.05, n_patients = 100, odds_multiplier = 2, n_simulation = 10000, limit = 2.96, seed = 2046 )
# # control limit can be obtained with cusum_limit_sim(), # here it is set to an arbitrary value (2.96) # simulate false positive probability of CUSUM cusum_alpha_sim( failure_probability = 0.05, n_patients = 100, odds_multiplier = 2, n_simulation = 10000, limit = 2.96, seed = 2046 )
Generated performance data of indicator 17/1 54030: Preoperative stay over 24 hours for patients with proximal femur fracture.
cusum_example_data
cusum_example_data
A data frame with 2000 rows and 3 variables:
Sequence of observations
Patient outcome
Year of treatment
Patient outcomes were simulated based on average national failure rate. Two years are provided, so Phase I and Phase II can be defined.
Data for simulation was provided by Bavarian Agency of Quality Assurance (BAQ), Munich Germany.
Description of performance indicator (in German): https://iqtig.org/downloads/auswertung/2016/17n1hftfrak/QSKH_17n1-HUEFTFRAK_2016_QIDB_V02_2017-04-26.pdf
This function only works for very small sample sizes (<= 15), as it permutes through all possible outcome sequences and estimates the percentage of runs that reach a specific CUSUM values.
cusum_limit_exact(n_patients, failure_probability, odds_multiplier, alpha)
cusum_limit_exact(n_patients, failure_probability, odds_multiplier, alpha)
n_patients |
Integer. Number of patients in monitoring period /sample size |
failure_probability |
Double. Baseline failure probability |
odds_multiplier |
Double. Odds multiplier of adverse event under the alternative hypothesis (<1 looks for decreases) |
alpha |
Double. False signal probability of CUSUM |
Returns the control limit for signalling performance change for small sample sizes (double)
# calculate exact control limits for alpha = 0.05 cusum_limit_exact( failure_probability = 0.1, n_patients = 10, odds_multiplier = 2, alpha = 0.05 )
# calculate exact control limits for alpha = 0.05 cusum_limit_exact( failure_probability = 0.1, n_patients = 10, odds_multiplier = 2, alpha = 0.05 )
Simulate control limit given false signal probability alpha for CUSUM charts
cusum_limit_sim(failure_probability, n_patients, odds_multiplier, n_simulation, alpha, seed = NULL)
cusum_limit_sim(failure_probability, n_patients, odds_multiplier, n_simulation, alpha, seed = NULL)
failure_probability |
Double. Baseline failure probability |
n_patients |
Integer. Number of patients in monitoring period /sample size |
odds_multiplier |
Double. Odds multiplier of adverse event under the alternative hypothesis (<1 looks for decreases) |
n_simulation |
Integer. Number of simulation runs |
alpha |
Double. False signal probability of CUSUM |
seed |
Integer. Seed for RNG |
Returns the control limit for signalling performance change (double)
# simulate control limits for alpha = 0.05 cusum_limit_sim( failure_probability = 0.05, n_patients = 100, odds_multiplier = 2, n_simulation = 1000, alpha = 0.05, seed = 2046 )
# simulate control limits for alpha = 0.05 cusum_limit_sim( failure_probability = 0.05, n_patients = 100, odds_multiplier = 2, n_simulation = 1000, alpha = 0.05, seed = 2046 )
Calculate GSCUSUM chart for non-risk-adjusted processes.
gscusum(input_outcomes, failure_probability, odds_multiplier, limit, quantiles, max_num_shuffles = 10000L, seed = 0L)
gscusum(input_outcomes, failure_probability, odds_multiplier, limit, quantiles, max_num_shuffles = 10000L, seed = 0L)
input_outcomes |
Matrix. First column are binary patient outcomes (0,1). Second column are continuous sequence of block identifier. |
failure_probability |
Double. Baseline failure probability |
odds_multiplier |
Double. Odds multiplier of adverse event under the alternative hypothesis (<1 looks for decreases) |
limit |
Double. Control limit for signalling performance change |
quantiles |
Double. Vector of requested quantiles of GSCUSUM distribution |
max_num_shuffles |
Integer. Number of shuffles (i.e. different sequences of observations) |
seed |
Integer. Seed for RNG (if = 0 random seed is set (default)) |
gscusum matrix, signal probability, average CUSUM value and specified quantiles for every observation.
Generated performance data of indicator 17/1 54030: Preoperative stay over 24 hours for patients with proximal femur fracture.
gscusum_example_data
gscusum_example_data
A data frame with 2000 rows and 4 variables:
Sequence of observations
Patient outcome
Year of treatment
Continuous block identifier
Patient outcomes were simulated based on average national failure rate. Two years are provided, so Phase I and Phase II can be defined.
Data for simulation was provided by Bavarian Agency of Quality Assurance (BAQ), Munich Germany.
Description of performance indicator (in German): https://iqtig.org/downloads/auswertung/2016/17n1hftfrak/QSKH_17n1-HUEFTFRAK_2016_QIDB_V02_2017-04-26.pdf
creates all possible sequences of outcomes for a sample size
make_all_outcomes(npat_outcome)
make_all_outcomes(npat_outcome)
npat_outcome |
Number of patients (sample sizes) |
Returns matrix of possible sequences
Produces a CUSUM chart.
## S3 method for class 'cusum' plot(x, signal = TRUE, ...)
## S3 method for class 'cusum' plot(x, signal = TRUE, ...)
x |
An object of class cusum |
signal |
Logical. If TRUE, signals are plotted (default) |
Calculate risk-adjusted CUSUM charts for performance data
racusum(patient_risks, patient_outcomes, limit, weights = NULL, odds_multiplier = 2, reset = TRUE, limit_method = c("constant", "dynamic"))
racusum(patient_risks, patient_outcomes, limit, weights = NULL, odds_multiplier = 2, reset = TRUE, limit_method = c("constant", "dynamic"))
patient_risks |
Double. Vector of patient risk scores (individual risk of adverse event) |
patient_outcomes |
Integer. Vector of binary patient outcomes (0,1) |
limit |
Double. Control limit for signalling performance change |
weights |
Double. Optional vector of weights, if empty, standard CUSUM weights are calculated with weights_t |
odds_multiplier |
Double. Odds multiplier of adverse event under the alternative hypothesis (<1 looks for decreases) |
reset |
Logical. Reset the CUSUM after a signal to 0; defaults to TRUE |
limit_method |
"constant" or "dynamic" |
# Patients risks are usually known from Phase I. # If not, these risk scores can be simulated. # define possible patient risk scores risks <- c(0.001, 0.01, 0.1, 0.002, 0.02, 0.2) # sample risk population of size n = 100 set.seed(2046) patient_risks <- sample(x = risks, size = 100, replace = TRUE) # control limit can be obtained with racusum_limit_sim(), # here it is set to an arbitrary value (2.96), # or dynamic control limits with racusum_limit_dpcl() ##### RA-CUSUM of in-control process # simulate patient outcome for performace as expected set.seed(2046) patient_outcomes <- as.logical(rbinom( n = 100, size = 1, prob = patient_risks )) racusum(patient_risks, patient_outcomes, limit = 2.96 ) #### RA-CUSUM of out-of-control process # simulate patient outcome for deviating performance set.seed(2046) patient_outcomes <- as.logical(rbinom(n = 100, size = 1, prob = patient_risks * 2)) #' racusum(patient_risks, patient_outcomes, limit = 2.96 )
# Patients risks are usually known from Phase I. # If not, these risk scores can be simulated. # define possible patient risk scores risks <- c(0.001, 0.01, 0.1, 0.002, 0.02, 0.2) # sample risk population of size n = 100 set.seed(2046) patient_risks <- sample(x = risks, size = 100, replace = TRUE) # control limit can be obtained with racusum_limit_sim(), # here it is set to an arbitrary value (2.96), # or dynamic control limits with racusum_limit_dpcl() ##### RA-CUSUM of in-control process # simulate patient outcome for performace as expected set.seed(2046) patient_outcomes <- as.logical(rbinom( n = 100, size = 1, prob = patient_risks )) racusum(patient_risks, patient_outcomes, limit = 2.96 ) #### RA-CUSUM of out-of-control process # simulate patient outcome for deviating performance set.seed(2046) patient_outcomes <- as.logical(rbinom(n = 100, size = 1, prob = patient_risks * 2)) #' racusum(patient_risks, patient_outcomes, limit = 2.96 )
Simulate false signal probability alpha given control limit for RA-CUSUM charts
racusum_alpha_sim(patient_risks, odds_multiplier, n_simulation, limit, seed = NULL)
racusum_alpha_sim(patient_risks, odds_multiplier, n_simulation, limit, seed = NULL)
patient_risks |
Double. Vector of patient risk scores (individual risk of adverse event) |
odds_multiplier |
Double. Odds multiplier of adverse event under the alternative hypothesis (<1 looks for decreases) |
n_simulation |
Integer. Number of simulation runs |
limit |
Double. Control limit for signalling performance change |
seed |
Integer. Seed for RNG |
Returns False signal probability of specified RA-CUSUM chart.
# Patients risks are usually known from Phase I. # If not, these risk scores can be simulated. # define possible patient risk scores risks <- c(0.001, 0.01, 0.1, 0.002, 0.02, 0.2) # sample risk population of size n = 100 set.seed(2046) patient_risks <- sample(x = risks, size = 100, replace = TRUE) # control limit can be obtained with racusum_limit_sim(), # here it is set to an arbitrary value (2.96) # simulate false positive probability of RA-CUSUM racusum_alpha_sim(patient_risks, odds_multiplier = 2, n_simulation = 1000, limit = 2.96, seed = 2046 )
# Patients risks are usually known from Phase I. # If not, these risk scores can be simulated. # define possible patient risk scores risks <- c(0.001, 0.01, 0.1, 0.002, 0.02, 0.2) # sample risk population of size n = 100 set.seed(2046) patient_risks <- sample(x = risks, size = 100, replace = TRUE) # control limit can be obtained with racusum_limit_sim(), # here it is set to an arbitrary value (2.96) # simulate false positive probability of RA-CUSUM racusum_alpha_sim(patient_risks, odds_multiplier = 2, n_simulation = 1000, limit = 2.96, seed = 2046 )
Generated performance data of indicator: Ratio of observed to expected cases of severe stroke or death under open carotid stenosis surgery.
racusum_example_data
racusum_example_data
A data frame with 2000 rows and 4 variables:
Sequence of observations
Patient outcome
Patient risk score
Year of treatment
Individual patient risk scores were drawn from actual hospital data and patient outcomes were simulated. Two years are provided, so Phase I and Phase II can be defined.
Data for simulation was provided by Bavarian Agency of Quality Assurance (BAQ), Munich Germany.
Description of performance indicator (in German): https://iqtig.org/downloads/auswertung/2016/10n2karot/QSKH_10n2-KAROT_2016_QIDB_V02_2017-04-26.pdf
Set DPCL for risk-adjusted Bernoulli CUSUM Charts
racusum_limit_dpcl(patient_risks, N = 1e+05, odds_multiplier = 2, alpha, seed = NULL)
racusum_limit_dpcl(patient_risks, N = 1e+05, odds_multiplier = 2, alpha, seed = NULL)
patient_risks |
Double. Vector of patient risk scores (individual risk of adverse event) |
N |
Integer. Number of simulation runs |
odds_multiplier |
Double. Odds multiplier of adverse event under the alternative hypothesis (<1 looks for decreases) |
alpha |
Double. False signal probability of RA-CUSUM |
seed |
Integer. Seed for RNG |
Returns vector of dynamic control limit for signalling performance change (double)
Zhang, Xiang & Woodall, William. (2016). Dynamic Probability Control Limits for Lower and Two-Sided Risk-Adjusted Bernoulli CUSUM Charts. Quality and Reliability Engineering International. 10.1002/qre.2044.
patient_risks <- runif(100, min = 0.1, max = 0.8) dpcl <- racusum_limit_dpcl( patient_risks = patient_risks, N = 1000, odds_multiplier = 2, alpha = 0.05, seed = 32423 ) plot(dpcl, type = "l")
patient_risks <- runif(100, min = 0.1, max = 0.8) dpcl <- racusum_limit_dpcl( patient_risks = patient_risks, N = 1000, odds_multiplier = 2, alpha = 0.05, seed = 32423 ) plot(dpcl, type = "l")
False-signal-probability-simulation of Control Limits h for risk-adjusted CUSUM charts
racusum_limit_sim(patient_risks, odds_multiplier, n_simulation, alpha, seed = NULL)
racusum_limit_sim(patient_risks, odds_multiplier, n_simulation, alpha, seed = NULL)
patient_risks |
Double. Vector of patient risk scores (individual risk of adverse event) |
odds_multiplier |
Double. Odds multiplier of adverse event under the alternative hypothesis (<1 looks for decreases) |
n_simulation |
Integer. Number of simulation runs |
alpha |
Double. False signal probability of RA-CUSUM |
seed |
Integer. Seed for RNG |
Returns the control limit for signalling performance change (double)
# Patients risks are usually known from Phase I. # If not, these risk scores can be simulated. # define possible patient risk scores risks <- c(0.001, 0.01, 0.1, 0.002, 0.02, 0.2) # sample risk population of size n = 100 set.seed(2046) patient_risks <- sample(x = risks, size = 100, replace = TRUE) # simulate control limits for alpha = 0.05 racusum_limit_sim(patient_risks, odds_multiplier = 2, n_simulation = 1000, alpha = 0.05, seed = 2046 )
# Patients risks are usually known from Phase I. # If not, these risk scores can be simulated. # define possible patient risk scores risks <- c(0.001, 0.01, 0.1, 0.002, 0.02, 0.2) # sample risk population of size n = 100 set.seed(2046) patient_risks <- sample(x = risks, size = 100, replace = TRUE) # simulate control limits for alpha = 0.05 racusum_limit_sim(patient_risks, odds_multiplier = 2, n_simulation = 1000, alpha = 0.05, seed = 2046 )
Calculate GSCUSUM chart for risk-adjusted processes.
ragscusum(input_ra_outcomes, limit, quantiles, max_num_shuffles = 10000L, seed = 0L)
ragscusum(input_ra_outcomes, limit, quantiles, max_num_shuffles = 10000L, seed = 0L)
input_ra_outcomes |
Matrix. First column are binary patient outcomes (0,1). Second column are patient individual weight for adverse event (failure) and third column patient individual weight for no adverse event (success). Fourth column are continuous sequence of block identifier. |
limit |
Double. Control limit for signalling performance change |
quantiles |
Double. Vector of requested quantiles of RA-GSCUSUM distribution |
max_num_shuffles |
Integer. Number of shuffles (i.e. different sequences of observations) |
seed |
Integer. Seed for RNG (if = 0 random seed is set (default)) |
ragscusum NumericMatix, signal probability, average CUSUM value and specified quantiles for every observation.
Generated performance data of indicator: Ratio of observed to expected cases of severe stroke or death under open carotid stenosis surgery.
ragscusum_example_data
ragscusum_example_data
A data frame with 2000 rows and 4 variables:
Sequence of observations
Patient outcome
Patient risk score
Year of treatment
Continuous block identifier
Individual patient risk scores were drawn from actual hospital data and patient outcomes were simulated. Two years are provided, so Phase I and Phase II can be defined.
Data for simulation was provided by Bavarian Agency of Quality Assurance (BAQ), Munich Germany.
Description of performance indicator (in German): https://iqtig.org/downloads/auswertung/2016/10n2karot/QSKH_10n2-KAROT_2016_QIDB_V02_2017-04-26.pdf
Calculate standard CUSUM weights
weights_t(patient_outcomes, probability_ae, odds_multiplier = 2)
weights_t(patient_outcomes, probability_ae, odds_multiplier = 2)
patient_outcomes |
Integer. Vector of binary patient outcomes (0,1) |
probability_ae |
Double. Baseline failure probability for adverse event in non-risk-adjusted case, vector of patient risk scores for risk-adjustment. |
odds_multiplier |
Double. Odds multiplier of adverse event under the alternative hypothesis (<1 looks for decreases) |