*! version 17.0 30mar2023

dgraph Plots and tables for stacked t tests

Syntax

dgraph varlist(min=1), by(string) [ label long reverse echo suppress ci(num) graphoptions ]

Description

This package generates a stacked coefficient plot for two-tailed t-tests.
It is very useful for showcasing, through a very simple line of code, a graphical
representation of covariates imbalance between groups. Several dependent variables
can be tested in a single run. Results can be stored in a LaTeX table.

For more info and updates, please visit: https://github.com/DiegoCiccia/dgraph

Options

Baseline options

varlist: (required) outcome variables. Only numeric variables can be included in varlist.

by(string): (required) dummy variable defining two estimation groups. It can be numeric or string, but it must take only two distinct values.

label: use variable labels in place of variable names.

long: stack confidence intervals horizontally (starting from the left side);. By default, confidence intervals are stacked vertically (starting from the bottom).

reverse: shown point estimates as the average y(1) - y(0). As in the Stata ttest command, by default y(0) - y(1) is shown.

echo: print in the Stata console a table with the numeric values of the average difference between groups and upper/lower bounds for the estimate for each of the variables in varlist.

suppress: (often used in combination with echo and tabsaving) the graph is not produced, while values can be still displayed in console or printed in file.

ci(num): level of confidence. By default, ci(95) is specified

Graph options

title(string), subtitle(string): specify title and subtitle of the graph. By default, no title nor subtitle.

lc(string), lw(num), lp(string): change the color, width and patters of the lines in confidence intervals.

mc(string), ms(num): change color and size of scatter points for point estimates and upper/lower bounds.

sl(num), sw(num): change length and width of segments at the edges of confidence intervals.

seplc(string), seplp(string), seplw(num): change the color, width and pattern of the separation line (0 by default).

labsize(num), labangle(num): change size and angle orientation of variable labels on the graph.

scheme(string): change the graph scheme.

ysize(num), xsize(num): change the axes sizes.

saving(string): save the graph as a .gph file.

replace: replaces previous savings.

tabsaving(string): saves the echo output as a TeX tabular (automatic replace).

Example

Setup

clear

set seed 0

set obs 20000

forv i = 1/30 {

gen var_`i' = rnormal()

label var var_`i' "Dep Var `i'"

}

gen D = runiform() > 0.5

tostring D, replace

Test all 30 variables generated by the previous routine by dummy string D.

dgraph var_*, by(D) long labangle(45) label scheme(white_tableau) title("Graph") reverse mc(black) msize(1) lw(0.2) ci(90) labsize(vsmall) saving(gr_sample) replace echo tabsaving(table)