balance: Functions to compute the balance statistics

balanceR Documentation

Functions to compute the balance statistics

Description

This function computes the balance statistics before and after matching.

Usage

balance(rawdata, treat, matched, estimand="ATT")

## S3 method for class 'balance'
print(x, ..., combined = FALSE, digits = 2)

## S3 method for class 'balance'
plot(x, longcovnames=NULL, which.covs="mixed",
    v.axis=TRUE, cex.main=1, cex.vars=1, cex.pts=1,
    mar=c(4, 3, 5.1, 2), plot=TRUE, x.max = NULL, ...)

Arguments

rawdata

The full covariate dataset

treat

the vector of treatment assignments for the full dataset

matched

vector of weights to apply to the full dataset to create the restructured data: for matching without replacement these will all be 0's and 1's; for one-to-one matching with replacement these will all be non-negative integers; for IPTW or more complicated matching methods these could be any non-negative numbers

estimand

can either be ATT, ATC, or ATE, default is ATT

x

an object return by the balance function.

combined

default is FALSE

digits

minimal number of significant digits, default is 2.

longcovnames

long covariate names. If not provided, plot will use covariate variable name by default

which.covs

mixed then it plots all as std diffs; binary it only plots binary and as abs unstd diffs; cont it only plots non-binary and as abs std diffs

v.axis

default is TRUE, which shows the top axis–axis(3).

cex.main

font size of main title

cex.vars

font size of variabel names

cex.pts

point size of the estimates

mar

A numerical vector of the form c(bottom, left, top, right) which gives the number of lines of margin to be specified on the four sides of the plot. The default is c(0,3,5.1,2).

plot

default is TRUE, which will plot the plot.

x.max

set the max of the xlim, default is NULL

...

other plot options may be passed to this function

Details

This function plots the balance statistics before and after matching. The open circle dots represent the unmatched balance statistics. The solid dots represent the matched balance statistics. The closer the value of the estimates to the zero, the better the treated and control groups are balanced after matching.

Note

The function does not work with predictors that contain factor(x), log(x) or all other data transformation. Create new objects for these variables. Attach them into the original dataset before doing the matching procedure.

Author(s)

Jennifer Hill jennifer.hill@nyu.edu; Yu-Sung Su suyusung@tsinghua.edu.cn

References

Andrew Gelman and Jennifer Hill. (2006). Data Analysis Using Regression and Multilevel/Hierarchical Models. Cambridge University Press. (Chapter 10)

See Also

matching, par

Examples

# matching first
old.par <- par(no.readonly = TRUE)
data(lalonde)
attach(lalonde)
fit <- glm(treat ~ re74 + re75 + age + factor(educ) + 
            black + hisp + married + nodegr + u74 + u75, 
            family=binomial(link="logit"))
pscores <- predict(fit, type="link")
matches <- matching(z=lalonde$treat, score=pscores)
matched <- matches$cnts

# balance check
b.stats <- balance(lalonde, treat, matched, estimand = "ATT")
print(b.stats)
plot(b.stats)
par(old.par)

arm documentation built on April 1, 2024, 3:01 p.m.

Related to balance in arm...