Last data update: 2014.03.03
R: Supports Multiple Methods for Defining and Visualizing (PS)...
cstrata.psa R Documentation
Supports Multiple Methods for Defining and Visualizing (PS) Strata
Description
Given propensity scores, allows strata to be directly user defined, possibly to: equalize sizes of strata, equalize the ranges of propensity scores, or to specify cut points on the unit interval. Once strata are created, a simple graphic is generated to visualize or judge strata for overlap and appropriateness. If a regression tree has been used, propensity scores are defined for each leaf of the tree.
Usage
cstrata.psa(treatment, propensity, strata = NULL, int = NULL,
tree = FALSE, minsize = 2, graphic = TRUE,
colors = c("dark blue", "dark green"),
xlab = "Estimated Propensity Scores with Random Heights",
pch = c(16, 16))
Arguments
treatment
Binary vector or factor defining the two treatments
propensity
Vector of same length as treatment
containing estimated propensity scores.
strata
Either a vector of same length as treatment
of predefined stratum number, or one integer n
used to assign rows to n
strata propensity
scores, each of approximately the same number of cases. If relatively few unique propensity scores have been defined (as from a classification tree) then the logical tree
should be set equal to TRUE
.
int
Either a number m
used to divide [0,1]
into m
equal length subintervals, or a vector containing cut points between 0 and 1 that define subintervals (perhaps as suggested by loess.psa). In either case the subintervals define strata, for which sizes can differ.
tree
Logical, default FALSE
. If there are few unique propensity scores, say from a recursively partitioned tree, then TRUE
forces strata to be defined by the unique propensity scores.
minsize
Smallest allowable stratum-treatment size. If violated, rows in the stratum are removed. User may wish to redefine strata.
graphic
Logical, default TRUE
. If set to FALSE
the graphic is not provided.
colors
2-ary color vector. Sets the colors of the points in the graphic. Default = c("blue", "orange")
xlab
Label for the x axis; default = "Estimated Propensity Scores with Random Heights"
.
pch
2-ary vector; determines the shape of points in the graphic. Default = c(16, 16)
.
Value
Original.Strata
Table of strata-treatment sizes before minsize
evaluation.
Used.Strata
Table of strata-treatment sizes after minsize
evaluation.
strata
Vector of the same length as treatment
, indicating either the strata input by user or those created by the function.
Author(s)
James E. Helmreich James.Helmreich@Marist.edu
Robert M. Pruzek RMPruzek@yahoo.com
KuangNan Xiong harryxkn@yahoo.com
See Also
cv.bal.psa
, loess.psa
Examples
data(lindner)
attach(lindner)
lindner.ps <- glm(abcix ~ stent + height + female +
diabetic + acutemi + ejecfrac + ves1proc,
data = lindner, family = binomial)
ps <- lindner.ps$fitted
cstrata.psa(abcix, ps, strata = 5)
cstrata.psa(abcix, ps, strata = 10)
cstrata.psa(abcix, ps, int = c(.37, .56, .87, 1))
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(PSAgraphics)
Loading required package: rpart
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/PSAgraphics/cstrata.psa.Rd_%03d_medium.png", width=480, height=480)
> ### Name: cstrata.psa
> ### Title: Supports Multiple Methods for Defining and Visualizing (PS)
> ### Strata
> ### Aliases: cstrata.psa
> ### Keywords: hplot
>
> ### ** Examples
>
> data(lindner)
> attach(lindner)
> lindner.ps <- glm(abcix ~ stent + height + female +
+ diabetic + acutemi + ejecfrac + ves1proc,
+ data = lindner, family = binomial)
> ps <- lindner.ps$fitted
> cstrata.psa(abcix, ps, strata = 5)
$Original.Strata
1 2 3 4 5
0 94 76 64 44 20
1 105 123 134 156 180
$Used.Strata
1 2 3 4 5
0 94 76 64 44 20
1 105 123 134 156 180
Strata.Size 199 199 198 200 200
$strata
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1
[38] 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
[75] 1 1 1 1 1 1 1 1 1 1 1 1 1 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8 8 8 8 7 7
[451] 8 8 8 7 7 7 8 8 7 7 7 7 8 8 8 7 8 8 8 8 8 8 7 7 8
[476] 7 8 8 7 8 8 8 8 8 8 7 7 8 8 8 9 7 9 8 8 7 8 7 7 8
[501] 7 7 7 8 8 8 7 8 8 8 8 7 7 8 8 8 7 7 7 10 9 9 9 10 10
[526] 9 9 9 9 10 10 10 10 10 9 9 10 10 9 9 9 9 9 9 10 9 9 9 10 9
[551] 10 10 9 9 8 10 10 9 9 10 9 9 10 9 8 9 10 10 9 9 9 9 9 9 9
[576] 9 9 10 8 10 9 10 10 10 10 9 9 10 10 10 10 9 10 10 10 9 10 10 10 9
[601] 9 10 9 10 9 9 10 9 9 9 9 9 10 10 9 10 10 9 9 10 10 9 10 9 9
[626] 9 9 10 9 10 10 10 10 10 10 10 10 10 10 9 9 9 10 10 9 10 10 10 10 9
[651] 10 9 10 9 10 9 9 10 10 9 10 10 9 9 10 9 10 10 10 9 9 10 10 9 10
[676] 9 10 9 10 10 10 10 10 9 9 10 10 9 9 10 9 10 10 10 9 9 10 10 1 1
[701] 2 1 1 1 1 2 1 2 1 1 1 1 2 1 1 1 1 2 1 1 2 1 1 1 1
[726] 2 2 1 1 1 2 1 2 2 2 1 2 1 1 1 1 2 2 1 1 2 1 1 2 1
[751] 2 1 2 1 1 2 2 2 2 2 2 2 1 1 1 2 1 1 1 1 1 1 1 1 2
[776] 2 2 2 2 1 1 2 1 1 1 2 1 1 1 2 2 1 4 3 3 3 4 4 3 3
[801] 4 3 3 4 3 3 3 4 4 3 4 4 4 4 4 4 3 4 4 3 4 4 4 4 3
[826] 4 4 4 3 4 3 4 3 4 3 4 4 3 4 3 4 3 4 4 3 3 3 3 3 4
[851] 4 3 3 4 3 3 4 4 4 3 4 3 3 4 3 3 3 6 6 6 6 6 5 6 6
[876] 5 6 5 6 4 5 6 5 6 5 6 6 5 6 5 5 5 6 6 6 5 5 6 5 5
[901] 6 5 6 5 5 5 6 6 6 6 5 5 6 6 5 5 5 5 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