NETCOURSE® 120: STATISTICAL GRAPHICS USING STATA

CONTENT

Learn how to communicate your data with Stata’s powerful graphics features. This course will introduce different kinds of graphs and demonstrate how to use them for exploratory data analysis. Topics include how to use graphs to check model assumptions; how to format, save, and export your graphs for publication using the Graph Editor; how to create custom graph schemes; how to create complex graphs by layering and combining multiple graphs; how to use margins and marginsplot; and more. Bonus material includes information on user-written graph commands and useful data management tools.

 

PREREQUISITES

  • Stata 18 installed and working.
  • Basic knowledge of using Stata interactively
  • Internet web browser, installed and working (course is platform independent)

PROGRAM

 

SESSION I: GETTING TO KNOW YOUR DATA USING GRAPHS

  1. Introduction
    • Why graphs are an important tool for exploratory data analysis
    • Data management tools for graphing data
    • The example dataset
  2. How to create and edit basic graphs using Stata
    • How to create and edit graphs with dialog boxes
    • How to edit graphs with the Graph Editor
    • How to create and edit graphs with commands
  3. Some basic graphs
    • Graphs for one continuous variable
    • Graphs for one categorical variable
    • Graphs for two continuous variables
    • Graphs for two categorical variables
    • Graphs for one continuous and one categorical variable
    • Graphs for many variables
  4. Storing, saving, and exporting graphs
    • Storing graphs in memory
    • Saving graphs to disk
    • Exporting graphs in .png format
  5. Automating the process: Looping and saving

 

SESSION II: UNDERSTANDING YOUR RESULTS USING GRAPHS

  1. Introduction
  2. Model checking using graphs
    • Using the predict command
    • Checking model assumptions
      • Checking the normality assumption
      • Checking the linearity assumption
      • Checking the homoskedasticity assumption
    • Identifying outliers and influential observations
  3. Visualizing the results of your models
    • Using the margins and marginsplot commands
      • A brief review of factor variables
      • Categorical independent variables
      • Multiple categorical independent variables
      • Continuous independent variables
      • Continuous and categorical independent variables
      • Average response versus response at average: The atmeans option
      • Contrasts of margin
      • Marginal effects: Margins of derivatives of responses
    • Using contour plots to visualize continuous-by-continuous interactions

 

SESSION III: FORMATTING GRAPHS FOR PUBLICATION

  1. Introduction
  2. Formatting titles, legends, and text boxes
    • Formatting titles
    • Formatting legends
    • Adding text boxes
    • Using italics, bold, superscripts, and subscripts
    • Using specialty characters
    • Using different fonts
    • Formatting numbers
  3. Formatting axes, axis labels, ticks, gridlines, graph, and plot regions
    • Formatting categorical axis labels
    • Formatting the x and y axes
    • Formatting the x- and y-axis labels
    • Formatting major and minor ticks and gridlines
    • Adding reference lines
    • Formatting the graph and plot regions
    • Formatting major and minor ticks and gridlines
    • Adding reference lines
    • Formatting the graph and plot regions
  4. Controlling the aspect ratio and size of graphs
  5. Using schemes to change the overall look of graphs
    • Using built-in schemes
    • Defining your own schemes
  6. Recording and saving edits in the Graph Editor

 

 

 

© Copyright 1996–2024 StataCorp LLC

 

 

 

SESSION IV: ADVANCED GRAPHS: HOW TO LAYER AND COMBINE MULTIPLE GRAPHS

  1. Introduction
  2. Layering multiple graphs with the graph twoway command
    • Basic layered graphs with one y axis
    • Advanced layered graphs with one y axis
    • Basic layered graphs with two y axes
    • Advanced layered graphs with two y axes
  3. Layering multiple graphs with the addplot() option
    • Basic
    • Advanced
  4. Creating multiple graphs with the by() option
  5. Combining different graphs with the graph combine command
    • Basics: Making a table of separate graphs
    • Advanced: Making a single complex graph from separate graphs
  6. Exporting graphs for publication
    • Exporting graphs in pixel-based formats
    • Exporting graphs in vector-based formats

 

 

Note: The previous four sessions constitute the core material of the course. The following material is optional and introduces user-written graphic commands and useful data management tools.

 

 

Bonus Material

  1. Introduction
  2. User-written graph commands
    • The Statistical Software Components (SSC) archive
    • The coefplot package by Ben Jann

3. How to write a simple graphics wrapper command

4. How to create animated graphs

5. Some fun graphs

    • How to create normal curves with shaded tails
    • How to show scatterplots with regression lines and residuals
    • How to add normal curves to regression lines
    • How to graph a histogram with a box plot

 

Appendix: Data management tools useful for graphing data

  1. The destring and encode commands
  2. The recode command
  3. The tabulate command with the generate() option
  4. The egen command
  5. The contract and collapse commands
  6. The statsby command
  7. The snapshot command
  8. The reshape command
  9. Macros and loops
  10. Extracting value labels to local macros

 

 

Note: There is a one-week break between the posting of Session 2 and 3; however, course leaders are available for discussion.