Stata Graphing for Economists
Basic twoway scatterplot
sysuse sp500 graph twoway scatter close date
Line Plot
graph twoway line close date
Connected Line Plot
graph twoway connected close date
Immediate scatterplot
graph twoway scatteri /// 965.8 15239 (3) "Low 965.8" /// 1373.73 15005 (3) "High 1373.73" , msymbol(i)
Note: Including (3) denotes the label position, by default labels are positioned at 3 o'clock
Scatterplot and Immediate Scatterplot
graph twoway /// (scatter close date) /// (scatteri 965.8 15239 (3) "Low, 9/21, 965.8" /// 1373.7 15005 (3) "High, 1/30, 1373.7", msymbol(i) )
Area Graph
drop if _n > 57 graph twoway area close date, sort
Bar plot
graph twoway bar close date
Spike plot
graph twoway spike close date
Dropline plot
graph twoway dropline close date
Dot plot
graph twoway dot change date
Range plot with area shading
graph twoway rarea high low date
Range plot with bars
graph twoway rbar high low date
Range plot with spikes
graph twoway rspike high low date
Range plot with capped spikes
graph twoway rcap high low date
Range plot with spikes capped with symbols
graph twoway rcapsym high low date
Range plot with markers
graph twoway rscatter high low date
Range plot with lines
graph twoway rline high low date
Range plot with lines and markers
graph twoway rconnected high low date
Median band line plot
use http://www.ats.ucla.edu/stat/stata/notes/hsb2, clear graph twoway mband read write
Spline line plot
graph twoway mspline read write
LOWESS line plot
graph twoway lowess read write
Linear prediction plot
graph twoway lfit read write
Quadratic prediction plot
graph twoway qfit read write
Fractional polynomial plot
graph twoway fpfit read write
Linear prediction plot with confidence intervals
graph twoway lfitci read write
Quadratic plot with confidence intervals
graph twoway qfitci read write
Fractional polynomial plot with CIs
graph twoway fpfitci read write
Histogram
graph twoway histogram read
Kernel density plot
graph twoway kdensity read
Function plot
graph twoway function y=normden(x), range(-4 4)
Keywords: Andrew Johnston, Andrew, Johnston, Education, Wharton, vita, curriculum vitae, cv, economics, applied economics, economist, microeconomics, empirics, empirical economics