help for xbalance

STANDARDIZED DIFFERENCES FOR STRATIFIED COMPARISONS

xbalance treatement strata varlist

Description

Given a treatment variable, a stratifying factor, and covariates,
xbalance calculates standardized differences (biases) along each
covariate, with and without the stratification. Also, tests for conditional
independence of the treatment variable and the covariates within strata.
Provides both stratified and unstratified analysis.

In the unstratified case, the standardized difference of
covariate means is the mean in the treatment group minus
the mean in the control group, divided by the sd
in the same variable estimated by pooling treatment and control
group sds on the same variable. In the stratified case, the
denominator of the standardized difference remains the same but
the numerator is a weighted average of within-stratum differences
in means on the covariate. By default, each stratum is weighted in proportion
to the harmonic mean of the number of
treated units (a) and control units (b) in the stratum; this weighting is
optimal under certain modeling assumptions (discussed in Kalton 1968,
Hansen and Bowers 2008).

Remarks

To use xBalance, you must install R, available from CRAN:
http://cran.r-project.org/ You must also install the RItools package
prior to using. The source and binary code is available via the CRAN repository system for versions of R later than 2.7.0 so installation should simply use (from your R prompt):

install.packages("RItools")

If you want to install RItools for versions of R more current than 2.2 but earlier than 2.7, you'll have to use:

install.packages("Ritools",type="source",dep=TRUE)

If you don't already have the SparseM package installed, you will need the tools required to compile fortran libraries installed in order to build SparseM, specifically gfortran. You should have all the tools you need if you have the full distribution of R (as compared to the "mini" distribution).

After installing RItools, you will need to install the Rsource Stata package.
To install Rsource from SSC:

ssc install rsource

You must set the global Rterm_path prior to running
xbalance. Examples, on Windows and Unix (such as Mac OS X) respectively:

.global Rterm_path `"c:\r\R-2.5.0\bin\Rterm.exe"'

.global Rterm_path `"/usr/bin/R"'

You may find it convenient to add this to your profile.do.

Examples

Example using a binary treatment with labels:

sysuse auto

gen price10k=0

replace price10k=1 if price>10000

xbalance foreign price10k mpg rep78 weight length make

Notice that although foreign has labels "Domestic" and "Foreign" in Stata, it becomes coded as "Domestic"=FALSE=0 and "Foreign"=TRUE=1 in R because of a requirement that treatment be either logical (aka binary) or numeric.

Example using a binary treatment without labels:

xbalance price10k foreign mpg

Example using a continuous treatment variable and multiple covariates. Notice that missing values on rep78 receive their own test.

xbalance price foreign mpg rep78 weight length make

An example of a test without stratification.

gen constant=1

xbalance price10k constant foreign mpg rep78

Author

Jake Bowers <jwbowers@illinois.edu>, Mark Fredrickson
<mark.m.fredrickson@gmail.com>, and Ben Hansen <ben.hansen@umich.edu>

Also see

On-line help from R.