Package 'twangContinuous'

Title: Toolkit for Weighting and Analysis of Nonequivalent Groups - Continuous Exposures
Description: Provides functions for propensity score estimation and weighting for continuous exposures as described in Zhu, Y., Coffman, D. L., & Ghosh, D. (2015). A boosting algorithm for estimating generalized propensity scores with continuous treatments. Journal of Causal Inference, 3(1), 25-40. <doi:10.1515/jci-2014-0022>.
Authors: Donna Coffman [aut, cre] , Brian Vegetabile [ctb]
Maintainer: Donna Coffman <[email protected]>
License: GPL (>= 2)
Version: 1.0.0
Built: 2024-11-04 03:48:38 UTC
Source: https://github.com/dcoffman/twangcontinuous

Help Index


Compute the balance table.

Description

'bal.table' is a generic function for extracting balance tables from 'ps.cont' objects, one for an unweighted analysis and one for the weighted analysis.

Usage

bal.table(x, digits = 3, ...)

Arguments

x

A 'ps.cont' object

digits

Number of digits to round to. Default: 3

...

Additional arguments.

Value

Returns a data frame containing the balance information. * 'unw' The unweighted correlation between the exposure and each covariate. * 'wcor' The weighted correlation between the exposure and each covariate.

See Also

ps.cont

Examples

## Not run: bal.table(test.mod)

A synthetic data set that was derived from a large scale observational study on youth in substance use treatment.

Description

A subset of measures from the Global Appraisal of Individual Needs biopsychosocial assessment instrument (GAIN) (Dennis, Titus et al. 2003) from sites that administered two different types of substance use disorder treatments (treatment “A” and treatment “B”). The Center for Substance Abuse Treatment (CSAT) funded the sites that administered these two SUD treatments. This dataset consists of 4,000 adolescents, 2,000 in each treatment group. The dataset includes substance use and mental health variables.

Usage

data("dat")

Format

A data frame with 4000 observations on the following 29 variables.

treat

a factor with levels A B

tss_0

a numeric vector

tss_3

a numeric vector

tss_6

a numeric vector

sfs8p_0

a numeric vector

sfs8p_3

a numeric vector

sfs8p_6

a numeric vector

eps7p_0

a numeric vector

eps7p_3

a numeric vector

eps7p_6

a numeric vector

ias5p_0

a numeric vector

dss9_0

a numeric vector

mhtrt_0

a numeric vector

sati_0

a numeric vector

sp_sm_0

a numeric vector

sp_sm_3

a numeric vector

sp_sm_6

a numeric vector

gvs

a numeric vector

ers21_0

a numeric vector

nproc

a numeric vector

ada_0

a numeric vector

ada_3

a numeric vector

ada_6

a numeric vector

recov_0

a numeric vector

recov_3

a numeric vector

recov_6

a numeric vector

subsgrps_n

a numeric vector

sncnt

a numeric vector

engage

a numeric vector

Details

tss_0

Traumatic Stress Scale - Baseline

tss_3

Traumatic Stress Scale - 3 months

tss_6

Traumatic Stress Scale - 6 months

sfs8p_0

Substance Frequency Scale - Baseline

sfs8p_3

Substance Frequency Scale - 3 months

sfs8p_6

Substance Frequency Scale - 6 months

eps7p_0

Emotional Problems Scale - Baseline

eps7p_3

Emotional Problems Scale - 3 months

eps7p_6

Emotional Problems Scale - 6 months

ias5p_0

Illegal Activities Scale - baseline

dss9_0

depressive symptom scale - baseline

mhtrt_0

mental health treatment in the past 90 days - baseline

sati_0

substance abuse treatment index - baseline

sp_sm_0

substance problem scale (past month) - baseline

sp_sm_3

substance problem scale (past month) - 3 months

sp_sm_6

substance problem scale (past month) - 6 months

gvs

General Victimization Scale

ers21_0

Environmental Risk Scale - baseline

ada_0

adjusted days abstinent (any in past 90) - baseline

ada_3

adjusted days abstinent (any in past 90) - 3 months

ada_6

adjusted days abstinent (any in past 90) - 6 months

recov_0

in recovery - baseline

recov_3

in recovery - 3 months

recov_6

in recovery - 6 months

subsgrps_n

primarily opioid using youth vs alcohol/marijuana using youth vs other

Source

Diamond, G., Godley, S. H., Liddle, H. A., Sampl, S., Webb, C., Tims, F. M., & Meyers, R. (2002). Five outpatient treatment models for adolescent marijuana use: a description of the Cannabis Youth Treatment Interventions. Addiction, 97, 70-83.

References

Diamond, G., Godley, S. H., Liddle, H. A., Sampl, S., Webb, C., Tims, F. M., & Meyers, R. (2002). Five outpatient treatment models for adolescent marijuana use: a description of the Cannabis Youth Treatment Interventions. Addiction, 97, 70-83.

Examples

data(dat)
## maybe str(dat) ; plot(dat) ...

Extract propensity score weights

Description

Extracts propensity score weights from a ps.cont object.

Usage

get.weights(ps1, stop.method = "wcor", withSampW = TRUE)

Arguments

ps1

a ps.cont object

stop.method

indicates which set of weights to retrieve from the ps.cont object

withSampW

Returns weights with sample weights multiplied in, if they were provided in the original ps.cont call.

Value

a vector of weights

Author(s)

Donna L. Coffman

See Also

ps.cont


Plot the 'ps.cont' object.

Description

This function produces a collection of diagnostic plots for 'ps.cont' objects.

Usage

## S3 method for class 'ps.cont'
plot(x, plots = "optimize", subset = NULL, ...)

Arguments

x

'ps.cont' object

plots

An indicator of which type of plot is desired. The options are * '"optimize"' A plot of the balance criteria as a function of the GBM iteration. * '"es"' Plots of the standardized effect size of the pre-treatment variables before and after weighting

subset

Used to restrict which of the 'stop.method's will be used in the figure.

...

Additional arguments.

Value

Returns diagnostic plots for 'ps.cont' objects.

See Also

ps.cont

Examples

## Not run: plot(test.mod)

Gradient boosted propensity score estimation for continuous exposures

Description

'ps.cont' calculates propensity scores using gradient boosted regression and provides diagnostics of the resulting propensity scores.

Usage

ps.cont(
  formula,
  data,
  n.trees = 10000,
  interaction.depth = 3,
  shrinkage = 0.01,
  bag.fraction = 1,
  sampw = NULL,
  print.level = 2,
  verbose = FALSE,
  stop.method = "wcor",
  treat.as.cont = FALSE,
  ...
)

Arguments

formula

An object of class [formula]: a symbolic description of the propensity score model to be fit with the treatment variable on the left side of the formula and the potential confounding variables on the right side.

data

A dataset that includes the treatment as well as the potential confounding variables.

n.trees

Number of gbm iterations passed on to [gbm]. Default: 10000.

interaction.depth

A positive integer denoting the tree depth used in gradient boosting. Default: 3.

shrinkage

A numeric value between 0 and 1 denoting the learning rate. See [gbm] for more details. Default: 0.01.

bag.fraction

A numeric value between 0 and 1 denoting the fraction of the observations randomly selected in each iteration of the gradient boosting algorithm to propose the next tree. See [gbm] for more details. Default: 1.0.

sampw

Optional sampling weights.

print.level

The amount of detail to print to the screen. Default: 2.

verbose

If 'TRUE', lots of information will be printed to monitor the the progress of the fitting. Default: 'FALSE'.

stop.method

A method or methods of measuring and summarizing balance across pretreatment variables. Current options are 'wcor', the weighted Pearson correlation, summarized by using the mean across the pretreatment variables. Default: 'wcor'.

treat.as.cont

Used as a check on whether the exposure has greater than five levels. If it does not and treat.as.cont=FALSE, an error will be produced. Default: FALSE

...

Additional arguments that are passed to ps function.

Value

Returns an object of class 'ps.cont', a list containing

* 'gbm.obj' The returned [gbm] object.

* 'treat' The treatment variable.

* 'desc' A list containing balance tables for each method selected in 'stop.methods'. Includes a component for the unweighted analysis names “unw”. Each 'desc' component includes a list with the following components

- 'ess' The effective sample size.

- 'n' The number of subjects.

- 'max.wcor' The largest weighted correlation across the covariates.

- 'mean.wcor' The average weighted correlation across the covariates.

- 'rms.wcor' The root mean square of the absolute weighted correlations across the covariates.

- 'bal.tab' a (potentially large) table summarizing the quality of the weights for balancing the distribution of the pretreatment covariates. This table is best extracted using the [bal.table] method. See the help for [bal.table] for details.

- 'n.trees' The estimated optimal number of [gbm] iterations to optimize the loss function.

* 'ps.den' Denominator values for the propensity score weights.

* 'ps.num' Numerator values for the propensity score weights.

* 'w' The propensity score weights. If sampling weights are given then these are incorporated into these weights.

* 'datestamp' Records the date of the analysis.

* 'parameters' Saves the 'ps.cont' call.

* 'alerts' Text containing any warnings accumulated during the estimation.

* 'iters' A sequence of iterations used in the GBM fits used by 'plot' function.

* 'balance' The balance measures for the pretreatment covariates used in plotting.

* 'sampw' The sampling weights as specified in the 'sampw' argument.

* 'preds' Predicted values based on the propensity score model.

* 'covariates' Data frame containing the covariates used in the propensity score model.

* 'n.trees' Maximum number of trees considered in GBM fit.

* 'data' Data as specified in the 'data' argument.

References

Zhu, Y., Coffman, D. L., & Ghosh, D. (2015). A boosting algorithm for estimating generalized propensity scores with continuous treatments. *Journal of Causal Inference*, 3(1), 25-40. doi:10.1515/jci-2014-0022

See Also

gbm, plot.ps.cont, bal.table, summary.ps.cont

Examples

## Not run: test.mod <- ps.cont(tss_0 ~ sfs8p_0 + sati_0 + sp_sm_0
          + recov_0 + subsgrps_n + treat, data=dat
## End(Not run)

Displays a useful description of a 'ps.cont' object.

Description

Computes a short summary table describing the size of the dataset and the quality of the propensity score weights about a stored 'ps.cont' object.

Usage

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

Arguments

object

A 'ps.cont' object

...

Additional arguments.

Value

*'n' The number of subjects. *'ess' The effective sample size. *'max.wcor' The largest weighted correlation across the covariates. *'mean.wcor' The average weighted correlation across the covariates. *'rms.wcor' The root mean square of the absolute weighted correlations across the covariates. *'iter' The estimated optimal number of [gbm] iterations to optimize the loss function.

See Also

ps.cont

Examples

## Not run: summary(test.mod)