*! version 1.0 07mar2013

Title

stddiff -- Calculate standardized differences between groups for continuous and categorical variables

Syntax

Standardized differences of variables in varlist

stddiff
[varlist]
[if] [in],
by(varlist:groupvar)
[options]

Immediate form of standardized differences for continuous variables

stddiffi
[#obs1] #mean1 #sd1 [#obs2] #mean2 #sd2
,
[options]

Immediate form of standardized differences for categorical variables

stddiffi
#11 #12 \ #21 #22 [\ ...]

by specifices the grouping variable. by must be a two level variable and is not optional when varlist is specified.

cohensd calculates Cohen's d, adjusting for sample size.

hedgesg calculates Hedges's g.

abs calculates absolute values of the standardized difference.

Description

stddiff calculates the standardized difference between two groups for both continuous and categorical variables. Standardized difference estimates are increasingly used to compare groups in clinical trials
and observational studies, in preference over p-values. Some have proposed that an absolute standardized difference of 0.10 or more indicates that covariates are imbalanced between groups (see Austin 2001).

stddiff calculaates standardized differences using the method of Yange and Dalton for both continuous and categorical variables. Categorical variables must be entered using Stata's factor variable notation (e.g., i.var)
. If the options cohensd or hedgesg are specified, stddif is a wrapper for esize twosample. See [R] esize.

stddiffi is an immediate form of stddiff. If 4 numbers are entered, stddiffi calculates the standard difference using the formula (mean1-mean2)/((sd1^2+sd2^2)/2).
If 6 numbers are entered, stddiffi calculates the standarized difference using the formulas specified in esize. One of cohensd or hedgesg must be specifed.
If both are specified, only Hedge's g is calculated.
For categorical variables, numbers should be entered as they are for tabi, with rows separated by a backslash (\). Each row must have exactly two columns.

Options

cohensd calculates Cohen's d using the formula specified by { help esize}, which adjusts for sample size.

hedgesg calculates Heges's d using the formula specified by { help esize}, which adjusts for a bias in estimating Cohen's d. If both cohensd and hedgesg are specified, only hedgesg will be calculated.

abs reports absolute values of the standardized difference.

Examples

Setup

. webuse depression

Standard difference for a continuos variable

. stddiff age, by(sex)

Standard difference for a categorical variable

. stddiff i.race, by(sex)

Absolute standard differences for multiple variables using Hedge's g for continuous variables

. stddiff age i.race q*, by(sex) hedgesg abs

Immediate form of stddiffi using means and standard deviations

. stddiffi 36.37 9.46 36.97 9.53

Immediate form of stddiffi using number of observations, means, and standard deviations calculating Cohen's d

. stddiffi 712 36.37 9.46 288 36.97 9.53, cohensd

Immediate form of stddiffi for a categorical variable

. stddiffi 88 45 \ 259 95 \ 365 148

Stored results

stddiff stores the following in
r():

r(stddiff) Matrix of standardized differences

r(output) Matrix containing results tables (for expoort to excel or other further editing)

stddiffi stores the following in
r():

r(std_diff) Standarized difference

stddiffi with categorical variables also stores the following in
r():

r(table) Matrix containing input table

References

Yang DS, Dalton JE.
A Unified Approach to Measuring the Effect Size Between Two Groups Using
SAS. SAS Global Forum 2012. Paper 335 .

Austin PC.
Balance diagnostics for comparing the distribution of baseline covariates between treatment groups in propensity-score matched samples.
Stat Med. 2009 Nov 10; 28(25): 3083–3107. doi:10.1002/sim.3697