Package 'scqe'

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

Help Index


scqe: Stability Controlled Quasi-Experimentation

Description

The scqe package contains several function for statistical analysis that factor in confounding variables and their impact on estimates (Hazlett, 2019).

Details

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.

package dependencies

AER ggplot2

References

Hazlett, C. (2019), 'Estimating causal effects of new treatments despite self-selection: The case of experimental medical treatments.' Journal of Causal Inference.


Delta optimization method for scqe 2 cohort, summary statistics

Description

The print method provides the critical values presented in the summary method for scqe objects.

Usage

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,
  ...
)

Arguments

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.

Value

Optimal delta.


Delta optimization method for scqe 1 cohort, summary statistics

Description

The print method provides the critical values presented in the summary method for scqe objects.

Usage

delta.optim.scqe(
  Y_T0,
  untreated,
  Y_untreated,
  treated,
  Y_treated,
  obj,
  specified = NULL,
  alpha = 0.05,
  ...
)

Arguments

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.

Value

Optimal delta.


Delta optimization method for scqe 1 cohort, full data

Description

The print method provides the critical values presented in the summary method for scqe objects.

Usage

delta.optim.scqe.1cfull(
  treatment,
  outcome,
  delta,
  obj,
  specified = NULL,
  alpha = 0.05,
  ...
)

Arguments

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.

Value

Optimal delta.


Delta optimization method for scqe 2 cohort, full data

Description

The print method provides the critical values presented in the summary method for scqe objects.

Usage

delta.optim.scqe2(
  post,
  treatment,
  outcome,
  delta,
  obj,
  alpha = 0.05,
  specified = NULL,
  ...
)

Arguments

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.

Value

Optimal delta.


Plot method for scqe

Description

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.

Usage

## S3 method for class 'scqe'
plot(x, xlab, ylab, ...)

Arguments

x

an object of class scqe

xlab

Optional character label for x axis.

ylab

Optional character label for y axis.

...

Extra optional arguments

Value

Plot of estimates and confidence intervals.

Examples

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)

Stability controlled quasi-experiment (scqe)

Description

Main scqe function. Computes scqe estimates and corresponding confidence intervals.

Usage

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,
  ...
)

Arguments

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 outcome is supplied.

max_outcome

Maximum value for the outcome. Optional, not used if outcome is supplied.

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 delta is supplied.

max_delta

Maximum delta. Optional, not used if delta is supplied.

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.

Value

scqe object, results table

References

Hazlett, C. (2019), 'Estimating causal effects of new treatments despite self-selection: The case of experimental medical treatments.' Journal of Causal Inference.

Examples

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)

Stability controlled quasi-experiment (scqe) for 1 cohort case, full data

Description

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.

Usage

scqe.1cfull(treatment, outcome, delta, min_delta, max_delta, alpha = 0.05, ...)

Arguments

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 delta is supplied.

max_delta

Maximum delta. Optional, not used if delta is supplied.

alpha

Numeric alpha for confidence interval (default is alpha = 0.05).

...

Extra optional arguments.

Value

scqe object of class "scqe." Returns results table for the 1 cohort, full data case.

Examples

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)

Stability controlled quasi-experiment (scqe) for 1 cohort case, summary statistics

Description

This function returns the scqe estimates and confidence intervals for the 1 cohort case when the user inputs only summary statistics.

Usage

scqe.1csumm(
  untr_1C,
  Y_untr_1C,
  tr_1C,
  Y_tr_1C,
  delta,
  min_delta,
  max_delta,
  alpha = 0.05,
  ...
)

Arguments

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 delta is supplied.

max_delta

Maximum delta. Optional, not used if delta is supplied.

alpha

Numeric alpha for confidence interval (default is alpha = 0.05).

...

Extra optional arguments.

Value

scqe object of class "scqe." Returns results table for the 1 cohort, summary statistics case.

Examples

# 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)

Stability controlled quasi-experiment (scqe) for 2 cohort case, full data

Description

This function returns the scqe estimates and confidence intervals for the 2 cohort case when the user inputs full data.

Usage

scqe.2cfull(
  post,
  treatment,
  outcome,
  delta,
  min_delta,
  max_delta,
  alpha = 0.05,
  ...
)

Arguments

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 delta is supplied.

max_delta

Maximum delta. Optional, not used if delta is supplied.

alpha

Numeric alpha for confidence interval (default is alpha = 0.05).

...

Extra optional arguments.

Value

scqe object of class "scqe." Returns results table for the 2 cohort, full data case.

Examples

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)

Stability controlled quasi-experiment (scqe) for 1 cohort case, summary statistics

Description

This function returns the scqe estimates and confidence intervals for the 2 cohort case when the user inputs only summary statistics.

Usage

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,
  ...
)

Arguments

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 delta is supplied.

max_delta

Maximum delta. Optional, not used if delta is supplied.

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.

Value

scqe object of class "scqe." Returns results table for the 2 cohort, summary statistics case.

Examples

# 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)

Stability controlled quasi-experiment (scqe)

Description

Dispatches to correct scqe function

Usage

scqemethod(...)

Arguments

...

Arguments from scqe

Value

scqe object of class "scqe", results table


Summary method for scqe

Description

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.

Usage

## S3 method for class 'scqe'
summary(object, ...)

## S3 method for class 'scqe'
print(x, ...)

Arguments

object

an object of class scqe

...

Extra optional arguments

x

an object of class scqe

Value

Text interpretations of your results from scqe method results table.

Results table.

Examples

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)