Title: | Multilevel Propensity Score Analysis |
---|---|
Description: | Conducts and visualizes propensity score analysis for multilevel, or clustered data. Bryer & Pruzek (2011) <doi:10.1080/00273171.2011.636693>. |
Authors: | Jason Bryer <[email protected]> |
Maintainer: | Jason Bryer <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.2.5 |
Built: | 2024-11-04 05:34:51 UTC |
Source: | https://github.com/jbryer/multilevelpsa |
This packages provides functions to estimate and visualize multilevel propensity score analysis.
This package extends the principles put forth by the PSAgraphics
(Helmreich, Pruzek, & Xiong, 2010) for multilevel, or clustered, data.
Propensity score analyses are typically done in two phases. In phase I, a
statistical model predicting treatment using the available individual covariates
is estimated. This package currently currently provides functions to perform
propensity score estimates using logistic regression (see mlpsa.logistic
)
and conditional inference trees (see mlpsa.ctree
). The latter method
provides explicit stratifications as defined by each leaf node. The former however,
results in a numerical value ranging from zero to one (i.e. the fitted values).
A common approach is to then create stratifications using quintiles. However,
other approaches such as Loess regression are also provided.
Phase II of typical propensity score analyses concerns with the comparison of an
outcome between the treatment and comparison groups. The mlpsa
method will perform this analysis in a multilevel, or clustered, fashion. That
is, the results of the mlpsa
procedure produce summary results
at level one (i.e. each strata within each cluster), level two (i.e. overall results
for each cluster), and overall (i.e. overall results across all clusters).
This package also provides a number of visualizations that provide a critical
part in presenting, understanding, and interpreting the results. See
plot.mlpsa
for details.
Jason Bryer [email protected]
http://cran.r-project.org/web/packages/PSAgraphics/PSAgraphics.pdf http://www.jstatsoft.org/v29/i06/
PSAgraphics
Adapted from ggExtra package which is no longer available. This is related to an experimental mlpsa plot that will combine the circular plot along with the two individual distributions.
## S3 method for class 'plots' align(gl, ...)
## S3 method for class 'plots' align(gl, ...)
gl |
grid.layout |
... |
graphic elements to combine. |
Returns the overall effects as a data frame.
## S3 method for class 'covariate.balance' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
## S3 method for class 'covariate.balance' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
x |
results of |
row.names |
unused. |
optional |
unused. |
... |
unused |
a data frame with overall covariate effects before and after adjustment.
Estimate covariate effect sizes before and after propensity score adjustment.
covariate.balance(covariates, treatment, level2, strata, abs = TRUE)
covariate.balance(covariates, treatment, level2, strata, abs = TRUE)
covariates |
frame or matrix of covariates. |
treatment |
vector of treatment indicators. |
level2 |
vector indicating level 2 membership. |
strata |
strata indicators. |
abs |
if TRUE absolute values of effect sizes will be plotted. |
This function is modified from the cv.bal.psa
function in the
PSAgrpahics
package.
covariateBalance(covariates, treatment, propensity, strata = NULL, int = NULL, tree = FALSE, minsize = 2, universal.psd = TRUE, trM = 0, absolute.es = TRUE, trt.value = NULL, use.trt.var = FALSE, verbose = FALSE, xlim = NULL, plot.strata = TRUE, na.rm = TRUE, ...)
covariateBalance(covariates, treatment, propensity, strata = NULL, int = NULL, tree = FALSE, minsize = 2, universal.psd = TRUE, trM = 0, absolute.es = TRUE, trt.value = NULL, use.trt.var = FALSE, verbose = FALSE, xlim = NULL, plot.strata = TRUE, na.rm = TRUE, ...)
covariates |
dataframe of interest |
treatment |
binary vector of 0s and 1s (necessarily? what if character, or 1, 2?) |
propensity |
PS scores from some method or other. |
strata |
either a vector of strata number for each row of covariate, or one number n in which case it is attempted to group rows by ps scores into n strata of size approximately 1/n. This does not seem to work well in the case of few specific propensity values, as from a tree. |
int |
either a number m used to divide [0,1] into m equal length subintervals, or a vector of cut points between 0 an 1 defining the subintervals (perhaps as suggested by loess.psa). In either case these subintervals define strata, so strata can be of any size. |
tree |
logical, if unique ps scores are few, as from a recursively partitioned tree, then TRUE will force each ps value to define a stratum. |
minsize |
smallest allowable stratum-treatment size. If violated, strata is removed. |
universal.psd |
If 'TRUE', forces standard deviations used to be unadjusted for stratification. |
trM |
trimming proportion for mean calculations. |
absolute.es |
logical, if 'TRUE' routine uses absolute values of all effect sizes. |
trt.value |
allows user to specify which value is active treatment, if desired. |
use.trt.var |
logical, if true then Rubin-Stuart method using only treatment variance with be used in effect size calculations. |
verbose |
logical, controls output that is visibly returned. |
xlim |
limits for the x-axis. |
plot.strata |
logical indicating whether to print strata. |
na.rm |
should missing values be removed. |
... |
currently unused. |
Note: effect sizes are calculated as treatment 1 - treatment 0, or treatment B - treatment A.
Robert M. Pruzek [email protected]
James E. Helmreich [email protected]
KuangNan Xiong [email protected]
Jason Bryer [email protected]
The function cv.trans.psa
takes a covariate data frame and replaces each
categorical covariate of n >=3
levels with n new binary covariate columns,
one for each level. Transforms covariate dataframe for use with the function
cv.bal.psa
.
cv.trans.psa(covariates, fcol = NULL)
cv.trans.psa(covariates, fcol = NULL)
covariates |
A dataframe of covariates, presumably some factors. |
fcol |
An optional vector containing the factor columns in the covariate
data frame. In |
NOTE: This function originated in the PSAgraphics
package. It has been
adapted here for the multilevelPSA
package.
James E. Helmreich [email protected]
Robert M. Pruzek [email protected]
KuangNan Xiong [email protected]
Jason Bryer [email protected]
This function produces a ggplot2 figure containing the mean differences for each level two, or cluster.
difftable.plot(x, fill.colors = NULL, legendlab = NULL, ...)
difftable.plot(x, fill.colors = NULL, legendlab = NULL, ...)
x |
the results of |
fill.colors |
the colors to use for each level two. |
legendlab |
the label to use for the legend, or NULL to exclude. |
... |
currently unused. |
a ggplot2 figure
Returns a data frame with two columns corresponding to the level 2 variable and the fitted value from the logistic regression.
getPropensityScores(lr.results, nStrata = 5)
getPropensityScores(lr.results, nStrata = 5)
lr.results |
the results of |
nStrata |
number of strata within each level. |
a data frame
mlpsa.logistic
Returns a data frame with two columns corresponding to the level 2 variable and the leaves from the conditional inference trees.
getStrata(party.results, data, level2)
getStrata(party.results, data, level2)
party.results |
the results of |
data |
the data frame to merge results to |
level2 |
the name of the level 2 variable. |
a data frame
mlpsa.ctree
mlpsa
Returns true if the object is of type mlpsa
is.mlpsa(x)
is.mlpsa(x)
x |
the object to test |
Loess plot with density distributions for propensity scores and outcomes on top and right, respectively.
loess.plot(x, response, treatment, responseTitle = "", treatmentTitle = "Treatment", percentPoints.treat = 0.1, percentPoints.control = 0.01, points.treat.alpha = 0.1, points.control.alpha = 0.1, plot.strata, plot.strata.alpha = 0.2, ...)
loess.plot(x, response, treatment, responseTitle = "", treatmentTitle = "Treatment", percentPoints.treat = 0.1, percentPoints.control = 0.01, points.treat.alpha = 0.1, points.control.alpha = 0.1, plot.strata, plot.strata.alpha = 0.2, ...)
x |
vector of propensity scores. |
response |
the response variable. |
treatment |
the treatment variable as a logical type. |
responseTitle |
the label to use for the y-axis (i.e. the name of the response variable) |
treatmentTitle |
the label to use for the treatment legend. |
percentPoints.treat |
the percentage of treatment points to randomly plot. |
percentPoints.control |
the percentage of control points to randomly plot. |
points.treat.alpha |
the transparency level for treatment points. |
points.control.alpha |
the transparency level for control points. |
plot.strata |
an integer value greater than 2 indicating the number of vertical lines to plot corresponding to quantiles. |
plot.strata.alpha |
the alpha level for the vertical lines. |
... |
other parameters passed to |
a ggplot2 figure
plot.mlpsa
## Not run: require(multilevelPSA) require(party) data(pisana) data(pisa.psa.cols) cnt = 'USA' #Can change this to USA, MEX, or CAN pisana2 = pisana[pisana$CNT == cnt,] pisana2$treat <- as.integer(pisana2$PUBPRIV) %% 2 lr.results <- glm(treat ~ ., data=pisana2[,c('treat',pisa.psa.cols)], family='binomial') st = data.frame(ps=fitted(lr.results), math=apply(pisana2[,paste('PV', 1:5, 'MATH', sep='')], 1, mean), pubpriv=pisana2$treat) st$treat = as.logical(st$pubpriv) loess.plot(st$ps, response=st$math, treatment=st$treat, percentPoints.control = 0.4, percentPoints.treat=0.4) ## End(Not run)
## Not run: require(multilevelPSA) require(party) data(pisana) data(pisa.psa.cols) cnt = 'USA' #Can change this to USA, MEX, or CAN pisana2 = pisana[pisana$CNT == cnt,] pisana2$treat <- as.integer(pisana2$PUBPRIV) %% 2 lr.results <- glm(treat ~ ., data=pisana2[,c('treat',pisa.psa.cols)], family='binomial') st = data.frame(ps=fitted(lr.results), math=apply(pisana2[,paste('PV', 1:5, 'MATH', sep='')], 1, mean), pubpriv=pisana2$treat) st$treat = as.logical(st$pubpriv) loess.plot(st$ps, response=st$math, treatment=st$treat, percentPoints.control = 0.4, percentPoints.treat=0.4) ## End(Not run)
Nicer list of objects in memory. Particularly useful for analysis of large data. # http://stackoverflow.com/questions/1358003/tricks-to-manage-the-available-memory-in-an-r-session
lsos(..., n = 10)
lsos(..., n = 10)
... |
not used. |
n |
the number of objects to return. |
a list of objects loaded sorted by size.
NOTE: This is an experimental function and the results may vary depending on the nature of the dataset.
missing.plot(x, grouping, grid = FALSE, widths = c(ggplot2::unit(3, "null"), ggplot2::unit(1, "inches")), heights = c(ggplot2::unit(1, "inches"), ggplot2::unit(3, "null")), color = "red", ...)
missing.plot(x, grouping, grid = FALSE, widths = c(ggplot2::unit(3, "null"), ggplot2::unit(1, "inches")), heights = c(ggplot2::unit(1, "inches"), ggplot2::unit(3, "null")), color = "red", ...)
x |
a data frame containing the variables to visualize missingness |
grouping |
a vector of length nrow(vars) corresponding to how missing will be grouped by |
grid |
whether to draw a grid between tiles |
widths |
the ratio of the widths of the heatmap and histogram. |
heights |
the ratio of the heights of the heatmap and histogram. |
color |
the color used for indicating missingness. |
... |
currently unused. |
a ggplot2 expression
plot.mlpsa
TODO: Need more details
mlpsa(response, treatment = NULL, strata = NULL, level2 = NULL, minN = 5, reverse = FALSE, ci.level = 0.05)
mlpsa(response, treatment = NULL, strata = NULL, level2 = NULL, minN = 5, reverse = FALSE, ci.level = 0.05)
response |
vector containing the response values |
treatment |
vector containing the treatment conditions |
strata |
vector containing the strata for each response |
level2 |
vector containing the level 2 specifications |
minN |
the minimum number of subjects per strata for that strata to be included in the analysis. |
reverse |
reverse the order of treatment and control for the difference calculation. |
ci.level |
the confidence level to use for confidence intervals. Defaults to a 95% confidence level. |
The ci.adjust provides a Bonferroni-Sidak adjusted confidence intervals based on the number of levels/clusters.
a mlpsa class
## Not run: require(multilevelPSA) require(party) data(pisana) data(pisa.colnames) data(pisa.psa.cols) mlctree = mlpsa.ctree(pisana[,c('CNT','PUBPRIV',pisa.psa.cols)], formula=PUBPRIV ~ ., level2='CNT') student.party = getStrata(mlctree, pisana, level2='CNT') student.party$mathscore = apply(student.party[,paste0('PV', 1:5, 'MATH')], 1, sum) / 5 results.psa.math = mlpsa(response=student.party$mathscore, treatment=student.party$PUBPRIV, strata=student.party$strata, level2=student.party$CNT, minN=5) results.psa.math summary(results.psa.math) ## End(Not run)
## Not run: require(multilevelPSA) require(party) data(pisana) data(pisa.colnames) data(pisa.psa.cols) mlctree = mlpsa.ctree(pisana[,c('CNT','PUBPRIV',pisa.psa.cols)], formula=PUBPRIV ~ ., level2='CNT') student.party = getStrata(mlctree, pisana, level2='CNT') student.party$mathscore = apply(student.party[,paste0('PV', 1:5, 'MATH')], 1, sum) / 5 results.psa.math = mlpsa(response=student.party$mathscore, treatment=student.party$PUBPRIV, strata=student.party$strata, level2=student.party$CNT, minN=5) results.psa.math summary(results.psa.math) ## End(Not run)
The plot created uses the ggplot2
framework. As such, additional modifications
can be made. This plot is an extension of the circ.psa
function in the
PSAgraphics
package for multilevel models.
mlpsa.circ.plot(x, xlab = names(multilevelPSA$level2.summary)[4], ylab = names(multilevelPSA$level2.summary)[5], legendlab = "Level 2", title = NULL, overall.col = "blue", overall.ci.col = "green", level1.plot = FALSE, level1.point.size = NULL, level1.rug.plot = NULL, level1.projection.lines = FALSE, level2.plot = TRUE, level2.point.size = NULL, level2.rug.plot = "tr", level2.projection.lines = TRUE, level2.label = FALSE, unweighted.means = FALSE, weighted.means = FALSE, fill.colors = NULL, ...)
mlpsa.circ.plot(x, xlab = names(multilevelPSA$level2.summary)[4], ylab = names(multilevelPSA$level2.summary)[5], legendlab = "Level 2", title = NULL, overall.col = "blue", overall.ci.col = "green", level1.plot = FALSE, level1.point.size = NULL, level1.rug.plot = NULL, level1.projection.lines = FALSE, level2.plot = TRUE, level2.point.size = NULL, level2.rug.plot = "tr", level2.projection.lines = TRUE, level2.label = FALSE, unweighted.means = FALSE, weighted.means = FALSE, fill.colors = NULL, ...)
x |
the results of |
xlab |
label for the x-axis. |
ylab |
label for the y-axis. |
legendlab |
the label for the legend, or NULL to exclude. |
title |
title for the figure. |
overall.col |
the color used for the overall results. |
overall.ci.col |
the color used for the confidence intervals. |
level1.plot |
logical value indicating whether level 1 points should be plotted. |
level1.point.size |
the size of level 1 points |
level1.rug.plot |
the placement for plotting a level 2 rug. Possible values
are |
level1.projection.lines |
logical value indicating whether level 1 project lines (parallel to the unit line) are drawn. |
level2.plot |
logical value indicating whether level 2 points should be plotted. |
level2.point.size |
the size of level 2 points |
level2.rug.plot |
the placement for plotting a level 2 rug. Possible values
are |
level2.projection.lines |
logical value indicating whether level 2 project lines (parallel to the unit line) are drawn. |
level2.label |
logical value indicating whether level 2 points should be labeled. |
unweighted.means |
logical value indicating whether horizontal and vertical lines are drawn representing the unweighted (i.e. unadjusted from phase I of PSA) means for each level 2, or cluster. |
weighted.means |
logical value indicating whether horizontal and vertical lines are drawn representing the weighted means for each level 2, or cluster. |
fill.colors |
if specified, the colors to use for level 2 points. |
... |
currently unused. |
plot.mlpsa
## Not run: data(pisana) data(pisa.colnames) data(pisa.psa.cols) mlctree = mlpsa.ctree(pisana[,c('CNT','PUBPRIV',pisa.psa.cols)], formula=PUBPRIV ~ ., level2='CNT') student.party = getStrata(mlctree, pisana, level2='CNT') student.party$mathscore = apply(student.party[,paste0('PV', 1:5, 'MATH')], 1, sum) / 5 results.psa.math = mlpsa(response=student.party$mathscore, treatment=student.party$PUBPRIV, strata=student.party$strata, level2=student.party$CNT, minN=5) mlpsa.circ.plot(results.psa.math, legendlab=FALSE) ## End(Not run)
## Not run: data(pisana) data(pisa.colnames) data(pisa.psa.cols) mlctree = mlpsa.ctree(pisana[,c('CNT','PUBPRIV',pisa.psa.cols)], formula=PUBPRIV ~ ., level2='CNT') student.party = getStrata(mlctree, pisana, level2='CNT') student.party$mathscore = apply(student.party[,paste0('PV', 1:5, 'MATH')], 1, sum) / 5 results.psa.math = mlpsa(response=student.party$mathscore, treatment=student.party$PUBPRIV, strata=student.party$strata, level2=student.party$CNT, minN=5) mlpsa.circ.plot(results.psa.math, legendlab=FALSE) ## End(Not run)
This function will estimate propensity scores using the conditional inference
framework as outlined in the party
package. Specifically, a separate
tree will be estimated for each level 2 (or cluster). A key advantage of this
framework over other methods for estimating propensity scores is that this
method will work on data sets containing missing values.
mlpsa.ctree(vars, formula, level2, ...)
mlpsa.ctree(vars, formula, level2, ...)
vars |
a data frame containing the covariates to use for estimating the propensity scores. |
formula |
the model for estimating the propensity scores. For example, treat ~ . |
level2 |
the name of the column in |
... |
currently unused. |
a list of BinaryTree-class classes for each level 2
Torsten Hothorn, Kurt Hornik and Achim Zeileis (2006). Unbiased Recursive Partitioning: A Conditional Inference Framework. Journal of Computational and Graphical Statistics, 15(3), 651–674.
Creates a graphic summarizing the differences between treatment and comparison groups within and across level two clusters.
mlpsa.difference.plot(x, xlab, ylab = NULL, title = NULL, overall.col = "blue", overall.ci.col = "green", level2.point.size = NULL, level1.points = TRUE, errorbars = TRUE, errorbars.adjusted.ci = TRUE, level2.rug.plot = TRUE, jitter = TRUE, reorder = TRUE, labelLevel2 = TRUE, sd = NULL, xlim, ...)
mlpsa.difference.plot(x, xlab, ylab = NULL, title = NULL, overall.col = "blue", overall.ci.col = "green", level2.point.size = NULL, level1.points = TRUE, errorbars = TRUE, errorbars.adjusted.ci = TRUE, level2.rug.plot = TRUE, jitter = TRUE, reorder = TRUE, labelLevel2 = TRUE, sd = NULL, xlim, ...)
x |
the results of |
xlab |
label for the x-axis, or NULL to exclude. |
ylab |
label for the y-axis, or NULL to exclude. |
title |
title of the figure, or NULL to exclude. |
overall.col |
the color of the overall results line. |
overall.ci.col |
the color of the overall confidence interval. |
level2.point.size |
the point size of level 2 points. |
level1.points |
logical value indicating whether level 1 strata should be plotted. |
errorbars |
logical value indicating whether error bars should be plotted for for each level 1. |
errorbars.adjusted.ci |
whether the Bonferroni adjusted error bars should be plotted (these will be dashed lines). |
level2.rug.plot |
logical value indicating whether a rug plot should be plotted for level 2. |
jitter |
logical value indicating whether level 1 points should be jittered. |
reorder |
logical value indicating whether the level two clusters should be reordered from largest difference to smallest. |
labelLevel2 |
logical value indicating whether the difference for each level 2 should be labeled. |
sd |
If specified, effect sizes will be plotted instead of difference in the native unit. |
xlim |
the limits of the x-axis. |
... |
currently unused. |
plot.mlpsa
## Not run: data(pisana) data(pisa.colnames) data(pisa.psa.cols) mlctree = mlpsa.ctree(pisana[,c('CNT','PUBPRIV',pisa.psa.cols)], formula=PUBPRIV ~ ., level2='CNT') student.party = getStrata(mlctree, pisana, level2='CNT') student.party$mathscore = apply(student.party[,paste0('PV', 1:5, 'MATH')], 1, sum) / 5 results.psa.math = mlpsa(response=student.party$mathscore, treatment=student.party$PUBPRIV, strata=student.party$strata, level2=student.party$CNT, minN=5) mlpsa.difference.plot(results.psa.math, sd=mean(student.party$mathscore, na.rm=TRUE)) ## End(Not run)
## Not run: data(pisana) data(pisa.colnames) data(pisa.psa.cols) mlctree = mlpsa.ctree(pisana[,c('CNT','PUBPRIV',pisa.psa.cols)], formula=PUBPRIV ~ ., level2='CNT') student.party = getStrata(mlctree, pisana, level2='CNT') student.party$mathscore = apply(student.party[,paste0('PV', 1:5, 'MATH')], 1, sum) / 5 results.psa.math = mlpsa(response=student.party$mathscore, treatment=student.party$PUBPRIV, strata=student.party$strata, level2=student.party$CNT, minN=5) mlpsa.difference.plot(results.psa.math, sd=mean(student.party$mathscore, na.rm=TRUE)) ## End(Not run)
Plots distribution for either the treatment or comparison group.
mlpsa.distribution.plot(x, treat, fill.colours = NULL, flip = TRUE, label = treat, level2.label = NULL, legendlab = NULL, axis.text.size = 8, fill.colors = NULL, ...)
mlpsa.distribution.plot(x, treat, fill.colours = NULL, flip = TRUE, label = treat, level2.label = NULL, legendlab = NULL, axis.text.size = 8, fill.colors = NULL, ...)
x |
the results of |
treat |
the group to plot. This must be one of the two levels of the treatment variable. |
fill.colours |
if specified, the colors to use for level 2 points. |
flip |
if TRUE, the level 2 clusters will be on the y-axis and the outcome variable on the x-axis. Otherwise reversed. |
label |
the label to use for the axis. |
level2.label |
the axis label for the level 2 indicators. |
legendlab |
the label for the legend, or NULL to exclude a legend. |
axis.text.size |
the size of the axis text |
fill.colors |
if specified, the colors to use for level 2 points. |
... |
currently unused. |
plot.mlpsa
This method will estimate a separate logistic regression model for each level 2 (or cluster).
mlpsa.logistic(vars, formula, level2, stepAIC = FALSE, ...)
mlpsa.logistic(vars, formula, level2, stepAIC = FALSE, ...)
vars |
data frame containing the variables to estimate the logistic regression |
formula |
the logistic regression formula to use |
level2 |
the name of the column containing the level 2 specification |
stepAIC |
if true, the |
... |
currently unused. |
a list of glm classes for each level 2 or stepwise-selected model if stepAIC is true.
getPropensityScores
pisana
with full descriptions.This data frame provides three variables, Variable
corresponding to the
column names in pisana
, ShortDesc
providing a short
description of the variable as a valid R object name, and Desc
providing
a longer description of the variable.
a data frame with 50 rows of 3 variables.
This data frame has two columns, CNT3
for the three letter abbreviation
of each country and Country
that provides the full country name in English.
data frame with 65 rows of 2 variables.
Character vector representing the list of covariates used for estimating propensity scores.
a character vector with covariate names for estimating propensity scores.
Student results from the 2009 Programme of International Student Assessment (PISA) as provided by the Organization for Economic Co-operation and Development (OECD). See http://www.pisa.oecd.org/ for more information including the code book.
a data frame with 66,548 obvservations of 65 variables.
Note that missing values have been imputed using the
http://cran.r-project.org/web/packages/mice/index.html package.
Details on the specific procedure are in the pisa.impute
function
in the pisa
package.
Organization for Economic Co-operation and Development
Organization for Economic Co-operation and Development (2009). Programme for International Student Assessment (PISA). http://www.pisa.oecd.org/
A graphic based upon cv.bal.psa
function in the PSAgraphics
package. This graphic plots the effect sizes for multiple covariates before and
after propensity score adjustement.
## S3 method for class 'covariate.balance' plot(x, plot.strata = FALSE, order = c("unadjusted", "adjusted"), strata.size = 3, strata.legend.guide = "none", point.size = 3, point.alpha = 1, line.color = "black", line.alpha = 0.2, legend.position = c(0.8, 0.2), ...)
## S3 method for class 'covariate.balance' plot(x, plot.strata = FALSE, order = c("unadjusted", "adjusted"), strata.size = 3, strata.legend.guide = "none", point.size = 3, point.alpha = 1, line.color = "black", line.alpha = 0.2, legend.position = c(0.8, 0.2), ...)
x |
results of |
plot.strata |
whether individual strata should be plotted. |
order |
how to order the y-axis. Possible values are adjusted, unadjusted, or NULL (don't reorder). |
strata.size |
text size for strata if plotted. |
strata.legend.guide |
guide for legend placement for strata. |
point.size |
size of the overall effect size points. |
point.alpha |
transparency level of the overall effect size points. |
line.color |
the color of the line connecting the overall effect size points. |
line.alpha |
transparency level of the line connecting the overall effect size points. |
legend.position |
where to position the legend. |
... |
currently unused. |
a ggplot2 with an attribute, effects
, that is the data frame
used to create the plot.
The plot created uses the ggplot2
framework. As such, additional modifications
can be made. This plot is an extension of the circ.psa
function in the
PSAgraphics
package for multilevel models.
## S3 method for class 'mlpsa' plot(x, ratio = c(1, 2), plotExtra = NULL, ...)
## S3 method for class 'mlpsa' plot(x, ratio = c(1, 2), plotExtra = NULL, ...)
x |
the results of |
ratio |
the ratio of the size of the distribution plots (left and bottom) to the circular plot. |
plotExtra |
a plot to place in the lower left corner. |
... |
parameters passed to |
## Not run: require(multilevelPSA) require(party) data(pisana) data(pisa.colnames) data(pisa.psa.cols) mlctree = mlpsa.ctree(pisana[,c('CNT','PUBPRIV',pisa.psa.cols)], formula=PUBPRIV ~ ., level2='CNT') student.party = getStrata(mlctree, pisana, level2='CNT') student.party$mathscore = apply(student.party[,paste0('PV', 1:5, 'MATH')], 1, sum) / 5 results.psa.math = mlpsa(response=student.party$mathscore, treatment=student.party$PUBPRIV, strata=student.party$strata, level2=student.party$CNT, minN=5) plot(results.psa.math) ## End(Not run)
## Not run: require(multilevelPSA) require(party) data(pisana) data(pisa.colnames) data(pisa.psa.cols) mlctree = mlpsa.ctree(pisana[,c('CNT','PUBPRIV',pisa.psa.cols)], formula=PUBPRIV ~ ., level2='CNT') student.party = getStrata(mlctree, pisana, level2='CNT') student.party$mathscore = apply(student.party[,paste0('PV', 1:5, 'MATH')], 1, sum) / 5 results.psa.math = mlpsa(response=student.party$mathscore, treatment=student.party$PUBPRIV, strata=student.party$strata, level2=student.party$CNT, minN=5) plot(results.psa.math) ## End(Not run)
Plots densities and ranges for the propensity scores.
## S3 method for class 'psrange' plot(x, xlab = NULL, ylab = NULL, labels = c("Comparison", "Treatment"), text.ratio.size = 4, text.ncontrol.size = 3, point.size = 1, point.alpha = 0.6, line.width = 6, density.alpha = 0.2, rect.color = "green", rect.alpha = 0.2, ...)
## S3 method for class 'psrange' plot(x, xlab = NULL, ylab = NULL, labels = c("Comparison", "Treatment"), text.ratio.size = 4, text.ncontrol.size = 3, point.size = 1, point.alpha = 0.6, line.width = 6, density.alpha = 0.2, rect.color = "green", rect.alpha = 0.2, ...)
x |
the result of psrange. |
xlab |
label for x-axis. |
ylab |
label for y-axis. |
labels |
labels for the comparison and treatment legend. |
text.ratio.size |
size of the text for the ratio. |
text.ncontrol.size |
size of the text for the number of control units. |
point.size |
size of the points for the minimum and maximum ranges for each model. |
point.alpha |
the alpha (transparency) level for the points. |
line.width |
the width of the line between the median of the minimum and maximum ranges. |
density.alpha |
the alpha (transparency) level of the density curves. |
rect.color |
the color of the rectangle surrounding the range of minimum and maximum ranges. |
rect.alpha |
the alpha (transparency) level of the rectangle. |
... |
currently unused. |
a ggplot2 object
Prints the overall effects before and after propensity score adjustment.
## S3 method for class 'covariate.balance' print(x, ...)
## S3 method for class 'covariate.balance' print(x, ...)
x |
results of |
... |
unused. |
mlpsa
class.Prints basic information about a mlpsa
class.
## S3 method for class 'mlpsa' print(x, ...)
## S3 method for class 'mlpsa' print(x, ...)
x |
the |
... |
unused. |
Prints information about a psrange result.
## S3 method for class 'psrange' print(x, ...)
## S3 method for class 'psrange' print(x, ...)
x |
psrange to print info about. |
... |
currently unused |
mlpsa
and xtable.mlpsa
.Print method for xtable.mlpsa
.
## S3 method for class 'xmlpsa' print(x, tabular.environment = "longtable", floating = FALSE, ...)
## S3 method for class 'xmlpsa' print(x, tabular.environment = "longtable", floating = FALSE, ...)
x |
result of |
tabular.environment |
see |
floating |
see |
... |
other parameters passed to |
Estimates models with increasing number of comparison subjects starting from 1:1 to using all available comparison group subjects.
psrange(df, treatvar, formula, nsteps = 10, nboot = 10, samples, type = c("logistic", "ctree"), ...)
psrange(df, treatvar, formula, nsteps = 10, nboot = 10, samples, type = c("logistic", "ctree"), ...)
df |
data frame with variables to pass to glm |
treatvar |
vector representing treatment placement. Should be coded as 0s (for control) and 1s (for treatment). |
formula |
formula for logistic regression model |
nsteps |
number of steps to estimate from 1:1 to using all control records. |
nboot |
number of models to execute for each step. |
samples |
the sample sizes to draw from control group for each step. |
type |
either logistic for Logistic regression (using |
... |
other parameters passed to glm. |
a class of psrange that contains a summary data frame, a details data frame, and a list of each individual result from glm.
mlpsa
class.Provides a summary of a mlpsa
class.
## S3 method for class 'mlpsa' summary(object, overall.label = "Overall", ...)
## S3 method for class 'mlpsa' summary(object, overall.label = "Overall", ...)
object |
the mlpsa object. |
overall.label |
the label to place in the strata column for the overall results. |
... |
unused. |
Prints the summary results of psrange.
## S3 method for class 'psrange' summary(object, ...)
## S3 method for class 'psrange' summary(object, ...)
object |
psrange to print summary of. |
... |
currently unused. |
This figure provides a summary of the covariates used within each level two cluster along with their relative importance. Covariates are listed on the y-axis and level two clusters along the x-axis. Cells that are shaded indicate that that covariate was present in the conditional. The shade of the color represents the highest level within the tree that covariate appeared. That is, the darkest color, or depth 1, corresponds to the covariate used at the root of the tree, or the first split.
tree.plot(x, colNames, level2Col, colLabels = NULL, color.high = "azure", color.low = "steelblue", color.na = "white", ...)
tree.plot(x, colNames, level2Col, colLabels = NULL, color.high = "azure", color.low = "steelblue", color.na = "white", ...)
x |
the results of |
colNames |
the columns to include in the graphic |
level2Col |
the name of the level 2 column. |
colLabels |
column labels to use. This is a data frame with two columns, the
first column should match the values in |
color.high |
color for variables with less relative importance as determined by occurring later in the tree (further from the root split). |
color.low |
color for variables with greater relative importance as determined by occurring sooner in the tree (closer to the root split). |
color.na |
color for variables that do not occur in the tree. |
... |
currently unused. |
a ggplot2 expression
plot.mlpsa
## Not run: require(party) data(pisana) data(pisa.colnames) data(pisa.psa.cols) mlctree = mlpsa.ctree(pisana[,c('CNT','PUBPRIV',pisa.psa.cols)], formula=PUBPRIV ~ ., level2='CNT') student.party = getStrata(mlctree, pisana, level2='CNT') tree.plot(mlctree, level2Col=pisana$CNT) ## End(Not run)
## Not run: require(party) data(pisana) data(pisa.colnames) data(pisa.psa.cols) mlctree = mlpsa.ctree(pisana[,c('CNT','PUBPRIV',pisa.psa.cols)], formula=PUBPRIV ~ ., level2='CNT') student.party = getStrata(mlctree, pisana, level2='CNT') tree.plot(mlctree, level2Col=pisana$CNT) ## End(Not run)
mlpsa
as a LaTeX table.This function implements the xtable
method for mlpsa
.
## S3 method for class 'mlpsa' xtable(x, caption, label, align, digits = 2, display = NULL, auto = FALSE, include.note = TRUE, ...)
## S3 method for class 'mlpsa' xtable(x, caption, label, align, digits = 2, display = NULL, auto = FALSE, include.note = TRUE, ...)
x |
results of |
caption |
passed through to |
label |
passed through to |
align |
Not used. |
digits |
number of digits to print. |
display |
passed through to |
auto |
passed through to |
include.note |
include a table note indicating how many rows were removed due to insufficient data within a strata. |
... |
other parameters passed to |