Making a figure with Stata or Excel - PowerPoint PPT Presentation

1 / 42
About This Presentation
Title:

Making a figure with Stata or Excel

Description:

Making a figure with Stata or Excel Biostatistics 212 Lecture 7 Housekeeping Lab 5 issues Does your do file run? Make sure! Comment correctly Final Project questions? – PowerPoint PPT presentation

Number of Views:135
Avg rating:3.0/5.0
Slides: 43
Provided by: MarkPl5
Category:

less

Transcript and Presenter's Notes

Title: Making a figure with Stata or Excel


1
Making a figure with Stata or Excel
  • Biostatistics 212
  • Lecture 7

2
Housekeeping
  • Lab 5 issues
  • Does your do file run? Make sure!
  • Comment correctly
  • Final Project questions?
  • Print and hand in to Olivia or Allison (5th
    floor) by the end of the day on 9/18/07
  • 20 points docked for each 1 day late
  • Email or call for help!
  • PLEASE DO COURSE EVALUATIONS
  • Youll get a link by email

3
Final Project, grading
  • Grading
  • 80 (254 out of 317 possible) required to get a
    Satisfactory score in the class
  • Also need to turn in all the Labs, even if they
    are late

4
Final Project, grading
  • Final Project will count for 150/317 points
  • Table 75 points
  • 35 for do file log
  • Housekeeping commands open/close log, use
    dataset, etc
  • Analysis generate numbers in the Table
  • 40 for Table itself
  • Architecture
  • Documentation
  • Formatting/appearance

5
Final Project, grading
  • Final Project will count for 150/317 points
  • Figure 75 points
  • 35 for do file log
  • Housekeeping commands open/close log, use
    dataset, etc
  • Analysis
  • 40 for Figure itself
  • Design
  • Documentation
  • Formatting/appearance

6
Final Project, grading
  • Advice
  • Find a classmate, give them your Table and
    Figure, and get their critiques.
  • See if they can understand it without any verbal
    explanation

7
Final Project, grading
  • Extra credit
  • 10 points extra credit and bragging rights for
    the most artistic, creative, and clear figure
    turned in

8
Today...
  • Figure basics
  • Why make a figure?
  • Types of figures
  • Elements of a figure
  • Steps in making a figure with Excel
  • Steps in making a figure with Stata
  • Demos

9
Figures
  • Figures are GOOD for presenting overall effects
  • Figure are NOT GOOD for presenting specific
    measurements

Browner, W. Publishing and Presenting Clinical
Research
10
Figures
  • A picture is worth a thousand words

11
Figures
  • A picture is worth a thousand words

How many words is this picture worth?
12
Figures
  • A picture is worth a thousand words

48 of CARDIA participants consume alcohol
moderately.
How many words is this picture worth?
Worth 7 words
13
Figures
  • A picture is worth a thousand words

How many words is this picture worth?
14
Figures
  • A picture is worth a thousand words

White Black Drinks/day n1935 n1727 0 40 5
7 0.1-0.9 39 26 1-1.9 13 9 2 8 8
How many words is this picture worth?
Worth 1 small table
15
Figures
  • A picture is worth a thousand words

How many words is this picture worth?
16
Figures
  • A picture is worth a thousand words

with CAC Abstainer Mod drinker Black
women .047 .036 White women .054 .049 Black
men .068 .132 White men .180 .167
How many words is this picture worth?
17
Figures
  • A picture is worth a thousand words

How many words is this picture worth?
Worth A thousand words?
18
Figures
  • A picture is worth a thousand words

How many words is this picture worth?
19
Figures
  • A picture is worth a thousand words

How many words is this picture worth?
Worth 968 data points lines gt 1000 words?
20
Figures
  • A picture is worth a thousand words
  • Guidelines
  • Figures should have a minimum of 4 data points
  • Convey important effects, or interactions

Browner, W. Publishing and Presenting Clinical
Research
21
Steps in making an Excel figure
  • Sketch the Figure, with title
  • Try several versions
  • Point should be clear at a glance
  • Requires some artistic vision

22
Steps in making an Excel figure
  • Make a dummy TABLE
  • Contains the data for the figure
  • Doesnt have to look nice

23
Steps in making an Excel figure
  • Make a dummy TABLE
  • Contains the data for the figure
  • Doesnt have to look nice
  • Write a .do file to fill in the table

24
Steps in making an Excel figure
  • Make a dummy TABLE
  • Contains the data for the figure
  • Doesnt have to look nice
  • Write a .do file to fill in the table
  • Copy and paste from log file into the Table

25
Steps in making an Excel figure
  • Make a dummy TABLE
  • Contains the data for the figure
  • Doesnt have to look nice
  • Write a .do file to fill in the table
  • Copy and paste from log file into the Table
  • Use the Chart Wizard to create the Figure

26
Steps in making an Excel figure
  • Make a dummy TABLE
  • Contains the data for the figure
  • Doesnt have to look nice
  • Write a .do file to fill in the table
  • Copy and paste from log file into the Table
  • Use the Chart Wizard to create the Figure
  • Format format format til it looks nice

27
Stata vs. Excel for Figures
  • Excel
  • Flexible and intuitive point-and-click figures
  • Easy to create and modify
  • Flexible, more options, error bars, adjusted
    estimates, etc
  • But
  • Requires an extra step copy/pasting to Excel
  • Harder to reproduce
  • Much harder to do scatter plots

28
Stata vs. Excel for Figures
  • Stata
  • Can create very customizable figures using 1
    complex Stata command
  • Easy to recreate simple do file
  • No error
  • Scatter plots are MUCH easier with Stata
  • But
  • Harder to create the first time? - no point and
    click
  • A little less flexible?

29
Steps in making a Stata figure
  • Sketch the figure

30
Steps in making a Stata figure
  • Sketch the figure
  • Write a do file

31
Steps in making a Stata figure
  • Sketch the figure
  • Write a do file
  • Compose the command using the dialog box
  • Get the syntax down, multiple iterations
  • Transfer to your do file and edit

32
Steps in making a Stata figure
  • Sketch the figure
  • Write a do file
  • Compose the command using the dialog box
  • Get the syntax down, multiple iterations
  • Transfer to your do file and edit
  • Produce graph and edit more?
  • Graph editor function new feature!

33
Steps in making a Stata figure
  • Sketch the figure
  • Write a do file
  • Compose the command using the dialog box
  • Get the syntax down, multiple iterations
  • Transfer to your do file and edit
  • Produce graph and edit more?
  • Graph editor function new feature!
  • May need additional Stata commands for p-values,
    figure legend, etc

34
Pay attention to
  • Formatting!
  • Make it look nice and professional, but not gaudy

35
Pay attention to
  • Labeling!
  • Your figure should be understandable by itself
  • Include important p-values

36
Pay attention to
  • The Figure Legend!
  • Title, explanations, extra p-values, etc
  • Separate section in manuscript or at bottom of
    page depends on journal

37
Stata commands intro
  • Pie charts
  • graph pie, over(catvar)
  • Bar graphs
  • graph bar (mean) yvar1 yvar2, over(catvar1)
    over(catvar2) asyvars
  • Box plots
  • graph box contvar1 contvar2, over(catvar1)
    over(catvar2)
  • Scatter plots
  • twoway (graphtype yvar xvar) (graphtype yvar
    xvar)
  • Scatter, line, connect, lowess, lfit, qfit, etc

38
Demo
  • Pie charts
  • Bar charts
  • Twoway plots
  • Formatting options

39
  • twoway (scatter dfev1 cumpy10 if menthol11,
    msymbol(plus) msize(small) mcolor(black)) ///
  • (scatter dfev1 cumpy10 if
    menthol10, msymbol(circle_hollow)) ///
  • (line m cumpy10 if menthol11,
    sort clcolor(black) clpat(dash) clwidth(thick))
    ///
  • (line nm cumpy10 if menthol10,
    sort clcolor(black) clpat(solid) clwidth(thick))
    ///
  • , ytitle(Change in FEV1
    (milliliters), size(large)) yscale(titlegap(5))
    ///
  • xtitle(Pack-years of exposure to
    tobacco, size(large)) ///
  • xscale(titlegap(3)) ///
  • legend(order(1 "Menthol smokers"
    2 "Non-menthol smokers" 3 "Menthol regression"
    ///
  • 4
    "Non-menthol regression")) ///
  • scheme(s1mono) ///
  • graphregion(fcolor(none)
    lcolor(none) ifcolor(none) ilcolor(none)) ///
  • plotregion(fcolor(none)
    lcolor(none) ifcolor(none) ilcolor(none))

40
  • graph bar (mean) cac ///
  • , over(modalc) ///
  • over(racegender) ///
  • asyvars ///
  • ytitle(Prevalence of coronary
    calcification) ///
  • title("Prevalence of coronary
    calcification in moderate drinkers and
    abstainers", ///
  • size(medium) span) ///
  • subtitle("By race and gender",
    size(medsmall))

41
Summary figure tips
  • Only use a Figure if
  • There is an important message to convey
  • The visual will be more compelling and clear
  • Try using both Stata and Excel
  • Stata will be harder at first, but often worth it
  • Browner book, Stata book both helpful
  • Document, label, and be creative

42
Thats it!
  • Thanks for your active participation in the
    course.
Write a Comment
User Comments (0)
About PowerShow.com