{smcl}
{* 19may2021}{...}
{cmd:help rdbalance}{right: }
{hline}
{title:Title}
{p2colset 5 18 20 2}{...}
{p2col:{hi:rdbalance} {hline 2}} Covariate balance statistics with formatted table output in treatment effect analysis and RDD. {p_end}
{p2colreset}{...}
{title:Syntax}
{p 8 16 2}
{cmd:rdbalance} {cmd:}{it:{help varname:treatvar}} {it:{help varlist:varlist}} {ifin}
[{cmd:,} {it:options}]
{synoptset 29 tabbed}{...}
{synopthdr}
{synoptline}
{synopt:{cmdab:s:tatistics:(}{it:{help tabstat##statname:statname}} [{it:...}]{cmd:)}}report specified statistics{p_end}
{synopt:{opt w:t}{cmd:(}{it:{help varname:varname}}{cmd:)}}weight used for calculating weighted statistics{p_end}
{synopt:{opt abs:olute}}produce absolute standardized differences{p_end}
{synopt:{opt f:ormat}{cmd:(%}{it:{help format:fmt}}{cmd:)}}display format for statistics; default format is {cmd:%9.0g}{p_end}
{synopt:{opt case:wise}}perform casewise deletion of observations{p_end}
{synopt:{opt leftc:ontrol}}list control group on the left, which is regarded as group 1, when calculating SMD & VR{p_end}
{synopt:{opt s:aving}{cmd:(}{it:{help filename:filename}}{cmd:)}}specify filename where the statistics, generated by {cmd:rdbalance}, are to be saved. The suboption "replace" is allowed{p_end}
{synopt:{opt excel}}export the results into Excel{p_end}
{synopt:{opt v:line}}add vertical border when exporting results in Excel format{p_end}
{synopt:{opt not:itle}}suppress title in the table header when exporting results in Excel format{p_end}
{synopt:{opt note:s}{cmd:(}{it:string}{cmd:)}}add notes when exporting results in Excel format{p_end}
{synoptline}
{p2colreset}{...}
{p 4 6 2}
{opt by} is allowed; see {manhelp by D}. {p_end}
{title:Description}
{pstd}
{cmd:rdbalance} produces a table of distributional test statistics (see {it:{help tabstat##statname: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, {cmd: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
{it:{help rdbalance##references:Chen et al. (2019)}}. {p_end}
{phang} * SMD: standardized mean differences{p_end}
Mean1 - Mean2
SMD = {hline 19}
sqrt[(Var1+Var2)/2}
{phang} * VR: Variance-Ratio {p_end}
Var1
VR = {hline 4}
Var2
{title:Options}
{phang}
{cmd:statistics(}{it:{help tabstat##statname:statname}} [{it:...}]{cmd:)}
specifies the statistics to be displayed; the default is equivalent to
specifying {cmd:statistics(mean)}. ({opt stats()} is a synonym for
{opt statistics()}.) Multiple statistics may be specified
and are separated by white space, such as {cmd:statistics(mean sd)}.
{phang}
{cmd:wt(}{it:{help varname:varname}}{cmd:)} specifies the weight variable used for balancing covariates.
{phang}
{cmd:absolute} produces the absolute value of the standardized difference; the default is the signed value of the standardized difference.
{phang}
{opt format}{cmd:(%}{it:{help format:fmt}}{cmd:)} specifies the format to be used for all statistics. The maximum width of the specified format should not exceed
nine characters; default format is {cmd:%9.0g}.
{phang}
{opt 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.
{phang}
{opt leftcontrol} lists control group on the left, which is regarded as group 1, when calculating SMD & VR.
{phang}
{cmd:saving(}{it:{help filename:filename}}{cmd:)} specifies the filename where the statistics generated by {cmd:rdbalance} will be saved. {cmd:replace}, used with
{cmd:saving}, specifies that {it:{help filename}} can be replaced if it already exists.
{phang}
{opt excel} exports the results into Excel. This option must be used with {cmd:saving(}{it:{help filename:filename}}{cmd:)}.
{phang}
{opt vline} adds vertical border when exporting results in Excel format.
{phang}
{opt notitle} suppresses title in the table header when exporting results in Excel format.
{phang}
{cmd:notes(}{it:string}{cmd:)} adds {it:string} as notes when exporting results in Excel format.
{title:Examples}
{result}{dlgtab:The web data}{text}
{phang2} * Load example data{p_end}
{phang2}{inp:.} {stata "webuse cattaneo2, clear":webuse cattaneo2, clear}{p_end}
{phang2} * Generate inverse probability of treatment weights (IPTW) {p_end}
{phang2}{inp:.} {stata "logit mbsmoke mmarried c.mage c.mage#c.mage fbaby i.medu":logit mbsmoke mmarried c.mage c.mage#c.mage fbaby i.medu}{p_end}
{phang2}{inp:.} {stata "predict pscore, pr":predict pscore, pr}{p_end}
{phang2}{inp:.} {stata "gen iptw = cond(mbsmoke, 1/pscore, 1/(1-pscore))":gen iptw = cond(mbsmoke, 1/pscore, 1/(1-pscore))}{p_end}
{phang2}{inp:.} {stata "xtile strata = pscore, nq(5)":xtile strata = pscore, nq(5)}{p_end}
{phang2} * Run {cmd:rdbalance} {p_end}
{phang2}{inp:.} {stata "rdbalance mbsmoke mmarried mage fbaby medu":rdbalance mbsmoke mmarried mage fbaby medu}{p_end}
{phang2}{inp:.} {stata "rdbalance mbsmoke mmarried mage fbaby medu, s(mean median variance skewness)":rdbalance mbsmoke mmarried mage fbaby medu, s(mean median variance skewness)}{p_end}
{phang2}{inp:.} {stata "rdbalance mbsmoke mmarried mage fbaby medu, wt(iptw) abs for(%9.3f)":rdbalance mbsmoke mmarried mage fbaby medu, wt(iptw) abs for(%9.3f)}{p_end}
{phang2}{inp:.} {stata "bys strata: rdbalance mbsmoke mmarried mage fbaby medu if strata !=., abs for(%9.3f)":bys strata: rdbalance mbsmoke mmarried mage fbaby medu if strata !=., abs for(%9.3f)}{p_end}
{phang2} * save in Stata {p_end}
{phang2}{inp:.} {stata "rdbalance mbsmoke mmarried mage fbaby medu, wt(iptw) abs for(%9.3f) saving(output, replace)":rdbalance mbsmoke mmarried mage fbaby medu, wt(iptw) abs for(%9.3f) saving(output)}{p_end}
{phang2} * save in Excel {p_end}
{phang2}{inp:.} {stata "rdbalance mbsmoke mmarried mage fbaby medu, wt(iptw) abs for(%9.3f) saving(output.xls, replace) excel":rdbalance mbsmoke mmarried mage fbaby medu, wt(iptw) abs for(%9.3f) saving(output.xls, replace) excel}{p_end}
{result}{dlgtab:Example in Chen(2019)}{text}
{phang2} * Load example data{p_end}
{phang2}{inp:.} {stata "use hukou_jinan.dta, clear":use hukou_jinan.dta, clear}{p_end}
{phang2} * Run {cmd:rdbalance} {p_end}
{phang2}{inp:.} {stata `"local Notes "Notes: House price is the unit price per sq.m.""':local Notes "Notes: House price is the unit price per sq.m."}{p_end}
{phang2}{inp:.} {stata `"global xx price area rooms floor decoration height age elevator green far totalbuild totalhouse"':global xx price area rooms floor decoration height age elevator green far totalbuild totalhouse}{p_end}
{phang2}{inp:.} {stata `"rdbalance yesG1 $xx, s(N mean sd) f(%10.3f) saving(output, replace) excel notes("`Notes'") leftc"':rdbalance yesG1 $xx, s(N mean sd) f(%10.3f) saving(output, replace) excel notes("`Notes'") leftc}{p_end}
{title:Stored results}
{pstd}
{cmd:rdbalance} stores the following in {cmd:r()}, which can be displayed by typing {cmd: return list} after {cmd:rdbalance} is finished (see {help return}):
{synoptset 15 tabbed}{...}
{p2col 5 15 19 2: Scalars}{p_end}
{synopt:{cmd:r(varcnt)}}number of covariates assessed{p_end}
{synopt:{cmd:r(stacnt)}}number of statistics assessed{p_end}
{synopt:{cmd:r(masd)}}mean of the absolute standardized differences{p_end}
{synopt:{cmd:r(mvr)}}mean of the variance ratios{p_end}
{synoptset 15 tabbed}{...}
{p2col 5 15 19 2: Matrices}{p_end}
{synopt:{cmd:r(table)}}balance table{p_end}
{p2colreset}{...}
{title:Acknowledgments}
{pstd}
rdbalance is build upon {help covbal} from Ariel Linden. Compared to covbal, we mainly contribute to the RDD analysis in the following four aspects:{p_end}
{phang}{inp:(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. {p_end}
{phang}{inp:(2)} Freely choose which statistics (see {it:{help tabstat##statname:statname}}) to be reported, while covbal can only report the specific three: mean, variance and skewness. {p_end}
{phang}{inp:(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. {p_end}
{phang}{inp:(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. {p_end}
{marker references}{...}
{title:References}
{pstd}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.{p_end}
{phang2}{inp:.} {browse "https://www.sciencedirect.com/science/article/abs/pii/S0304387818309520?via%3Dihub":View full text}{p_end}
{phang2}{inp:.} {browse "https://data.mendeley.com/datasets/dtzfwv5vf2/1":View dataset on Mendeley Data}{p_end}
{title:Author}
{pstd} Yongli Chen {p_end}
{pstd} Antai College of Economics and Management, Shanghai Jiao Tong University{p_end}
{pstd} E-mail: {browse "mailto:yongli_chan@163.com":yongli_chan@163.com}{p_end}
{pstd} {cmd:Yujun Lian} {p_end}
{pstd} Department of Finance, Lingnan College, Sun Yat-Sen University {p_end}
{pstd} E-mail: {browse "mailto:arlionn@163.com":arlionn@163.com}, Blog: {browse "https://www.lianxh.cn":lianxh.cn} {break}{p_end}
{title:Also see}
{pstd} Online: {helpb tebalance}, {helpb tabstat}, {helpb qqplot}, {helpb pbalchk} (if installed), {helpb imbalance} (if installed) {helpb qqplot3} (if installed){p_end}