# balance: Functions to compute the balance statistics In arm: Data Analysis Using Regression and Multilevel/Hierarchical Models

## Description

This function computes the balance statistics before and after matching.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```balance(rawdata, matched, pscore.fit, factor=TRUE) ## S3 method for class 'balance' print(x, ..., digits = 2) ## S3 method for class 'balance' plot(x, longcovnames = NULL, main = "Standardized Difference in Means", v.axis=TRUE, cex.main = 1, cex.vars = 0.8, cex.pts = 0.8, mar=c(0,3,5.1,2), plot=TRUE, ...) ```

## Arguments

 `rawdata` data before using `matching` function, see the example below. `matched` matched data using `matching` function, see the example below. `pscore.fit` glm.fit object to get propensity scores. `factor` default is `TRUE` which will display the factorized categorical variables. In a situation where no equal levels of factorized categorical variables is observed, use factor=FALSE to proceed. `x` an object return by the balance function. `digits` minimal number of significant digits, default is 2. `longcovnames` long covariate names. If not provided, plot will use covariate variable name by default `main` The main title (on top) using font and size (character expansion) `par("font.main")` and color `par("col.main")`; default title is `Standardized Difference in Means`. `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. `...` 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 [email protected]; Yu-Sung Su [email protected]

## References

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

`matching`, `par`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16``` ```# 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 <- lalonde[matches\$matched,] # balance check b.stats <- balance(lalonde, matched, fit) print(b.stats) plot(b.stats) par(old.par) ```

### Example output

```Loading required package: MASS

arm (Version 1.9-3, built: 2016-11-21)

Working directory is /work/tmp

Differences in Means of Unmatched Data
--
Treat control   diff diff.std     se      sd
re74           2095.57 2107.03 -11.45     0.00 503.50 5302.42
re75           1532.06 1266.91 265.15     0.08 305.04 3161.65
age              25.82   25.05   0.76     0.11   0.68    7.11
factor(educ)4     0.00    0.00   0.00    -0.09   0.00    0.04
factor(educ)5     0.02    0.00   0.02     0.16   0.01    0.11
factor(educ)6     0.02    0.01   0.01     0.08   0.01    0.11
factor(educ)7     0.01    0.02  -0.01    -0.10   0.01    0.10
factor(educ)8     0.01    0.03  -0.02    -0.12   0.01    0.14
factor(educ)9     0.10    0.08   0.02     0.06   0.03    0.29
factor(educ)10    0.15    0.15   0.00    -0.01   0.03    0.36
factor(educ)11    0.17    0.27  -0.11    -0.26   0.04    0.41
factor(educ)12    0.24    0.27  -0.03    -0.07   0.04    0.44
factor(educ)13    0.21    0.14   0.07     0.19   0.04    0.38
factor(educ)14    0.04    0.02   0.02     0.14   0.02    0.17
factor(educ)15    0.03    0.01   0.02     0.15   0.01    0.13
factor(educ)16    0.01    0.00   0.01     0.10   0.01    0.05
black             0.01    0.00   0.01     0.10   0.01    0.05
hisp              0.84    0.83   0.02     0.04   0.04    0.37
married           0.06    0.11  -0.05    -0.17   0.03    0.28
nodegr            0.19    0.15   0.04     0.09   0.04    0.38
u74               0.71    0.83  -0.13    -0.30   0.04    0.42
u75               0.71    0.75  -0.04    -0.09   0.04    0.44
--

Differences in Means of Matched Data
--
Treat control   diff diff.std     se      sd
re74           2095.57 1744.47 351.11     0.07 503.50 5302.42
re75           1532.06 1410.79 121.27     0.04 305.04 3161.65
age              25.82   24.86   0.96     0.13   0.68    7.11
factor(educ)4     0.02    0.01   0.02     0.37   0.01    0.04
factor(educ)5     0.02    0.01   0.01     0.05   0.01    0.11
factor(educ)6     0.01    0.01   0.00     0.00   0.01    0.11
factor(educ)7     0.01    0.01   0.01     0.05   0.01    0.10
factor(educ)8     0.10    0.10  -0.01    -0.04   0.02    0.14
factor(educ)9     0.15    0.18  -0.03    -0.11   0.03    0.29
factor(educ)10    0.17    0.16   0.01     0.01   0.04    0.36
factor(educ)11    0.24    0.30  -0.06    -0.14   0.04    0.41
factor(educ)12    0.21    0.19   0.02     0.05   0.04    0.44
factor(educ)13    0.04    0.03   0.02     0.04   0.03    0.38
factor(educ)14    0.03    0.01   0.02     0.09   0.01    0.17
factor(educ)15    0.01    0.00   0.01     0.04   0.01    0.13
factor(educ)16    0.01    0.00   0.01     0.10   0.01    0.05
black             0.84    0.86  -0.02    -0.31   0.03    0.05
hisp              0.06    0.06   0.00     0.00   0.03    0.37
married           0.19    0.15   0.04     0.14   0.03    0.28
nodegr            0.71    0.77  -0.06    -0.17   0.04    0.38
u74               0.71    0.72  -0.02    -0.04   0.04    0.42
u75               0.60    0.62  -0.02    -0.05   0.05    0.44
--

\$raw
re74           re75            age  factor(educ)4  factor(educ)5
-0.002159921    0.083863254    0.107277121   -0.087705802    0.158623414
factor(educ)6  factor(educ)7  factor(educ)8  factor(educ)9 factor(educ)10
0.078298987   -0.098299879   -0.118377488    0.057923710   -0.006921703
factor(educ)11 factor(educ)12 factor(educ)13 factor(educ)14 factor(educ)15
-0.256078933   -0.072042948    0.190980849    0.138025647    0.148068395
factor(educ)16          black           hisp        married         nodegr
0.103975049    0.103975049    0.043886611   -0.174561071    0.093640701
u74            u75
-0.303986439   -0.094140477

\$matched
re74           re75            age  factor(educ)4  factor(educ)5
0.06621614     0.03835607     0.13463030     0.36978662     0.04823636
factor(educ)6  factor(educ)7  factor(educ)8  factor(educ)9 factor(educ)10
0.00000000     0.05324577    -0.03971374    -0.11366162     0.01499702
factor(educ)11 factor(educ)12 factor(educ)13 factor(educ)14 factor(educ)15
-0.14431246     0.04961898     0.04280605     0.09321213     0.04139547
factor(educ)16          black           hisp        married         nodegr
0.10397505    -0.31192515     0.00000000     0.13694015    -0.17185823
u74            u75
-0.03896622    -0.04858863
```

arm documentation built on May 31, 2017, 3:34 a.m.