# Functions to compute the balance statistics

### 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 |

`matched` |
matched data using |

`pscore.fit` |
glm.fit object to get propensity scores. |

`factor` |
default is |

`x` |
an object return by the balance function. |

`digits` |
minimal number of |

`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) |

`v.axis` |
default is |

`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 |

`plot` |
default is |

`...` |
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 jh1030@columbia.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

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)
``` |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.