R/bal.ms.psa.R
bal.ms.psa.Rd
Function provides a measure (based on the trimmed mean) of the balance achieved between control and treatment groups for a continuous covariate from user defined strata. This statistic is compared to the same measure for randomly permuted strata.
bal.ms.psa(
continuous,
treatment = NULL,
strata = NULL,
trim = 0,
B = 1000,
main = NULL
)
Quantitative covariate that is being balanced within
strata in a PSA. If continuous
has three columns, then the second
and third are assumed to be the treatment and strata respectively. Missing
values are not allowed.
Binary variable of same length as continuous
;
generally 0 for 'control,' 1 for 'treatment.'
Integer variable; a vector of same length as continuous
indicating the derived strata from estimated propensity scores.
Fraction (0 to 0.5) of observations to be trimmed from each end
of stratum-treatment level before the mean is computed. See
mean
.
Numeric; number of randomly generated iterations of the balance measure are created for the comparison distribution.
Title passed to histogram
.
In addition to the histogram, a list with the following components is returned:
Balance measure of user defined strata.
Rank of original balance measure in comparison with the B randomly generated values.
This function measures the balance achieved across K strata for a continuous covariate. If \( \mu_{ik} \) is the covariate trimmed (as specified by user) mean of cases in stratum k, treatment i, then the statistic is the sum over all K of \( |\mu_{0k} - \mu_{1k}| \). A permutation distribution is generated by randomly assigning cases to strata, thus generating B permuted stratifications and the associated B permutation statistics. The permutation stratifications are generated under a fixed marginals model to retain comparability with the original stratification. A histogram of the permutation statistics is produced with the original statistic referenced as a red dot.
bal.ks.psa
, bal.cws.psa
, bal.cs.psa
#Balance stat should be close to zero
meas<-rnorm(500)
continuous<-c(meas,meas+rnorm(500,0,.1))
treatment<-c(rep(0,500),rep(1,500))
strata<-rep(c(rep(1,100),rep(2,100),rep(3,100),rep(4,100),rep(5,100)),2)
bal.ms.psa(continuous,treatment,strata)
#> $balance.orig
#> [1] 0.009313108
#>
#> $rank.orig
#> [1] 1
#>
#Balance stat should be close to .4
meas<-rnorm(500)
continuous<-c(meas, meas[1:250] + runif(250,0,.2),
meas[251:500]-runif(250,0,.2))
treatment<-c(rep(0,500),rep(1,500))
strata<-rep(c(rep(1,100), rep(2,100), rep(3,100),
rep(4,100),rep(5,100)),2)
bal.ms.psa(continuous, treatment, strata, B=200)
#> $balance.orig
#> [1] 0.07968108
#>
#> $rank.orig
#> [1] 68
#>