cat.psa {PSAgraphics} | R Documentation |
Compare balance graphically of a categorical covariate as part of a PSA
Description
Given predefined strata and two level treatment for a categorical covariate
from a propensity score analysis, cat.psa
draws pairs of side by side
barplots corresponding to control and treatment for each stratum.
Usage
cat.psa(
categorical,
treatment = NULL,
strata = NULL,
catnames = NULL,
catcol = "terrain.colors",
width = 0.25,
barlab = c("A", "B"),
barnames = NULL,
rtmar = 1.5,
balance = FALSE,
B = 1000,
tbl = TRUE,
cex.leg = 1,
...
)
Arguments
categorical |
Vector or N X 3 dataframe or matrix. If a vector, then
represents a categorical covariate that is being balanced within strata in a
PSA. If |
treatment |
Binary vector or factor of same length as |
strata |
A vector or factor of same length as |
catnames |
List of names in order of the categories; used in the plot
legend. Default is |
catcol |
List of colors used for the categories, default is
|
width |
Controls width of bars, default = 0.25. |
barlab |
Binary list of single |
barnames |
Binary list of treatment names used in the legend; by
default names are taken from |
rtmar |
Numeric. Governs size of right margin allocated for legend. Default = 1.5 |
balance |
Logical. If |
B |
Numeric; passed to |
tbl |
Logical; if |
cex.leg |
Numeric; value of |
... |
Other graphical parameters passed to plot. |
Details
Pairs of bars are graphed side by side so that comparisons may be made
within each stratum and across strata. If balance
is TRUE
,
then the histogram represents an ad hoc balance measure of the given strata
as compared to randomly generated strata. The p-values provided on the
bargraph are bootstrapped in a standard fashion via randomly generated
treatment divisions within given strata. For continuous covariates use
box.psa
.
Value
If tbl
is TRUE
, then a matrix is returned containing
the proportions of each category, and in each treatment level and stratum
that were used to draw the bargraph.
Author(s)
James E. Helmreich James.Helmreich@Marist.edu
Robert M. Pruzek RMPruzek@yahoo.com
See Also
bal.cs.psa
, bal.cws.psa
, box.psa
Examples
categorical<-sample(1:7,1000,replace=TRUE)
treatment<-sample(c(0,1),1000,replace=TRUE)
strata<-sample(5,1000,replace=TRUE)
cat.psa(categorical,treatment,strata)
data(lindner)
attach(lindner)
lindner.ps <- glm(abcix ~ stent + height + female +
diabetic + acutemi + ejecfrac + ves1proc,
data = lindner, family = binomial)
ps<-lindner.ps$fitted
lindner.s5 <- as.numeric(cut(ps, quantile(ps, seq(0, 1, 1/5)),
include.lowest = TRUE, labels = FALSE))
cat.psa(stent, abcix, lindner.s5, xlab = "stent")
lindner.s10 <- as.numeric(cut(ps, quantile(ps, seq(0, 1, 1/10)),
include.lowest = TRUE, labels = FALSE))
cat.psa(ves1proc,abcix, lindner.s10, balance = TRUE, xlab = "ves1proc")
#Using a rpart tree for strata
library(rpart)
lindner.rpart<-rpart(abcix ~ stent + height + female + diabetic +
acutemi + ejecfrac + ves1proc, data=lindner, method="class")
lindner.tree<-factor(lindner.rpart$where, labels = 1:6)
cat.psa(stent, abcix, lindner.tree, xlab = "stent")
cat.psa(ves1proc, abcix, lindner.tree, xlab = "ves1proc")