Simple function that calls fisher.test repeatedly for each strata, testing the independence of treatements for the given covariate within strata.

bal.fe.psa(categorical, treatment = NULL, strata = NULL, FB = 2000)

Arguments

categorical

Categorical covariate that is being balanced within strata in a PSA. If categorical has three columns, then the second and third are assumed to be the treatment and strata respectively. Missing values are not allowed. May be factor or numeric.

treatment

Binary variable of same length as categorical; generally 0 for 'control,' 1 for 'treatment.'

strata

Integer variable; a vector of same length as categorical indicating the derived strata from estimated propensity scores.

FB

Numeric; number of replications sent to fisher.test.

Value

Returns list of the same lenght as the number of strata containing p-values for the indpendence of treatment within each stratum derived from Fisher's Exact test.

Details

This function makes repeated calls to fisher.test, Fisher's Exact test, to test whether the distribution of the covariate categorical is independent of treatment within each stratum; a list of p-values for the test for each stratum are returned.

See also

bal.cs.psa, bal.ms.psa, bal.ks.psa

Author

James E. Helmreich James.Helmreich@Marist.edu

Robert M. Pruzek RMPruzek@yahoo.com

Examples

#Everything random
categorical<-sample(4, 1000, replace = TRUE)
treatment<-sample(c(0,1), 1000, replace = TRUE)
strata<-sample(5, 1000, replace = TRUE)
bal.fe.psa(categorical, treatment, strata)
#> [1] 0.3232707 0.9019826 0.9424025 0.8163853 0.5820495

#Perfect balance on 80%, random on last 20%
categorical<-rep(sample(5,1000, replace=TRUE), 2)
treatment<-c(rep(0,1000), rep(1,1000))
strata<-sample(6, 1200, replace=TRUE)
strata<-c(strata[1:1000], strata[1:800], strata[1001:1200])
bal.fe.psa(categorical, treatment, strata)
#> [1] 0.9660232 1.0000000 0.9991617 0.9148779 0.9988467 0.9924836