| Type: | Package |
| Date: | 2021-02-15 |
| Title: | Toolkit for Weighting and Analysis of Nonequivalent Groups - Continuous Exposures |
| Version: | 1.0.0 |
| 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>. |
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
| Encoding: | UTF-8 |
| LazyData: | true |
| VignetteBuilder: | knitr |
| Imports: | Rcpp (≥ 0.12.19), lattice (≥ 0.20-35), gbm (≥ 2.1.3), survey, xtable |
| Suggests: | knitr, rmarkdown |
| RoxygenNote: | 7.1.1 |
| NeedsCompilation: | no |
| Packaged: | 2021-02-24 16:38:26 UTC; tug76052 |
| Author: | Donna Coffman |
| Maintainer: | Donna Coffman <donna.coffman@gmail.com> |
| Depends: | R (≥ 3.5.0) |
| Repository: | CRAN |
| Date/Publication: | 2021-02-26 09:50:02 UTC |
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.
treata factor with levels
ABtss_0a numeric vector
tss_3a numeric vector
tss_6a numeric vector
sfs8p_0a numeric vector
sfs8p_3a numeric vector
sfs8p_6a numeric vector
eps7p_0a numeric vector
eps7p_3a numeric vector
eps7p_6a numeric vector
ias5p_0a numeric vector
dss9_0a numeric vector
mhtrt_0a numeric vector
sati_0a numeric vector
sp_sm_0a numeric vector
sp_sm_3a numeric vector
sp_sm_6a numeric vector
gvsa numeric vector
ers21_0a numeric vector
nproca numeric vector
ada_0a numeric vector
ada_3a numeric vector
ada_6a numeric vector
recov_0a numeric vector
recov_3a numeric vector
recov_6a numeric vector
subsgrps_na numeric vector
sncnta numeric vector
engagea numeric vector
Details
tss_0Traumatic Stress Scale - Baseline
tss_3Traumatic Stress Scale - 3 months
tss_6Traumatic Stress Scale - 6 months
sfs8p_0Substance Frequency Scale - Baseline
sfs8p_3Substance Frequency Scale - 3 months
sfs8p_6Substance Frequency Scale - 6 months
eps7p_0Emotional Problems Scale - Baseline
eps7p_3Emotional Problems Scale - 3 months
eps7p_6Emotional Problems Scale - 6 months
ias5p_0Illegal Activities Scale - baseline
dss9_0depressive symptom scale - baseline
mhtrt_0mental health treatment in the past 90 days - baseline
sati_0substance abuse treatment index - baseline
sp_sm_0substance problem scale (past month) - baseline
sp_sm_3substance problem scale (past month) - 3 months
sp_sm_6substance problem scale (past month) - 6 months
gvsGeneral Victimization Scale
ers21_0Environmental Risk Scale - baseline
ada_0adjusted days abstinent (any in past 90) - baseline
ada_3adjusted days abstinent (any in past 90) - 3 months
ada_6adjusted days abstinent (any in past 90) - 6 months
recov_0in recovery - baseline
recov_3in recovery - 3 months
recov_6in recovery - 6 months
subsgrps_nprimarily 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 |
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 |
Value
a vector of weights
Author(s)
Donna L. Coffman
See Also
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)