Introduction to Stata 13 Graphics. Dawn Koffman Office of Population Research Princeton University September 2013

Similar documents
Fieldwork Dates AmericasBarometer

Latin America and the Caribbean: Fact Sheet on Economic and Social Indicators

Spanish Countries. & Capitals. Map Labeling & Quiz SpanishMadeEasy.net

TECHNICAL SEMINAR ON TOURISM INVESTMENTS IN THE AMERICAS Asuncion, Paraguay. May 17-18, 2011

Sugar Cane production in both Haiti and the DR are down. New markets could restore production to historic levels.

Daniel Titelman Director Economic Development Division

International economic context and regional impact

DEVELOPMENT AID AT A GLANCE

ORGANIZATION OF AMERICAN STATES

DEVELOPMENT AID AT A GLANCE

UN-GGIM:Americas. UN-GGIM Expanded Bureau Meeting 7-9 December 2016, UN Headquarters New York. Rolando Ocampo President of UN-GGIM:Americas

Incorporating Information Literacy In Ibero-American University Libraries: Comparative Analysis of the Information from their Websites

Requests by Intake and Case Status Period. Intake 1 Case Review 6

Doing Business in Latin America and the Caribbean. Rita Ramalho Program Manager

ICELANDAIR NICE-REYKJAVIK SURVEY. OPPORTUNITIES SURVEY SOUTH & CENTRAL AMERICA / CARRIBEAN FROM/TO NICE AIRPORT Routes Online 2012

Broadband as an opportunity for Development

Inter-American Defense College

Foromic. 1 Welcome to Foromic 2 Background and Impact. 3 Participation by Country 4 Participation by Type of Institution 5 Agenda Content

NZQA registered unit standard version 2 Page 1 of 5

Contents of the Economic Survey 2012

Regional Director Latin America and Caribbean

1. Introduction. 2. Basic Fundamentals. 4. Results. 5. Initiatives. 6. Final Conclusions.

Preliminary Overview of the Economies of Latin America and the Caribbean

CHINA Y AMERICA LATINA: RELACIONES COMERCIALES Y ECONOMICAS

COMPETITIVENESS Vs. SECURITY: STRIKING THE RIGHT BALANCE

Comprehension Questions:

EU Trade policy in Latin America

Reformas Estructurales y Crecimiento Económico de Largo Plazo

Latin America and the Caribbean: Fact Sheet on Leaders and Elections

AfrICANDO th Annual

Effective for all tickets issued where American validation is used. IATA-approved locations classified by American as full service.

Base Commission To all destinations 0%

INTEGRATION AND TRADE IN THE AMERICAS

TABLE 1 VISITOR ARRIVALS. Total Visitor Arrivals +/ Month / / /18

ASSEMBLY 35TH SESSION

MEM. The. Bahamas (Commonwealth. Multilateral Evaluation Mechanism. in Drug Control. Inter-American Drug Abuse Control Commission (CICAD)

Countries of the World

EUROPEAN CENTRE FOR DISEASE PREVENTION AND CONTROLInfluenza A(H1N1)v

IMO/IHO World-Wide Navigational Warning Service NAVAREA IV / XII

XXXIX REPICA, JULY 25-28, 2017, BELIZE CITY, BELIZE

MEM. Grenada. Multilateral Evaluation Mechanism. in Drug Control. Inter-American Drug Abuse Control Commission (CICAD)

ACS/2013/TRADE Customs Working Group.INFO.001 IMPACT OF THE WELCOME

MindBridge Freedom Quick User Guide

Annex Multilateral Conventions 1. SUBJECT Where and When Signed Multilateral Organization Vienna Convention on Vienna, April 24, 1963

WORLD PRESS FREEDOM INDEX 2012

LACNIC REPORT. RIPE 46 Amsterdam Netherlands. Raúl Echeberría CEO RIPE 46

Paper for the Consideration by CBSC18. MACHC report

TVL DESK OF CONNECTICUT

REPUBLIC OF KOREA. Table 1. FDI flows in the host economy, by geographical origin. (Millions of US dollars)

TOURIST (Stopover Arrivals) Europe. United States. Canada. Latin America. Monthly Statistical Report

Regional Activities. 25 June Carlos Vogeler Director Executive Secretary for Members Relations and Regional Director for the Americas UNWTO

TOURIST (Stopover Arrivals) Europe. United States. Canada. Latin America. Monthly Statistical Report

LACNIC REPORT. ARIN XI - Memphis, USA. Raúl Echeberría LACNIC CEO < > ARIN XI

Business Opportunities in the Caribbean Region. Presented by: Robert Jones Commercial Counselor - Caribbean Region

A. Transport. Annex table 1. Road density is much lower in LAC than in Middle Income Coutries or China per 1000 person

COUNTRY & TERRITORY PROFILES A Summary of Oil Spill Response Arrangements & Resources Worldwide

National Days. 1 January Cuba Liberation Day. 1 January Haiti National Day. 1 January Sudan Independence Day (1956)

The World Pasta Industry in 2011

5.3. Cannabis: Wholesale and Street Prices and Purity Levels

Calls to premium rate numbers and other non-geographic numbers (which can vary over time) are not included.

Membership & Voting Strength - 1 October September 2020

History Culture Landscape Industry

Many ecotourists visit the various natural habitats in Central America. Why do you think ecotourism has become so popular?

RAF Country/Group Allocation Utilization Report*

International ISBN Agency - Range Message Printed: Apr 5, Last Change: Apr 4, 2018

TOURIST (Stopover Arrivals) Europe. United States. Canada. Latin America. Monthly Statistical Report USA 66.5% Canada 16.5% UK 8.2% All. Other 2.

TOURIST (Stopover Arrivals) Europe. United States. Latin America. Canada. Monthly Statistical Report USA 64.4% Canada 16.9% UK 9.4% All Other 2.

TOURIST (Stopover Arrivals) Europe. United States. Canada. Latin America. Monthly Statistical Report USA 66.0% Canada 15.9% UK 8.8% All Other 2.

Sprint Real Solutions VPN SDS International Rates from the U.S. Mainland, Hawaii, Puerto Rico, and the U.S. Virgin Islands 1*

TOURIST (Stopover Arrivals) Europe. United States. Latin America. Canada. Monthly Statistical Report

Central Bank of Different Countries

TOURIST (Stopover Arrivals) Europe. United States. Latin America. Canada. Monthly Statistical Report USA 65.0% Canada 16.7% UK 9.2% All Other 2.

TOURIST (Stopover Arrivals) Europe. United States. Latin America. Canada. Monthly Statistical Report USA 64.2% Canada 17.2% UK 9.3% All Other 2.

TOURIST (Stopover Arrivals) Europe. United States. Canada. Latin America. Monthly Statistical Report USA 66.4% Canada 15.8% UK 8.6% All Other 2.

Acquisition of Lafarge s assets in Honduras

TECHNICAL SEMINAR ON TOURISM INVESTMENTS IN THE AMERICAS GENERAL INFORMATION NOTE

MEM. Salvador. Multilateral Evaluation Mechanism. in Drug Control. Inter-American Drug Abuse Control Commission (CICAD)

Latin America. Physical Geography

Central America and the Caribbean. The Link Between North and South America

largest deployments by number of staff deployed Pakistan: Earthquake 2005 Haiti: Earthquake 2010** Pakistan: Floods 2010 Typhoon Haiyan 2013

The Lesser Antilles. Dominican Republic), and Puerto Rico

Measuring Public and Middle Class Attitudes to Democracy and Markets: Key Findings from the 2012 AmericasBarometer

MEM. Brazil. Multilateral Evaluation Mechanism. in Drug Control. Inter-American Drug Abuse Control Commission (CICAD)

The Rental Car Market: All Things American. John Healy Managing Director Northcoast Research International Car Rental Show

Latin America and Caribbean: Wheat Flour Industry and Flour Fortification Situation Assessment. The Micronutrient Initiative

XX REGIONAL CONFERENCE OF CUSTOMS DIRECTORS GENERAL FOR THE AMERICAS AND THE CARIBBEAN REGION

Localizing games for the Spanish Speaking World! Martina Santoro Okam Game Studio, Argentina Alejandro Gonzalez Brainz, Colombia

International Students Headcount & Credit Hour Enrollment Summary

Enjoy an unforgetful trip in Guanacaste!

INTERNATIONAL REGISTRY IN ORGAN DONATION and TRANSPLANTATION

The Latin America & Caribbean Market!

WÄRTSILÄ IN CENTRAL AMERICA AND THE CARIBBEAN

State of the Market: Latin America

Programme planning levels for regular resources in 2017 (10 January 2017)

PANAMA AUTOMOBILE MARKET SURVEY. Financial Studies Division March 2013

South America Projects

Colombia: An Upcoming Emerging Market for International Investors April 2012

ECONOMIC AND TRADE INDICATORS FOR LATIN AMERICA, 1960 TO 2004

WORLD HEALTH ORGANIZATION Assessed contributions overview for all Member States As at 31 May assessment (A) 31-Dec-17 (B)

LatinAmericaand the Caribbean

Transcription:

Introduction to Stata 13 Graphics Dawn Koffman Office of Population Research Princeton University September 2013 1

Stata 13 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: Sometimes slow Large syntax: 680 page graphics manual! Stata 13 Graphics Manual is only available on-line: Help -> PDF Documentation -> [G] Graphics 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 13 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

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

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

Multiple Dependent Variables line le_wmale le_wfemale le_bmale le_bfemale year 30 40 50 60 70 80 1900 1920 1940 1960 1980 2000 Year Life expectancy, white males Life expectancy, black males Life expectancy, white females Life expectancy, black females 6

Adding Text line le_wmale le_wfemale le_bmale le_bfemale year ///, text(32 1920 {bf:1918} {it:influenza} Pandemic", place(3)) 30 40 50 60 70 80 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 /* OR */ scatter /// le year if year >= 1950 /// lfit le year if year >= 1950 /* OR */ twoway /// (scatter le year if year >= 1950) /// (lfit le year if year >= 1950) /* OR */ #delimit ; twoway (scatter le year if year >= 1950) (lfit le year if year >= 1950); #delimit cr 68 70 72 74 76 1950 1960 1970 1980 1990 2000 Year life expectancy Fitted values 8

Overlaying Two-Way Plot Types scatter le year if year >= 1925 /// lfit le year if year >= 1925 & /// year < 1950 /// lfit le year if year >= 1950 /* OR */ twoway /// (scatter le year if year >= 1925) /// (lfit le year if year >= 1925 & /// year < 1950) /// (lfit le year if year >= 1950) /* OR */ 55 60 65 70 75 1920 1940 1960 1980 2000 Year #delimit ; scatter le year if year >= 1925 lfit le year if year >= 1925 & year < 1950 lfit le year if year >= 1950; #delimit cr life expectancy Fitted values 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 lfit le_female year if year >= 1950; #delimit cr 65 70 75 80 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 #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); #delimit cr US Male and Female Life Expectancy, 1950-2000 65 70 75 80 Female Male 1950 1960 1970 1980 1990 2000 Year 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(" by access to safe water, 1998") ytitle("") xtitle("") legend(ring(0) pos(5) order(2 "Linear fit" 1 "95% CI")); #delimit cr by access to safe water, 1998 50 60 70 80 Linear fit 95% CI 20 40 60 80 100 12

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

Position of Marker Labels by access to safe water, 1998 North America Haiti Dominican Republic Honduras El Salvador generate pos = 12 if country == "Panama" replace pos = 12 if country == "Honduras" 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(" by access to safe water, 1998") subtitle("north America") ytitle("") xtitle("") legend(ring(0) pos(5) order(2 "Linear fit" 1 "95% CI")) plotregion(margin(r+10)); #delimit cr 50 60 70 80 Jamaica Trinidad and Tobago Guatemala Linear fit Cuba Panama Mexico Nicaragua 20 40 60 80 100 Canada Puerto Rico 95% CI 14

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

Position of Marker Labels and Legend Display 55 60 65 70 75 80 replace pos = 9 if country == "Argentina" replace pos = 9 if country == "Canada" replace pos = 9 if country == "Cuba" replace pos = 9 if country == "Panama" 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(" by access to safe water, 1998") subtitle("north and South America") ytitle("") xtitle("") legend(ring(0) pos(5) order(1 "North America" 2 "South America") cols(1)); #delimit cr by access to safe water, 1998 North and South America Haiti 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 Bolivia Guatemala North America South America 20 40 60 80 100 16

Marker Size and Symbol, Line Color 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(" by access to safe water, 1998") subtitle("north and South America") ytitle("") xtitle("") legend(ring(0) pos(5) cols(1) order(1 "North America" 2 "South America" 3 "North America linear fit" 4 "South America linear fit")); 55 60 65 70 75 80 by access to safe water, 1998 North and South America Haiti 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 Bolivia Guatemala North America South America North America linear fit South America linear fit 20 40 60 80 100 17

Marker and Marker Label Color, Line Style 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(" by access to safe water, 1998", color(black)) subtitle("north and South America") ytitle("") xtitle("") legend(ring(0) pos(5) cols(1) order(1 "North America" 2 "South America" 3 "North America linear fit" 4 "South America linear fit")); by access to safe water, 1998 North and South America 55 60 65 70 75 80 Haiti 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 Bolivia Guatemala North America South America North America linear fit South America linear fit 20 40 60 80 100 18

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

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

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("") ytitle("") ylabel(55(5)80, angle(0)); Axis Scale, Ticks and Labels Life expectancy by access to safe water Eur & C.Asia N.A. 80 75 70 65 60 55 80 75 70 65 60 S.A. Total 55 30 40 50 60 70 80 90 100 30 40 50 60 70 80 90 100 21

Storing Graphs in Memory 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("") xtitle("") legend(off); 80 North America Canada 75 70 65 60 Jamaica Dominican Republic El Salvador Honduras Guatemala Puerto Rico Cuba Panama Trinidad and Tobago Mexico Nicaragua 55 Haiti 20 40 60 80 100 22

Storing Graphs in Memory 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("") xtitle("") legend(off); 75 South America Argentina Venezuela Chile Uruguay 70 65 Paraguay Ecuador Brazil Colombia Peru Bolivia 60 40 50 60 70 80 90 23

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

Life expectancy by access to safe water 80 75 70 65 60 55 Haiti El Salvador North America Jamaica Dominican Republic Honduras Guatemala Canada Puerto Rico Cuba Panama Trinidad and Tobago Mexico Nicaragua 20 40 60 80 100 Combining Graphs 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); 80 South America 75 70 65 60 Paraguay Chile Uruguay Argentina Venezuela Ecuador Colombia Peru Brazil Bolivia 55 20 40 60 80 100 25

Saving and Including 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 include "portable-format-graph" in Windows application (Word, Powerpoint): Insert -> Picture -> From File 26

Using Mata Functions to Add Graphs to Word Document* create Stata graphs and and use graph export to save graphs in portable format sysuse uslifeexp line le year graph export us_lifeexp_overall.emf, replace line le_wmale le_wfemale le_bmale le_bfemale year graph export us_lifeexp_race_gender.emf, replace use Mata functions to: create Word document add Stata graphs save Word document mata: dh = _docx_new() _docx_image_add(dh, us_lifeexp_overall.emf ) _docx_image_add(dh, us_lifeexp_race_gender.emf ) rc = _docx_save(dh, us_lifeexp_graphs.docx ) end * New functions available in Stata 13 27