Stata 12 Graphics May 2013cc - Princeton University

1y ago
9 Views
2 Downloads
1.72 MB
49 Pages
Last View : 5d ago
Last Download : 3m ago
Upload by : Allyson Cromer
Transcription

Stata 12 Graphics Dawn Koffman Office of Population Research Princeton University June 2013

Stata 12 Graphics Pros: Many graph types and plot types provided Multiple plot types may be overlaid Can easily change overall look of graphs Same options available for most types of graphs Very flexible Cons: Large syntax: 665 page graphics manual! Rather slow Interactive, point-and-click Graph Editor - However, as of Stata 11: can record edits and apply them to other graphs Stata Graphics References: http://data.princeton.edu/stata/Graphics.html, by German Rodriguez A Visual Guide To Stata Graphics, Third Edition, by Michael Mitchell Stata 12 Graphics Manual (may want to start with “graph intro”) 2

Stata Graphics Syntax graph graphtype graph bar graph twoway plottype graph twoway scatter graph twoway line graph twoway lfit graph twoway lfitci graphs commands may have options some options have suboptions or a list of options graph twoway scatter var1 var2, xlabel(30(10)100, labsize(small)) appearance of graph defined by graph elements: data - marker symbols, lines elements within plot region – text, marker labels, line labels elements outside plot region – titles, legend, notes, axis labels, tick marks, axis titles size and shape of plot region and entire graph 3

/* OR */ 50 twoway line le year 70 graph twoway line le year life expectancy 60 sysuse uslifeexp.dta, clear 80 Stata Graphics Syntax: A Simple Example 40 /* OR */ line le year 1900 1920 1940 1960 1980 2000 Year 4

80 40 50 line le year, scheme(s1mono) life expectancy 60 70 Using Schemes 1900 1920 1940 1960 1980 2000 Year 80 line le year, scheme(economist) /* to see list of scheme names: graph query, schemes 60 life expectancy 70 50 to change default scheme: set scheme schemename */ 1900 1920 1940 1960 1980 40 2000 Year 5

Multiple Dependent Variables 30 40 50 60 70 80 line le wmale le wfemale le bmale le bfemale year 1900 1920 1940 Year Life expectancy, white males Life expectancy, black males 1960 1980 2000 Life expectancy, white females Life expectancy, black females 6

Adding Text 40 50 60 70 80 line le wmale le wfemale le bmale le bfemale year /// , text(32 1920 “{bf:1918} {it:Influenza} Pandemic", place(3)) 30 1918 Influenza Pandemic 1900 1920 1940 1960 1980 2000 Year Life expectancy, white males Life expectancy, black males Life expectancy, white females Life expectancy, black females 7

Overlaying Two-Way Plot Types scatter le year if year 1950 lfit le year if year 1950 twoway /// (scatter le year if year 1950) /// (lfit le year if year 1950) 74 72 /* OR */ 70 scatter /// le year if year 1950 /// lfit le year if year 1950 76 /* OR */ #delimit twoway (scatter (lfit #delimit ; 68 /* OR */ 1950 le year if year 1950) le year if year 1950); cr 1960 1970 life expectancy Year 1980 1990 2000 Fitted values 8

Overlaying Two-Way Plot Types 1925 /// 1925 & /// 1950 /// 1950 /* OR */ /// 1925) /// 1925 & /// 1950) /// 1950) 65 twoway (scatter le year if year (lfit le year if year year (lfit le year if year 60 /* OR */ 70 75 55 scatter le year if year lfit le year if year year lfit le year if year 1920 #delimit ; scatter le year if year 1925 lfit le year if year 1925 & year 1950 lfit le year if year 1950; #delimit cr 1940 1960 Year life expectancy Fitted values 1980 2000 Fitted values 9

Overlaying Two-Way Plot Types #delimit ; scatter le male le female year if year 1950 lfit le male year if year 1950 75 70 65 #delimit cr 80 lfit le female year if year 1950; 1950 1960 1970 1980 1990 2000 Year Life expectancy, males Fitted values Life expectancy, females Fitted values 10

Adding a Title and Removing the Legend 75 80 #delimit ; scatter le male le female year if year 1950 lfit le male year if year 1950 lfit le female year if year 1950 ,title("US Male and Female Life Expectancy, 1950-2000") text(75 1978 "Female", place(3)) text(68 1978 "Male", place(3)) legend(off); US Male and Female Life Expectancy, 1950-2000 #delimit cr 70 Female 65 Male 1950 1960 1970 1980 Year 1990 2000 11

Showing Confidence Intervals, Labelling Axes, Modifying Legend sysuse lifeexp.dta, clear #delimit ; twoway (lfitci lexp safewater if region 2) /* North America */ (scatter lexp safewater if region 2) ,title("Life expectancy at birth by access to safe water, 1998") ytitle("Life expectancy at birth") xtitle("Percent of population with access to safe water") legend(ring(0) pos(5) order(2 "Linear fit" 1 "95% CI")); #delimit cr Life expectancy at birth 60 70 80 Life expectancy at birth by access to safe water, 1998 50 Linear fit 20 40 60 80 Percent of population with access to safe water 95% CI 100 12

Markers Labels and Subtitles #delimit ; twoway (lfitci lexp safewater if region 2) /* North America */ (scatter lexp safewater if region 2, mlabel(country)) ,title("Life expectancy at birth by access to safe water, 1998") subtitle("North America") ytitle("Life expectancy at birth") xtitle("Percent of population with access to safe water") legend(ring(0) pos(5) order(2 "Linear fit" 1 "95% CI")); #delimit cr Life expectancy at birth by access to safe water, 1998 80 North America Canada CubaPuerto Rico Jamaica Life expectancy at birth 60 70 Panama Trinidad and Tobago Mexico Dominican Republic El Salvador Honduras Nicaragua Guatemala Haiti 50 Linear fit 20 40 60 80 Percent of population with access to safe water 95% CI 100 13

Position of Marker Labels Life expectancy at birth by access to safe water, 1998 80 North America Canada Cuba Panama Life expectancy at birth 60 70 Jamaica Trinidad and Tobago Dominican Republic Honduras El Salvador Puerto Rico Mexico Nicaragua Guatemala 50 Haiti Linear fit generate pos 12 if country "Panama" 20 40 60 80 replace pos 12 if country "Honduras" Percent of population with access to safe water replace pos 10 if country "Cuba" replace pos 9 if country "Jamaica" replace pos 9 if country "El Salvador" replace pos 9 if country "Trinidad and Tobago" replace pos 9 if country "Dominican Republic" #delimit ; twoway (lfitci lexp safewater if region 2) /* North America */ (scatter lexp safewater if region 2 , mlabel(country) mlabvposition(pos)) ,title("Life expectancy at birth by access to safe water, 1998") subtitle("North America") ytitle("Life expectancy at birth") xtitle("Percent of population with access to safe water") legend(ring(0) pos(5) order(2 "Linear fit" 1 "95% CI")) plotregion(margin(r 10)); #delimit cr 95% CI 100 14

Position of Marker Labels #delimit ; twoway (scatter lexp safewater if region 2 region 3 ,mlabel(country)) ,title("Life expectancy at birth by access to safe water, 1998") subtitle("North and South America") ytitle("Life expectancy at birth") xtitle("Percent of population with access to safe water") plotregion(margin(r 10)); #delimit cr Life expectancy at birth by access to safe water, 1998 80 North and South America Life expectancy at birth 60 65 70 75 Canada CubaPuerto Rico Chile Panama Uruguay Argentina Venezuela Trinidad and Tobago Mexico Dominican Republic Ecuador Colombia El SalvadorHonduras Peru Nicaragua Brazil Jamaica Paraguay Guatemala 55 Bolivia Haiti 20 40 60 80 Percent of population with access to safe water 100 15

and Legend Display Life expectancy at birth by access to safe water, 1998 80 North and South America Life expectancy at birth 60 65 70 75 Position of Marker Labels Canada Puerto Rico Cuba Jamaica Chile Panama Uruguay Argentina Venezuela Trinidad and Tobago Mexico Dominican Republic Paraguay Ecuador Colombia El Salvador Honduras Peru Nicaragua Brazil Guatemala Bolivia 55 North America replace pos 9 if country "Argentina" South America replace pos 9 if country "Canada" Haiti replace pos 9 if country "Cuba" 20 40 60 80 100 replace pos 9 if country "Panama" Percent of population with access to safe water replace pos 9 if country "Venezuela" replace pos 9 if country "Jamaica" replace pos 9 if country "Dominican Republic" replace pos 9 if country "Ecuador" replace pos 9 if country "El Salvador" replace pos 12 if country "Puerto Rico" #delimit ; twoway (scatter lexp safewater if region 2 ,mlabel(country) mlabvposition(pos)) (scatter lexp safewater if region 3 ,mlabel(country) mlabvposition(pos)) ,title("Life expectancy at birth by access to safe water, 1998") subtitle("North and South America") ytitle("Life expectancy at birth") xtitle("Percent of population with access to safe water") legend(ring(0) pos(5) order(1 "North America" 2 "South America") cols(1)); 16 #delimit cr

Marker Size and Symbol, Line Color #delimit ; twoway (scatter lexp safewater if region 2 ,mlabel(country) mlabvposition(pos) msize(small)) (scatter lexp safewater if region 3 ,mlabel(country) mlabvposition(pos) msize(small) msymbol(circle hollow)) (lfit lexp safewater if region 2, clcolor(navy)) (lfit lexp safewater if region 3, clcolor(maroon)) ,title("Life expectancy at birth by access to safe water, 1998") subtitle("North and South America") ytitle("Life expectancy at birth") xtitle("Percent of population with access to safe water") legend(ring(0) pos(5) cols(1) order(1 "North America" 2 "South America" 3 "North America linear fit" 4 "South America linear fit")); #delimit cr Life expectancy at birth by access to safe water, 1998 80 North and South America Canada Life expectancy at birth 60 65 70 75 Puerto Rico Cuba Chile Panama Uruguay Argentina Venezuela Trinidad and Tobago Mexico Dominican Republic Paraguay Ecuador Colombia El Salvador Honduras Peru Nicaragua Brazil Jamaica Guatemala 55 Bolivia Haiti 20 North America South America North America linear fit South America linear fit 40 60 80 Percent of population with access to safe water 100 17

Marker and Marker Label Color, Line Style #delimit ; twoway (scatter lexp safewater if region 2 ,mlabel(country) mlabvposition(pos) msize(small) mcolor(black) mlabcolor(black)) (scatter lexp safewater if region 3 ,mlabel(country) mlabvposition(pos) msize(small) mcolor(black) mlabcolor(black) msymbol(circle hollow)) (lfit lexp safewater if region 2, clcolor(black)) (lfit lexp safewater if region 3, clcolor(black) clpattern(dash)) ,title("Life expectancy at birth by access to safe water, 1998", color(black)) subtitle("North and South America") ytitle("Life expectancy at birth") xtitle("Percent of population with access to safe water") legend(ring(0) pos(5) cols(1) order(1 "North America" 2 "South America" 3 "North America linear fit" 4 "South America linear fit")); #delimit cr Life expectancy at birth by access to safe water, 1998 80 North and South America Canada Life expectancy at birth 60 65 70 75 Puerto Rico Cuba Chile Panama Uruguay Argentina Venezuela Trinidad and Tobago Mexico Dominican Republic Paraguay Ecuador Colombia El Salvador Honduras Peru Nicaragua Brazil Jamaica Guatemala 55 Bolivia Haiti 20 North America South America North America linear fit South America linear fit 40 60 80 Percent of population with access to safe water 100 18

By-Graph: Separate Graphs for Each Subset of Data 60 50 Total 60 70 80 S.A. 50 Life expectancy at birth 70 80 #delimit ; twoway scatter lexp safewater, by(region, total) ,ytitle("Life expectancy at birth") xtitle("Percent of population with access to safe water"); #delimit cr Eur & C.Asia N.A. 20 40 60 80 100 20 40 60 Percent of population with access to safe water Graphs by Region 80 100 19

By-Graph Options #delimit ; twoway scatter lexp safewater ,by(region,total style(compact) title("Life expectancy by access to safe water") note("")) ytitle("Life expectancy at birth") xtitle("Percent of population with access to safe water"); #delimit cr Life expectancy by access to safe water N.A. S.A. Total 60 50 80 70 60 50 Life expectancy at birth 70 80 Eur & C.Asia 20 40 60 80 10020 40 60 Percent of population with access to safe water 80 100 20

Axis Scale, Ticks and Labels #delimit ; twoway scatter lexp safewater , by(region,total style(compact) title("Life expectancy by access to safe water") note("")) xscale(range(20 100)) xtick(20(10)100) xlabel(30(10)100, labsize(small)) xtitle("Percent of population with access to safe water") ytitle("Life expectancy at birth") ylabel(55(5)80, angle(0)); #delimit cr Life expectancy by access to safe water Eur & C.Asia N.A. S.A. Total 80 75 Life expectancy at birth 70 65 60 55 80 75 70 65 60 55 30 40 50 60 70 80 90 100 30 40 50 60 Percent of population with access to safe water 70 80 90 100 21

Storing Graphs in Memory #delimit ; twoway (scatter lexp safewater if region 2, mcolor(black) msize(small) mlabel(country) mlabvposition(pos) mlabcolor(black)) (lfit lexp safewater if region 2, clcolor(black)) ,name(north america, replace) subtitle("North America", color(black)) ylabel(,angle(0)) ytitle("Life expectancy at birth") xtitle("Percent of population with access to safe water") legend(off); North America #delimit cr 80 Canada Puerto Rico Cuba Life expectancy at birth 75 Jamaica Panama Trinidad and Tobago Mexico Dominican Republic 70 El Salvador Honduras 65 Nicaragua Guatemala 60 55 Haiti 20 40 60 80 Percent of population with access to safe water 100 22

Storing Graphs in Memory #delimit ; twoway (scatter lexp sa safewater if region 3, mcolor(black) msize(small) mlabel(country) mlabvposition(pos) mlabcolor(black)) (lfit lexp safewater if region 3, clcolor(black)) ,name(south america, replace) subtitle("South America", color(black)) ylabel(, angle(0)) ytitle("Life expectancy at birth") xtitle("Percent of population with access to safe water") legend(off); South America #delimit cr 75 Chile Uruguay Life expectancy at birth Argentina 70 Paraguay Venezuela Ecuador Colombia Peru Brazil 65 Bolivia 60 40 50 60 70 80 Percent of population with access to safe water 90 23

Combining Graphs #delimit ; graph combine north america south america ,title("Life expectancy by access to safe water", color(black)) col(1); #delimit cr Life expectancy by access to safe water Life expectancy at birth North America 80 75 Canada Puerto Rico Cuba Panama Trinidad Mexico and Tobago Jamaica 70 El Salvador Dominican Republic Nicaragua Honduras Guatemala 65 60 55 Haiti 20 40 60 80 Percent of population with access to safe water 100 Life expectancy at birth South America 75 Chile Argentina 70 Paraguay Venezuela Ecuador Uruguay Colombia Peru Brazil 65 Bolivia 60 40 50 60 70 Percent of population with access to safe water 80 90 24

Life expectancy by access to safe water Combining Canada 75 Life expectancy at birth #delimit ; graph combine north america south america ,title ("Life expectancy by access to safe water", color(black)) xcommon ycommon xsize(7) ysize(10.5) col(1); #delimit cr 80 Jamaica Dominican Republic 70 Puerto Rico Cuba Panama Trinidad and Tobago Mexico El Salvador Nicaragua Honduras 65 Guatemala 60 55 Haiti 20 40 60 80 Percent of population with access to safe water 100 South America 80 75 Life expectancy at birth Graphs North America Argentina 70 Paraguay Venezuela Ecuador Chile Uruguay Colombia Peru Brazil 65 Bolivia 60 55 20 40 60 80 Percent of population with access to safe water 25 100

Saving Stata Graphs save graph in portable format (format determined by filename extension) vector formats contain drawing instructions (.wmf .emf .ps .eps .pdf) resolution independent work well if graph my be resized graph export north america.wmf raster formats save graph pixel-by-pixel (.png) use current resolution work well if including graph on web pages graph export north america.png 26

Country Level Data clear input str14 country tvhome birth5years idealnum age1stbirth school agemarriage bangladesh 33.9 .6 2.3 17.7 4.5 15.2 bolivia 74.8 .8 2.6 20.3 7.6 20.1 colombia 93.4 .4 2.4 20.7 8.6 20.3 dr 83 .5 3.2 19.9 8.6 18.3 egypt 95.9 .7 2.9 21.3 7.3 19.7 haiti 27.9 .8 3.2 20.7 4.3 19.4 india 47.9 .6 2.4 19.2 4.3 17.1 indonesia 74 .5 2.8 20.7 7.5 19.3 morocco 66.6 .7 3.3 21.4 2.7 19.6 nepal 50.7 .6 2.2 19.6 3.6 17.4 pakistan 57.8 .9 4.1 20.5 2.8 18.4 peru 78.1 .6 2.5 21.1 8.8 20.6 end label variable tvhome "TV at home (%)" label variable school "years of school" label variable birth5years "births in last 5 years" label variable idealnum "ideal number of children" label variable age1stbirth "age at first birth" label variable school "years of school" label variable agemarriage "age at first marriage“ Data source: Westoff, Charles F., et. al. In preparation. Leading Indicators of Changes in Fertility in Sub-Saharan Africa. Demographic and Health Surveys, DHS Analytical Studies. ICF International, Calverton, MD, USA. 27

Creating a Matrix of Scatterplots #delimit ; local note "Source: Most recent DHS std survey: bangladesh bolivia colombia dr egypt haiti india indonesia morocco nepal pakistan peru, as of 5/2013"; graph matrix school tvhome idealnum agemarriage age1stbirth birth5years, half note(" note'", size(vsmall)); #delimit cr years of school 100 50 TV at home (%) 0 4 3 ideal number of children 2 20 18 16 age at first marriage 22 20 age at first birth 18 1 .8 .6 births in last 5 years .4 2 4 6 8 0 50 1002 3 4 16 18 20 18 20 22 Source: Most recent DHS std survey: bangladesh bolivia colombia dr egypt haiti india indonesia morocco nepal pakistan peru, as of 5/2013 28

Using Loops to Create Many Graphs ideal number of children #delimit ; local sample MARRIED; local note "Source: Most recent DHS standard survey, as of 5/2013“; foreach x in school tvhome {; foreach y in idealnum agemarriage age1stbirth birth5years {; twoway scatter y' x', mlabel(country) mlabsize(large) ylabel(, angle(0)) note(" note'") name(" x' y'", replace); graph export x' y' sample' mostrecent.emf, replace; }; pakistan }; 4 #delimit cr 3.5 morocco haiti dr 3 2.5 india bangladesh nepal egypt indonesia bolivia peru colombia 2 2 4 6 years of school 8 10 Source: Most recent DHS standard survey, as of 5/2013 29

Country Level Data: Time 1, Time 2 clear input str14 country bangladesh bolivia colombia dr egypt haiti india indonesia morocco nepal pakistan peru end school1 3.3 6.9 7.9 7.9 5.5 3.1 3.6 5.9 1.6 2.4 1.5 8.1 school2 4.5 7.6 8.6 8.6 7.3 4.3 4.3 7.5 2.7 3.6 2.8 8.8 agemarriage1 14.8 19.8 20.3 18.3 18.9 19.6 16.9 18.1 18.7 16.9 17.9 20.2 agemarriage2 15.2 20.1 20.3 18.3 19.7 19.4 17.1 19.3 19.6 17.4 18.4 20.6 Data source: Westoff, Charles F., et. al. In preparation. Leading Indicators of Changes in Fertility in Sub-Saharan Africa. Demographic and Health Surveys, DHS Analytical Studies. ICF International, Calverton, MD, USA. 30

Displaying Changes local local local local 22 20 age at marriage sample MARRIED x school y agemarriage note "Source: Two most recent DHS standard surveys, as of 5/2013" local xtitle "years of school" local ytitle "age at marriage" local ylabel ", angle(0)" gen pos 3 replace pos 12 if country "morocco" #delimit ; twoway pcarrow y'1 x'1 y'2 x'2, barbsize(1) lcolor(black) mcolor(black) scatter y'2 x'2, mcolor(none) mlabel(country) mlabvposition(pos) scatter y'1 x'1, msym(o) mcolor(black) msize(small) note(" note'", size(vsmall)) ytitle(" ytitle'") xtitle(" xtitle'") ylabel( ylabel') legend(off); #delimit cr bolivia egypt indonesia morocco haiti pakistan peru colombia dr 18 nepal india 16 bangladesh 14 2 4 6 years of school 8 10 Source: Two most recent DHS standard surveys, as of 5/2013 31

Histogram set scheme s2mono sysuse nlsw88.dta, clear keep if age 40 age 44 #delimit ; twoway histogram wage if wage 20, percent fcolor(gs12) lcolor(gs12) bin(30) title("Hourly Wage Distribution, Women 40-44") note("Source: Stata 12 NLSW 1988 extract", span) ylabel(, angle(0)); #delimit cr Hourly Wage Distribution, Women 40-44 8 Percent 6 4 2 0 0 5 10 hourly wage 15 20 Source: Stata 12 NLSW 1988 extract 32

Overlaying Histograms #delimit ; twoway histogram wage if union 1 & wage 20, percent fcolor(gs12) lcolor(gs12) bin(30) histogram wage if union 0 & wage 20, percent fcolor(none) lcolor(black) bin(30) title("Hourly Wage Distribution by Union Status, Women 40-44") note("Source: Stata 12 NLSW 1988 extract", span) ylabel(, angle(0)) legend(ring(0) pos(1) cols(1) order(1 "Union" 2 "Non-Union")); #delimit cr Hourly Wage Distribution by Union Status, Women 40-44 10 Union Non-Union Percent 8 6 4 2 0 0 5 10 hourly wage 15 20 Source: Stata 12 NLSW 1988 extract 33

Boxplot #delimit ; graph box wage if age 40 & age 44, over(race) title("Hourly Wage by Race, Women 40-44 (n 918)") note("Source: Stata 12 NLSW 1988 extract") ylabel(, angle(0)); #delimit cr Hourly Wage by Race, Women 40-44 (n 918) 40 hourly wage 30 20 10 0 white black other Source: Stata 12 NLSW 1988 extract 34

Scatter and Categorical Variable #delimit ; twoway scatter wage race if age 40 & age 44, title("Hourly Wage by Race, Women 40-44 (n 918)") note("Source: Stata 12 NLSW 1988 extract") xlabel(1 "white" 2 "black" 3 "other") xtitle("") xscale(range(0.5 3.5)) ylabel(, angle(0)); #delimit cr Hourly Wage by Race, Women 40-44 (n 918) 40 hourly wage 30 20 10 0 white black other Source: Stata 12 NLSW 1988 extract 35

Scatter with Jitter and Categorical Variable #delimit ; twoway scatter wage race if age 40 & age 44, jitter(25) msize(tiny) mcolor(gs5) title("Hourly Wage by Race, Women 40-44 (n 918)") note("Source: Stata 12 NLSW 1988 extract") xlabel(1 "white" 2 "black" 3 "other", noticks) xtitle("") xscale(range(0.5 3.5)) ylabel(, angle(0)); #delimit cr Hourly Wage by Race, Women 40-44 (n 918) 40 hourly wage 30 20 10 0 white black other Source: Stata 12 NLSW 1988 extract 36

Using twoway rbar hourly wage egen median median(wage), by(race) egen upq pctile(wage), p(75) by(race) egen loq pctile(wage), p(25) by(race) egen iqr iqr(wage), by(race) #delimit ; twoway rbar med upq race, barwidth(0.7) blc(black) bfc(none) lwidth(medthick) rbar med loq race, barwidth(0.7) blc(black) bfc(none) lwidth(medthick) title("Hourly Wage by Race, Women 40-44 (n 918)") note("Source: Stata 12 NLSW 1988 extract") xlabel(1 "white" 2 "black" 3 "other", noticks) xtitle("") xscale(range(0.5 3.5)) yscale(range(0 42)) Hourly Wage by Race, Women 40-44 (n 918) ylabel(0 (10) 40, angle(0)) 40 ytitle("hourly wage") legend(off); #delimit cr 30 20 10 0 white black other Source: Stata 12 NLSW 1988 extract 37

Boxplot with Scatter egen median median(wage), by(race) egen upq pctile(wage), p(75) by(race) egen loq pctile(wage), p(25) by(race) egen iqr iqr(wage), by(race) #delimit ; twoway scatter wage race, jitter(25) msize(tiny) mcolor(gs9) rbar med upq race, barwidth(0.70) blc(black) bfc(none) lwidth(medthick) rbar med loq race, barwidth(0.70) blc(black) bfc(none) lwidth(medthick) title("Hourly Wage by Race, Women 40-44 (n 918)") note("Source: Stata 12 NLSW 1988 extract") xlabel(1 "white" 2 "black" 3 "other", noticks) xtitle("") xscale(range(0.5 3.5)) yscale(range(0 42)) Hourly Wage by Race, Women 40-44 (n 918) ylabel(0 (10) 40, angle(0)) 40 ytitle("hourly wage") legend(off); #delimit cr hourly wage 30 20 10 0 white black other Source: Stata 12 NLSW 1988 extract 38

egen median median(wage), by(race) egen upq pctile(wage), p(75) by(race) egen loq pctile(wage), p(25) by(race) egen iqr iqr(wage), by(race) egen upper max(min(wage, upq 1.5 * iqr)), by(race) egen lower min(max(wage, loq - 1.5 * iqr)), by(race) #delimit ; twoway scatter wage race, jitter(25) msize(tiny) mcolor(gs9) rbar med upq race, barwidth(0.70) blc(black) bfc(none) lwidth(medthick) rbar med loq race, barwidth(0.70) blc(black) bfc(none) lwidth(medthick) rspike upq upper race, lwidth(medthick) rspike loq lower race, lwidth(medthick) title("Hourly Wage by Race, Women 40-44 (n 918)") note("Source: Stata 12 NLSW 1988 extract") xlabel(1 "white" 2 "black" 3 "other", noticks) xtitle("") xscale(range(0.5 3.5)) yscale(range(0 42)) Hourly Wage by Race, Women 40-44 (n 918) ylabel(0 (10) 40, angle(0)) 40 ytitle("hourly wage") legend(off); #delimit cr Boxplot with Whiskers and Scatter hourly wage 30 20 10 0 white Source: Stata 12 NLSW 1988 extract black other 39

Boxplot with Whiskers, Caps and Scatter egen median median(wage), by(race) egen upq pctile(wage), p(75) by(race) egen loq pctile(wage), p(25) by(race) egen iqr iqr(wage), by(race) egen upper max(min(wage, upq 1.5 * iqr)), by(race) egen lower min(max(wage, loq - 1.5 * iqr)), by(race) #delimit ; twoway scatter wage race, jitter(25) msize(tiny) mcolor(gs9) rbar med upq race, barwidth(0.70) blc(black) bfc(none) lwidth(medthick) rbar med loq race, barwidth(0.70) blc(black) bfc(none) lwidth(medthick) rcap loq lower race, lcolor(black) msize(*4) lwidth(medthick) rcap upq upper race, lcolor(black) msize(*4) lwidth(medthick) title("Hourly Wage by Race, Women 40-44 (n 918)") note("Source: Stata 12 NLSW 1988 extract") xlabel(1 "white" 2 "black" 3 "other", noticks) xtitle("") xscale(range(0.5 3.5)) yscale(range(0 42)) ylabel(0 (10) 40, angle(0)) Hourly Wage by Race, Women 40-44 (n 918) ytitle("hourly wage") legend(off); 40 #delimit cr hourly wage 30 20 10 0 white Source: Stata 12 NLSW 1988 extract black other 40

egen median median(wage), by(race) egen upq pctile(wage), p(75) by(race) egen loq pctile(wage), p(25) by(race) egen iqr iqr(wage), by(race) egen upper max(min(wage, upq 1.5 * iqr)), by(race) egen lower min(max(wage, loq - 1.5 * iqr)), by(race) egen mean mean(wage), by(race) #delimit ; twoway scatter wage race, jitter(25) msize(tiny) mcolor(gs9) scatter mean race, msymbol(D) mcolor(black) msize(small) rbar med upq race, barwidth(0.70) blc(black) bfc(none) lwidth(medthick) rbar med loq race, barwidth(0.70) blc(black) bfc(none) lwidth(medthick) rcap loq lower race, lcolor(black) msize(*4) lwidth(medthick) rcap upq upper race, lcolor(black) msize(*4) lwidth(medthick) title("Hourly Wage by Race, Women 40-44 (n 918)") note("Source: Stata 12 NLSW 1988 extract") xlabel(1 "white" 2 "black" 3 "other", noticks) xtitle("") xscale(range(0.5 3.5)) yscale(range(0 42)) Hourly Wage by Race, Women 40-44 (n 918) ylabel(0 (10) 40, angle(0)) ytitle("hourly wage") 40 legend(off); #delimit cr Boxplot with Whiskers, Caps, Scatter and Means hourly wage 30 20 10 0 white Source: Stata 12 NLSW 1988 extract black other 41

Bar Graph #delimit ; graph bar (mean) wage, over(union) over(married) over(collgrad) blabel(bar, format(%9.2f)) yscale(off) title("1988 Mean Hourly Wage of Women Age 40-44") subtitle("by union status, marital status, and college graduation") note("Source: Stata 12 NLSW 1988 extract", span); #delimit cr 1988 Mean Hourly Wage of Women Age 40-44 by union status, marital status, and college graduation 11.41 10.64 9.82 8.04 6.41 10.00 7.66 6.35 single married single not college grad married college grad nonunion union Source: Stata 12 NLSW 1988 extract Graph based on example shown in Stata Graphics Reference Manual, Release 12, page 58. 42

1988 Mean Hourly Wage of Women Age 40-44 Horizontal Bar Graph not college grad Personal Services Ag/Forestry/Fisheries Wholesale/Retail Trade Entertainment/Rec Svc Professional Services Construction Business/Repair Svc Manufacturing Public Administration Finance/Ins/Real Estate Transport/Comm/Utility Mining college grad Personal Services Ag/Forestry/Fisheries Wholesale/Retail Trade Entertainment/Rec Svc Professional Services Business/Repair Svc Finance/Ins/Real Estate Public Administration Transport/Comm/Utility Manufacturing Construction #delimit ; graph hbar wage, over(ind, sort(1)) over(collgrad) title("1988 Mean Hourly Wage of Women Age 40-44", span size(med)) note("Source: Stata 12 NLSW 1988 extract", span) nofill ytitle("") ysize(8); #delimit cr Graph based on example shown in Stata Graphics Reference Manual, Release 12, page 70. 0 5 10 15 20 Source: Stata 12 NLSW 1988 extract

1988 Mean Hourly Wage of Women Age 40-44 Dot Plot not college grad Personal Services Ag/Forestry/Fisheries Wholesale/Retail Trade Entertainment/Rec Svc Professional Services Construction Business/Repair Svc Manufacturing Public Administration Finance/Ins/Real Estate Transport/Comm/Utility Mining college grad Personal Services Ag/Forestry/Fisheries Wholesale/Retail Trade Entertainment/Rec Svc Professional Services Business/Repair Svc Finance/Ins/Real Estate Public Administration Transport/Comm/Utility Manufacturing Construction #delimit ; graph dot wage, over(ind, sort(1)) over(collgrad) title("1988 Mean Hourly Wage of Women Age 40-44", span size(med)) note("Source: Stata 12 NLSW 1988 extract", span) nofill ytitle("") ysize(8); #delimit cr 0 5 10 15 20 Source: Stata 12 NLSW 1988 extract

Upper and Lower Quartile of Hourly Wage Women Age 40-44, by College Graduation Status, 1988 Dot Plot with 2 Variables #delimit ; graph dot (p25) wage (p75) wage, over(ind, sort(2)) over(collgrad) title("Upper and Lower Quartile of Hourly Wage", span) subtitle("Women Age 40-44, by College Graduation Status, 1988", span) note("Source: Stata 12 NLSW 1988 extract", span) nofill ytitle("") ysize(8) xsize(6) legend(off); #delimit cr Personal Services Ag/Forestry/Fisheries Wholesale/Retail Trade Professional Services Manufacturing Business/Repair Svc not college grad Construction Public Administration Entertainment/Rec Svc Finance/Ins/Real Estate Transport/Comm/Utility Mining Personal Services Ag/Forestry/Fisheries Wholesale/Retail Trade Professional Services Entertainment/Rec Svc Public Administration college grad Business/Repair Svc Finance/Ins/Real Estate Transport/Comm/Utility Manufacturing Construction 0 Source: Stata 12 NLSW 1988 extract 10 20 30

Population Data 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. agegrp Under 5 5 to 9 10 to 14 15 to 19 20 to 24 25 to 29 30 to 34 35 to 39 40 to 44 45 to 49 50 to 54 55 to 59 60 to 64 65 to 69 70 to 74 75 to 79 80 to 84 maletotal 9,810,733 10,523,2

- However, as of Stata 11: can record edits and apply them to other graphs . A Visual Guide To Stata Graphics, Third Edition, by Michael Mitchell Stata 12 Graphics Manual (may want to start with "graph intro") Stata 12 Graphics. 3 Stata Graphics Syntax graph graphtype graph bar graph twoway plottype graph twoway scatter

Related Documents:

Stata is available in several versions: Stata/IC (the standard version), Stata/SE (an extended version) and Stata/MP (for multiprocessing). The major difference between the versions is the number of variables allowed in memory, which is limited to 2,047 in standard Stata/IC, but can be much larger in Stata/SE or Stata/MP. The number of

Categorical Data Analysis Getting Started Using Stata Scott Long and Shawna Rohrman cda12 StataGettingStarted 2012‐05‐11.docx Getting Started Using Stata – May 2012 – Page 2 Getting Started in Stata Opening Stata When you open Stata, the screen has seven key parts (This is Stata 12. Some of the later screen shots .

To open STATA on the host computer, click on the “Start” Menu. Then, when you look through “All Programs”, open the “Statistics” folder you should see a folder that says “STATA”. Click on the folde r and it will open up three STATA programs (STATA 10, STATA 11, and STATA 12). These are all the

There are several versions of STATA 14, such as STATA/IC, STATA/SE, and STATA/MP. The difference is basically in terms of the number of variables STATA can handle and the speed at which information is processed. Most users will probably work with the “Intercooled” (IC) version. STATA runs on the Windows, Mac, and Unix computers platform.

Stata/MP, Stata/SE, Stata/IC, or Small Stata. Stata for Windows installation 1. Insert the installation media. 2. If you have Auto-insert Notification enabled, the installer will start auto-matically. Otherwise, you will want to navigate to your installation media and double-click on Setup.exe to start the installer. 3.

Stata/IC and Stata/SE use only one core. Stata/MP supports multiple cores, but only commands are speeded up. . I am using Stata 14 and not Stata 15) Setting up the seed using dataset lename. type can be F create creates a dataset with empty seeds for each variation. If option fill is used, then seeds are random numbers.

STATA/IC, STATA/SE, and STATA/MP. The difference is basically in terms of the number of variables STATA can handle and the speed at which information is processed. Most users will probably work with the “Intercooled” (IC) version. STATA runs on the Windows (2000, 2003, XP, Vista, Server 2008, or Windows 7), Mac, and Unix computers platform.

WiFi, with all of the basic details of the authentication (user, venue and device details). This can be useful if you want to trigger real-time events or load data to your CRM without making repeated requests to BT Wi-Fi’s RESTful company API. To use Webhooks, you will need to create your own listener that receives and parses JSON in the format specified in the instructions below. The .