Introduction

This page contains Stata code and output, equivalent to the examples in the paper. In all cases, the data are random samples from the freely-available NHANES dataset, and the variables used are;

To run the code, the following packages must first be installed;

Following this, cut-and-paste the code for each figure into an R session.

Figure 1

insheet using http://faculty.washington.edu/kenrice/heartgraphs/nhanessmall.csv, clear
label variable bpxsar "Systolic Blood Pressure (mmHg)"
stripplot bpxsar 

Figure 1a

stripplot bpxsar, stack center 

Figure 1b

Figure 2

insheet using http://faculty.washington.edu/kenrice/heartgraphs/nhanesmedium.csv, clear
label variable bpxsar "Systolic Blood Pressure (mmHg)"
stripplot bpxsar

Figure 2a

stripplot bpxsar, stack center 

Figure 2b

stripplot bpxsar, width(1) stack center 

Figure 2c

Figure 3

insheet using http://faculty.washington.edu/kenrice/heartgraphs/nhaneslarge.csv, clear
label variable bpxsar "Systolic Blood Pressure (mmHg)"
vioplot bpxsar, horizontal 

Figure 3a

histogram bpxsar

Figure 3b

Figure 4

insheet using http://faculty.washington.edu/kenrice/heartgraphs/nhaneslarge.csv, clear
generate normotens = bpxsar <= 140
label define normotensl 1 "<= 140 mmHg" 0 "> 140 mmHg" 
label values normotens normotensl
generate sample = 1
graph hbar (percent) sample, over(normotens) asyvars stack

Figure 4a

insheet using http://faculty.washington.edu/kenrice/heartgraphs/nhaneslarge.csv, clear
generate normotens = bpxsar <= 140
collapse (mean) est=normotens (sebinomial) stderr=normotens
generate loCI = est - 1.96*stderr
generate hiCI = est + 1.96*stderr
generate x = 1
label variable x "Estimate"
label variable loCI "95% Conf Int"
label variable hiCI "95% Conf Int"
twoway (scatter x est) (rspike loCI hiCI x, horizontal), ///
xscale( r(0 1) ) xtick( 0(0.2)1 ) xlabel( 0(0.2)1) yscale(off)

Figure 4b

insheet using http://faculty.washington.edu/kenrice/heartgraphs/nhaneslarge.csv, clear
generate sample = 1
graph hbar (percent) sample, over(race_ethc) asyvars stack

Figure 4c

insheet using http://faculty.washington.edu/kenrice/heartgraphs/nhaneslarge.csv, clear
generate x=1
collapse (count) x, by(race_ethc)
generate est = x/1000
generate stderr = sqrt(est*(1-est)/1000)
generate loCI = est - 1.96*stderr
generate hiCI = est + 1.96*stderr
generate study = _n
label variable study "Estimate"
label variable loCI "95% Conf Int"
label variable hiCI "95% Conf Int"
twoway (scatter study est) (rspike loCI hiCI study, horizontal), ///
xscale( r(0 1) ) xtick( 0(0.2)1 ) xlabel( 0(0.2)1) /// 
ylabel( 1 "Black non-Hispanic" 2 "Hispanic" 3 "Other" 4 "White non-Hispanic", angle(0)) ///
ytitle("")

Figure 4d

Figure 5

insheet using http://faculty.washington.edu/kenrice/heartgraphs/nhaneslarge.csv, clear
generate normotens = bpxsar <= 140
label define normotensl 1 "<= 140 mmHg" 0 "> 140 mmHg" 
label values normotens normotensl
generate x = 1
graph pie x, over(normotens)

Figure 5a

insheet using http://faculty.washington.edu/kenrice/heartgraphs/nhaneslarge.csv, clear
generate x = 1
graph pie x, over(race_ethc)

Figure 5b

Figure 6

insheet using http://faculty.washington.edu/kenrice/heartgraphs/nhanessmall.csv, clear
label variable dr1tfola "Folate intake (ug/day)"
label define sexl 1 "Male" 2 "Female" 
label values riagendr sexl
stripplot dr1tfola, vertical over(riagendr)

Figure 6a

insheet using http://faculty.washington.edu/kenrice/heartgraphs/nhanesmedium.csv, clear
label variable dr1tfola "Folate intake (ug/day)"
label define sexl 1 "Male" 2 "Female" 
label values riagendr sexl
stripplot dr1tfola, width(20) vertical stack center over(riagendr)