help rdbalance

Title

rdbalance -- Covariate balance statistics with formatted table output in treatment effect analysis and RDD.

Syntax

rdbalance treatvar varlist [if] [in]
[, options]

statistics:(statname [...]) report specified statistics

wt(varname) weight used for calculating weighted statistics

absolute produce absolute standardized differences

format(%fmt) display format for statistics; default format is %9.0g

casewise perform casewise deletion of observations

leftcontrol list control group on the left, which is regarded as group 1, when calculating SMD & VR

saving(filename) specify filename where the statistics, generated by rdbalance, are to be saved. The suboption "replace" is allowed

excel export the results into Excel

vline add vertical border when exporting results in Excel format

notitle suppress title in the table header when exporting results in Excel format

notes(string) add notes when exporting results in Excel format

by is allowed; see [D] by.

Description

rdbalance produces a table of distributional test statistics (see statname) for each covariate specified, and assesses balance between treatment groups in the means
(using the standardized difference) and in the variances (using the variance ratio). It allows you to specify the list of statistics to be displayed and can export table directly to excel.
When applying RDD methods, rdbalance can be used to summarize the statistics for two subsamples that center on the cutoff point and test the balance between the control group and the treatment group through two perspectives: the
means (SMD) and standard errors (VR). SMD denotes the standardized mean difference between the two groups of data, while VR denotes the variance difference. For example usage of this command, see
Chen et al. (2019).

* SMD: standardized mean differences

Mean1 - Mean2
SMD =

sqrt[(Var1+Var2)/2}

* VR: Variance-Ratio

Var1
VR = ----
Var2

Options

statistics(statname [...])
specifies the statistics to be displayed; the default is equivalent to
specifying statistics(mean). (stats() is a synonym for
statistics().) Multiple statistics may be specified
and are separated by white space, such as statistics(mean sd).

wt(varname) specifies the weight variable used for balancing covariates.

absolute produces the absolute value of the standardized difference; the default is the signed value of the standardized difference.

format(%fmt) specifies the format to be used for all statistics. The maximum width of the specified format should not exceed
nine characters; default format is %9.0g.

casewise specifies casewise deletion of observations. Statistics
are to be computed for the sample that is not missing for any of the
variables in varlist. The default is to use all the nonmissing values
for each variable.

leftcontrol lists control group on the left, which is regarded as group 1, when calculating SMD & VR.

saving(filename) specifies the filename where the statistics generated by rdbalance will be saved. replace, used with
saving, specifies that filename can be replaced if it already exists.

excel exports the results into Excel. This option must be used with saving(filename).

vline adds vertical border when exporting results in Excel format.

notitle suppresses title in the table header when exporting results in Excel format.

notes(string) adds string as notes when exporting results in Excel format.

Examples

The web data

* Load example data

. webuse cattaneo2, clear

* Generate inverse probability of treatment weights (IPTW)

. logit mbsmoke mmarried c.mage c.mage#c.mage fbaby i.medu

. predict pscore, pr

. gen iptw = cond(mbsmoke, 1/pscore, 1/(1-pscore))

. xtile strata = pscore, nq(5)

* Run rdbalance

. rdbalance mbsmoke mmarried mage fbaby medu

. rdbalance mbsmoke mmarried mage fbaby medu, s(mean median variance skewness)

. rdbalance mbsmoke mmarried mage fbaby medu, wt(iptw) abs for(%9.3f)

. bys strata: rdbalance mbsmoke mmarried mage fbaby medu if strata !=., abs for(%9.3f)

* save in Stata

. rdbalance mbsmoke mmarried mage fbaby medu, wt(iptw) abs for(%9.3f) saving(output)

* save in Excel

. rdbalance mbsmoke mmarried mage fbaby medu, wt(iptw) abs for(%9.3f) saving(output.xls, replace) excel

Example in Chen(2019)

* Load example data

. use hukou_jinan.dta, clear

* Run rdbalance

. House price is the unit price per sq.m.""':local Notes "Notes: House price is the unit price per sq.m."

. global xx price area rooms floor decoration height age elevator green far totalbuild totalhouse

. rdbalance yesG1 $xx, s(N mean sd) f(%10.3f) saving(output, replace) excel notes("`Notes'") leftc

Stored results

rdbalance stores the following in r(), which can be displayed by typing return list after rdbalance is finished (see return):

Scalars

r(varcnt) number of covariates assessed

r(stacnt) number of statistics assessed

r(masd) mean of the absolute standardized differences

r(mvr) mean of the variance ratios

Matrices

r(table) balance table

Acknowledgments

rdbalance is build upon covbal from Ariel Linden. Compared to covbal, we mainly contribute to the RDD analysis in the following four aspects:

(1) Add a casewise option to decide whether statistics are to be computed for the full sample or the casewise sample, while covbal can only realise the latter.

(2) Freely choose which statistics (see statname) to be reported, while covbal can only report the specific three: mean, variance and skewness.

(3) Export results as excel files or stata files and add some options related to excel styling, while covbal can only export results as stata files.

(4) Freely choose which group to be listed first in the table, which therefore decides the computation of SMD and VR, while covbal can list only the treatment group first.

References

Chen Y, Shi S, Tang Y. Valuing the urban hukou in China: Evidence from a regression discontinuity design for housing prices[J]. Journal of Development Economics, 2019, 141: 102381.

. View full text

. View dataset on Mendeley Data

Author

Yongli Chen

Antai College of Economics and Management, Shanghai Jiao Tong University

E-mail: yongli_chan@163.com

Yujun Lian

Department of Finance, Lingnan College, Sun Yat-Sen University

E-mail: arlionn@163.com, Blog: lianxh.cn

Also see

Online: tebalance, tabstat, qqplot, pbalchk (if installed), imbalance (if installed) qqplot3 (if installed)