Title: | Stability Controlled Quasi-Experimentation |
---|---|
Description: | Functions to implement the stability controlled quasi-experiment (SCQE) approach to study the effects of newly adopted treatments that were not assigned at random. This package contains tools to help users avoid making statistical assumptions that rely on infeasible assumptions. Methods developed in Hazlett (2019) <doi:10.1002/sim.8717>. |
Authors: | Kirsten Landsiedel [cre], Hazlett Chad [aut], Wulf Ami [ctr], Pinkelman Colleen [ctr], Christopher Gandrud [ctr] |
Maintainer: | Kirsten Landsiedel <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0 |
Built: | 2025-02-18 04:41:58 UTC |
Source: | https://github.com/cran/scqe |
The scqe package contains several function for statistical analysis that factor in confounding variables and their impact on estimates (Hazlett, 2019).
The main function in the package is scqe
, which computes scqe
estimates and confidence intervals for one or two cohorts with summary or
full data given.
AER ggplot2
Hazlett, C. (2019), 'Estimating causal effects of new treatments despite self-selection: The case of experimental medical treatments.' Journal of Causal Inference.
scqe
2 cohort, summary statisticsThe print
method provides the critical values presented in the summary
method for scqe objects.
delta_optim_SCQE_2C( delta, untr_pre, untr_post, tr_post, tr_pre, Y_tr_post, Y_untr_post, Y_tr_pre, Y_untr_pre, obj, specified = NULL, alpha = 0.05, ... )
delta_optim_SCQE_2C( delta, untr_pre, untr_post, tr_post, tr_pre, Y_tr_post, Y_untr_post, Y_tr_pre, Y_untr_pre, obj, specified = NULL, alpha = 0.05, ... )
delta |
Single value or vector of possible values for change in average non-treatment outcome between cohorts (if applicable). |
untr_pre |
Integer number of untreated patients in the first cohort if applicable (summary statistics input) (T=0). |
untr_post |
Integer number of untreated patients in the second cohort if applicable (summary statistics input) (T=1). |
tr_post |
Integer number of treated patients in the second cohort if applicable (summary statistics input) (T=1). |
tr_pre |
Integer number of treated patients in the first cohort if applicable (summary statistics input) (T=0). |
Y_tr_post |
Outcome for patients who received treatment at time T=1 (summary statistics input). |
Y_untr_post |
Outcome for patients who did not receive treatment at time T=1 (summary statistics input). |
Y_tr_pre |
Outcome for patients who did receive treatment at time T=0 (summary statistics input). |
Y_untr_pre |
Outcome for patients who did not receive treatment at time T=0 (summary statistics input). |
obj |
scqe object. |
specified |
Specified optional arguments. |
alpha |
Numeric alpha for confidence intervals (default alpha = 0.05). |
... |
Extra optional arguments. |
Optimal delta.
scqe
1 cohort, summary statisticsThe print
method provides the critical values presented in the summary
method for scqe objects.
delta.optim.scqe( Y_T0, untreated, Y_untreated, treated, Y_treated, obj, specified = NULL, alpha = 0.05, ... )
delta.optim.scqe( Y_T0, untreated, Y_untreated, treated, Y_treated, obj, specified = NULL, alpha = 0.05, ... )
Y_T0 |
Y |
untreated |
Number of untreated individuals. |
Y_untreated |
Outcome for untreated individuals. |
treated |
Number of treated individuals. |
Y_treated |
Outcome for treated individuals. |
obj |
scqe object. |
specified |
Specified optional arguments. |
alpha |
Numeric alpha for confidence intervals (default alpha = 0.05). |
... |
Extra optional arguments. |
Optimal delta.
scqe
1 cohort, full dataThe print
method provides the critical values presented in the summary
method for scqe objects.
delta.optim.scqe.1cfull( treatment, outcome, delta, obj, specified = NULL, alpha = 0.05, ... )
delta.optim.scqe.1cfull( treatment, outcome, delta, obj, specified = NULL, alpha = 0.05, ... )
treatment |
Binary or continuous vector corresponding (usually) to 0,1 (no treatment or treatment) for each observation. |
outcome |
Continuous vector representing the outcome for each observation. |
delta |
Single value or vector of possible values for change in average non-treatment outcome between cohorts (if applicable). |
obj |
scqe object. |
specified |
Specified optional arguments. |
alpha |
Numeric alpha for confidence intervals (default alpha=.05). |
... |
Extra optional arguments. |
Optimal delta.
scqe
2 cohort, full dataThe print
method provides the critical values presented in the summary
method for scqe objects.
delta.optim.scqe2( post, treatment, outcome, delta, obj, alpha = 0.05, specified = NULL, ... )
delta.optim.scqe2( post, treatment, outcome, delta, obj, alpha = 0.05, specified = NULL, ... )
post |
Binary vector corresponding to T=0,1 for each observation. |
treatment |
Binary or continuous vector corresponding (usually) to 0,1. |
outcome |
Continuous vector representing the outcome for each observation |
delta |
Single value or vector of possible values for change in average non-treatment outcome between cohorts (if applicable). |
obj |
scqe object. |
alpha |
Numeric alpha for confidence intervals (default alpha=.05). |
specified |
Specified optional arguments. |
... |
Extra optional arguments. |
Optimal delta.
scqe
The print
method provides a plot of the estimates
and confidence intervals for the scqe estimates for the range of
values of delta provided by the user.
## S3 method for class 'scqe' plot(x, xlab, ylab, ...)
## S3 method for class 'scqe' plot(x, xlab, ylab, ...)
x |
an object of class |
xlab |
Optional character label for x axis. |
ylab |
Optional character label for y axis. |
... |
Extra optional arguments |
Plot of estimates and confidence intervals.
set.seed(1234) post <- c(rep(0,100), rep(1,100)) tx <- c(rep(0, 100), rbinom(n = 100, prob = 0.27, size = 1)) y <- rbinom(n = 200, prob = 0.1 + 0.02 * post - 0.05 * tx, size = 1) # Two cohorts, full data scqe.2cohort.full <- scqe(post = post, treatment = tx, outcome = y, delta = seq(from = -0.1, to = 0.1, by = 0.05)) plot(scqe.2cohort.full)
set.seed(1234) post <- c(rep(0,100), rep(1,100)) tx <- c(rep(0, 100), rbinom(n = 100, prob = 0.27, size = 1)) y <- rbinom(n = 200, prob = 0.1 + 0.02 * post - 0.05 * tx, size = 1) # Two cohorts, full data scqe.2cohort.full <- scqe(post = post, treatment = tx, outcome = y, delta = seq(from = -0.1, to = 0.1, by = 0.05)) plot(scqe.2cohort.full)
Main scqe function. Computes scqe estimates and corresponding confidence intervals.
scqe( post, treatment, outcome, min_outcome, max_outcome, delta, min_delta, max_delta, cohort, untr_pre, untr_post, tr_post, tr_pre, Y_tr_post, Y_untr_post, Y_tr_pre, Y_untr_pre, untr, tr, Y_tr, Y_untr, alpha = 0.05, ... )
scqe( post, treatment, outcome, min_outcome, max_outcome, delta, min_delta, max_delta, cohort, untr_pre, untr_post, tr_post, tr_pre, Y_tr_post, Y_untr_post, Y_tr_pre, Y_untr_pre, untr, tr, Y_tr, Y_untr, alpha = 0.05, ... )
post |
Binary vector corresponding to T = 0, 1 for each observation. |
treatment |
Binary or continuous vector corresponding (usually) to [0,1] (no treatment or treatment) for each observation. |
outcome |
Continuous vector representing the outcome for each observation. |
min_outcome |
Minimum value for the outcome.
Optional, not used if |
max_outcome |
Maximum value for the outcome.
Optional, not used if |
delta |
Single value or vector of possible values for change in average non-treatment outcome between cohorts (if applicable). |
min_delta |
Minimum delta. Optional, not used if |
max_delta |
Maximum delta. Optional, not used if |
cohort |
Numeric, 1 or 2 depending on cohort membership. |
untr_pre |
Integer number of untreated patients in the first cohort if applicable (summary statistics input) (T=0). |
untr_post |
Integer number of untreated patients in the second cohort if applicable (summary statistics input) (T=1). |
tr_post |
Integer number of treated patients in the second cohort if applicable (summary statistics input) (T=1). |
tr_pre |
Integer number of treated patients in the first cohort if applicable (summary statistics input) (T=0). |
Y_tr_post |
Outcome for patients who received treatment at time T=1 (summary statistics input). |
Y_untr_post |
Outcome for patients who did not receive treatment at time T=1 (summary statistics input). |
Y_tr_pre |
Outcome for patients who did receive treatment at time T=0 (summary statistics input). |
Y_untr_pre |
Outcome for patients who did not receive treatment at time T=0 (summary statistics input). |
untr |
Integer number of untreated patients (summary statistics input). |
tr |
Integer number of treated patients (summary statistics input). |
Y_tr |
Outcome for treated patients (summary statistics input). |
Y_untr |
Outcome for untreated patients (summary statistics input). |
alpha |
Numeric alpha for confidence interval (default is alpha = 0.05). |
... |
Extra optional arguments. |
scqe object, results table
Hazlett, C. (2019), 'Estimating causal effects of new treatments despite self-selection: The case of experimental medical treatments.' Journal of Causal Inference.
set.seed(1234) post = c(rep(0,100), rep(1,100)) tx = c(rep(0, 100), rbinom(n = 100, prob = 0.27, size = 1)) y = rbinom(n = 200, prob = 0.1 + .02 * post - 0.05 * tx, size = 1) # Two cohorts, full data scqe.2cohort.full = scqe(post = post, treatment = tx, outcome = y, delta = seq(from = -0.1, to = 0.1, by = 0.05)) plot(scqe.2cohort.full) summary(scqe.2cohort.full) # One cohort, full data scqe.1cohort.full = scqe(treatment = tx, outcome = y, delta=seq(from = -0.1, to = 0.1, by = 0.05)) plot(scqe.1cohort.full) summary(scqe.1cohort.full) # Two cohorts, summary data only scqe.2cohort.sum = scqe(untr_pre = 200,untr_post = 150, tr_post = 50, tr_pre = 0, Y_tr_post = 20, Y_untr_post = 1, Y_tr_pre = 0, Y_untr_pre = 5, min_delta = 0.1, max_delta = 1) plot(scqe.2cohort.sum) summary(scqe.2cohort.sum) # One cohort, summary data only scqe.1cohort.sum = scqe(untr = 100, tr = 200, Y_untr = 5, Y_tr = 50, min_delta= 0.1, max_delta = 1) plot(scqe.1cohort.sum) summary(scqe.1cohort.sum)
set.seed(1234) post = c(rep(0,100), rep(1,100)) tx = c(rep(0, 100), rbinom(n = 100, prob = 0.27, size = 1)) y = rbinom(n = 200, prob = 0.1 + .02 * post - 0.05 * tx, size = 1) # Two cohorts, full data scqe.2cohort.full = scqe(post = post, treatment = tx, outcome = y, delta = seq(from = -0.1, to = 0.1, by = 0.05)) plot(scqe.2cohort.full) summary(scqe.2cohort.full) # One cohort, full data scqe.1cohort.full = scqe(treatment = tx, outcome = y, delta=seq(from = -0.1, to = 0.1, by = 0.05)) plot(scqe.1cohort.full) summary(scqe.1cohort.full) # Two cohorts, summary data only scqe.2cohort.sum = scqe(untr_pre = 200,untr_post = 150, tr_post = 50, tr_pre = 0, Y_tr_post = 20, Y_untr_post = 1, Y_tr_pre = 0, Y_untr_pre = 5, min_delta = 0.1, max_delta = 1) plot(scqe.2cohort.sum) summary(scqe.2cohort.sum) # One cohort, summary data only scqe.1cohort.sum = scqe(untr = 100, tr = 200, Y_untr = 5, Y_tr = 50, min_delta= 0.1, max_delta = 1) plot(scqe.1cohort.sum) summary(scqe.1cohort.sum)
This function returns the scqe estimates and confidence intervals for the 1 cohort case (ie there is not 'post' input) when the user inputs full data.
scqe.1cfull(treatment, outcome, delta, min_delta, max_delta, alpha = 0.05, ...)
scqe.1cfull(treatment, outcome, delta, min_delta, max_delta, alpha = 0.05, ...)
treatment |
Binary or continuous vector corresponding (usually) to 0,1 (no treatment or treatment) for each observation. |
outcome |
Continuous vector representing the outcome for each observation. |
delta |
Single value or vector of possible values for change in average non-treatment outcome between cohorts (if applicable). |
min_delta |
Minimum delta. Optional, not used if |
max_delta |
Maximum delta. Optional, not used if |
alpha |
Numeric alpha for confidence interval (default is alpha = 0.05). |
... |
Extra optional arguments. |
scqe object of class "scqe." Returns results table for the 1 cohort, full data case.
set.seed(1234) post = c(rep(0,100), rep(1,100)) tx = c(rep(0, 100), rbinom(n = 100, prob = 0.27, size = 1)) y = rbinom(n = 200, prob = 0.1 + 0.02 * post - 0.05 * tx, size = 1) # One cohort, full data scqe.1cohort.full = scqe(treatment = tx, outcome = y, delta=seq(from = -0.1, to = 0.1, by = 0.05)) plot(scqe.1cohort.full) summary(scqe.1cohort.full)
set.seed(1234) post = c(rep(0,100), rep(1,100)) tx = c(rep(0, 100), rbinom(n = 100, prob = 0.27, size = 1)) y = rbinom(n = 200, prob = 0.1 + 0.02 * post - 0.05 * tx, size = 1) # One cohort, full data scqe.1cohort.full = scqe(treatment = tx, outcome = y, delta=seq(from = -0.1, to = 0.1, by = 0.05)) plot(scqe.1cohort.full) summary(scqe.1cohort.full)
This function returns the scqe estimates and confidence intervals for the 1 cohort case when the user inputs only summary statistics.
scqe.1csumm( untr_1C, Y_untr_1C, tr_1C, Y_tr_1C, delta, min_delta, max_delta, alpha = 0.05, ... )
scqe.1csumm( untr_1C, Y_untr_1C, tr_1C, Y_tr_1C, delta, min_delta, max_delta, alpha = 0.05, ... )
untr_1C |
Number of untreated individuals. |
Y_untr_1C |
Outcome for untreated individuals. |
tr_1C |
Number of treated individuals. |
Y_tr_1C |
Outcome for treated individuals. |
delta |
Single value or vector of possible values for change in average non-treatment outcome between cohorts (if applicable). |
min_delta |
Minimum delta. Optional, not used if |
max_delta |
Maximum delta. Optional, not used if |
alpha |
Numeric alpha for confidence interval (default is alpha = 0.05). |
... |
Extra optional arguments. |
scqe object of class "scqe." Returns results table for the 1 cohort, summary statistics case.
# One cohort, summary data only scqe.1cohort.sum = scqe(untr=100,tr=200,Y_untr=5,Y_tr=50, min_delta=.1,max_delta=1) plot(scqe.1cohort.sum) summary(scqe.1cohort.sum)
# One cohort, summary data only scqe.1cohort.sum = scqe(untr=100,tr=200,Y_untr=5,Y_tr=50, min_delta=.1,max_delta=1) plot(scqe.1cohort.sum) summary(scqe.1cohort.sum)
This function returns the scqe estimates and confidence intervals for the 2 cohort case when the user inputs full data.
scqe.2cfull( post, treatment, outcome, delta, min_delta, max_delta, alpha = 0.05, ... )
scqe.2cfull( post, treatment, outcome, delta, min_delta, max_delta, alpha = 0.05, ... )
post |
Binary vector corresponding to T = 0,1 for each observation. |
treatment |
Binary or continuous vector corresponding (usually) to 0,1 (no treatment or treatment) for each observation. |
outcome |
Continuous vector representing the outcome for each observation. |
delta |
Single value or vector of possible values for change in average non-treatment outcome between cohorts (if applicable). |
min_delta |
Minimum delta. Optional, not used if |
max_delta |
Maximum delta. Optional, not used if |
alpha |
Numeric alpha for confidence interval (default is alpha = 0.05). |
... |
Extra optional arguments. |
scqe object of class "scqe." Returns results table for the 2 cohort, full data case.
set.seed(1234) post = c(rep(0,100), rep(1,100)) tx = c(rep(0, 100), rbinom(n = 100, prob = 0.27, size = 1)) y = rbinom(n = 200, prob = 0.1 + 0.02 * post - 0.05 * tx, size = 1) # Two cohorts, full data scqe.2cohort.full = scqe(post = post, treatment = tx, outcome = y, delta = seq(from = -0.1,to = 0.1, by = 0.05)) plot(scqe.2cohort.full) summary(scqe.2cohort.full)
set.seed(1234) post = c(rep(0,100), rep(1,100)) tx = c(rep(0, 100), rbinom(n = 100, prob = 0.27, size = 1)) y = rbinom(n = 200, prob = 0.1 + 0.02 * post - 0.05 * tx, size = 1) # Two cohorts, full data scqe.2cohort.full = scqe(post = post, treatment = tx, outcome = y, delta = seq(from = -0.1,to = 0.1, by = 0.05)) plot(scqe.2cohort.full) summary(scqe.2cohort.full)
This function returns the scqe estimates and confidence intervals for the 2 cohort case when the user inputs only summary statistics.
scqe.2csumm( untr_pre, untr_post, tr_post, tr_pre, Y_tr_post, Y_untr_post, Y_tr_pre, Y_untr_pre, min_delta, max_delta, delta, alpha = 0.05, ... )
scqe.2csumm( untr_pre, untr_post, tr_post, tr_pre, Y_tr_post, Y_untr_post, Y_tr_pre, Y_untr_pre, min_delta, max_delta, delta, alpha = 0.05, ... )
untr_pre |
Integer number of untreated patients in the first cohort if applicable (summary statistics input) (T=0). |
untr_post |
Integer number of untreated patients in the second cohort if applicable (summary statistics input) (T=1). |
tr_post |
Integer number of treated patients in the second cohort if applicable (summary statistics input) (T=1). |
tr_pre |
Integer number of treated patients in the first cohort if applicable (summary statistics input) (T=0). |
Y_tr_post |
Outcome for patients who received treatment at time T=1 (summary statistics input). |
Y_untr_post |
Outcome for patients who did not receive treatment at time T=1 (summary statistics input). |
Y_tr_pre |
Outcome for patients who did receive treatment at time T=0 (summary statistics input). |
Y_untr_pre |
Outcome for patients who did not receive treatment at time T=0 (summary statistics input). |
min_delta |
Minimum delta. Optional, not used if |
max_delta |
Maximum delta. Optional, not used if |
delta |
Numeric scalar or numeric vector of possible values for change in average non-treatment outcome between cohorts (if applicable). |
alpha |
Numeric alpha for confidence interval (default is alpha=.05). |
... |
Extra optional arguments. |
scqe object of class "scqe." Returns results table for the 2 cohort, summary statistics case.
# Two cohorts, summary data only scqe_2cohort_sum <- scqe(untr_pre = 200,untr_post = 150,tr_post = 50, tr_pre=0, Y_tr_post = 20, Y_untr_post = 1, Y_tr_pre=0, Y_untr_pre = 5,min_delta = 0.1, max_delta = 1) plot(scqe_2cohort_sum) summary(scqe_2cohort_sum)
# Two cohorts, summary data only scqe_2cohort_sum <- scqe(untr_pre = 200,untr_post = 150,tr_post = 50, tr_pre=0, Y_tr_post = 20, Y_untr_post = 1, Y_tr_pre=0, Y_untr_pre = 5,min_delta = 0.1, max_delta = 1) plot(scqe_2cohort_sum) summary(scqe_2cohort_sum)
Dispatches to correct scqe function
scqemethod(...)
scqemethod(...)
... |
Arguments from scqe |
scqe object of class "scqe", results table
scqe
The summary
method provides several statements that summarize
important values of delta requires to make different conclusions
about the treatment's effect on patient outcome.
The ptin
method provides the result table that
includes the given delta values and their conclusions
about the treatment's effect on patient outcome.
## S3 method for class 'scqe' summary(object, ...) ## S3 method for class 'scqe' print(x, ...)
## S3 method for class 'scqe' summary(object, ...) ## S3 method for class 'scqe' print(x, ...)
object |
an object of class |
... |
Extra optional arguments |
x |
an object of class |
Text interpretations of your results from scqe method results table.
Results table.
set.seed(1234) post <- c(rep(0, 100), rep(1, 100)) tx <- c(rep(0, 100), rbinom(n = 100, prob = 0.27, size = 1)) y <- rbinom(n = 200, prob = 0.1 + 0.02 * post - 0.05 * tx, size = 1) # Two cohorts, full data scqe.2cohort.full = scqe(post = post, treatment = tx, outcome = y, delta=seq(from = -0.1, to = 0.1, by = 0.05)) summary(scqe.2cohort.full) set.seed(1234) post = c(rep(0,100), rep(1,100)) tx = c(rep(0, 100), rbinom(n = 100, prob = 0.27, size = 1)) y = rbinom(n= 200, prob = 0.1 + 0.02 * post - 0.05 * tx, size = 1) # Two cohorts, full data scqe.2cohort.full = scqe(post = post, treatment = tx, outcome = y, delta = seq(from = -0.1, to = 0.1, by = 0.05)) scqe.2cohort.full print(scqe.2cohort.full)
set.seed(1234) post <- c(rep(0, 100), rep(1, 100)) tx <- c(rep(0, 100), rbinom(n = 100, prob = 0.27, size = 1)) y <- rbinom(n = 200, prob = 0.1 + 0.02 * post - 0.05 * tx, size = 1) # Two cohorts, full data scqe.2cohort.full = scqe(post = post, treatment = tx, outcome = y, delta=seq(from = -0.1, to = 0.1, by = 0.05)) summary(scqe.2cohort.full) set.seed(1234) post = c(rep(0,100), rep(1,100)) tx = c(rep(0, 100), rbinom(n = 100, prob = 0.27, size = 1)) y = rbinom(n= 200, prob = 0.1 + 0.02 * post - 0.05 * tx, size = 1) # Two cohorts, full data scqe.2cohort.full = scqe(post = post, treatment = tx, outcome = y, delta = seq(from = -0.1, to = 0.1, by = 0.05)) scqe.2cohort.full print(scqe.2cohort.full)