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 |
'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.
bal.table(x, digits = 3, ...)
bal.table(x, digits = 3, ...)
x |
A 'ps.cont' object |
digits |
Number of digits to round to. Default: 3 |
... |
Additional arguments. |
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.
## Not run: bal.table(test.mod)
## Not run: bal.table(test.mod)
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.
data("dat")
data("dat")
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
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
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.
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.
data(dat) ## maybe str(dat) ; plot(dat) ...
data(dat) ## maybe str(dat) ; plot(dat) ...
Extracts propensity score weights from a ps.cont
object.
get.weights(ps1, stop.method = "wcor", withSampW = TRUE)
get.weights(ps1, stop.method = "wcor", withSampW = TRUE)
ps1 |
a |
stop.method |
indicates which set of weights to retrieve from the |
withSampW |
Returns weights with sample weights multiplied in, if they were provided in the original |
a vector of weights
Donna L. Coffman
This function produces a collection of diagnostic plots for 'ps.cont' objects.
## S3 method for class 'ps.cont' plot(x, plots = "optimize", subset = NULL, ...)
## S3 method for class 'ps.cont' plot(x, plots = "optimize", subset = NULL, ...)
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. |
Returns diagnostic plots for 'ps.cont' objects.
## Not run: plot(test.mod)
## Not run: plot(test.mod)
'ps.cont' calculates propensity scores using gradient boosted regression and provides diagnostics of the resulting propensity scores.
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, ... )
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, ... )
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. |
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.
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
gbm
, plot.ps.cont
, bal.table
, summary.ps.cont
## 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)
## 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)
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.
## S3 method for class 'ps.cont' summary(object, ...)
## S3 method for class 'ps.cont' summary(object, ...)
object |
A 'ps.cont' object |
... |
Additional arguments. |
*'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.
## Not run: summary(test.mod)
## Not run: summary(test.mod)