Presentation is loading. Please wait.

Presentation is loading. Please wait.

Making a figure with Stata or Excel Biostatistics 212 Lecture 7.

Similar presentations


Presentation on theme: "Making a figure with Stata or Excel Biostatistics 212 Lecture 7."— Presentation transcript:

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

2 Housekeeping Lab 5 cleanup –Which p-value is which? –Deciding when to “call” an interaction Final Project questions? –Print and hand in to Olivia or Allison (5 th floor) by the end of the day on 9/19/06 –20 points docked for each 1 day late –Email or call for help! PLEASE DO COURSE EVALUATIONS –You’ll get a link by email

3 . cs dead anycac, by(ageover60) ageover60 | RR [95% Conf. Interval] M-H Weight -----------------+------------------------------------------------- 0 | 3.294296 2.124413 5.108418 11.78094 1 | 3.372508 1.922288 5.916809 9.848343 -----------------+------------------------------------------------- Crude | 4.763402 3.413478 6.64718 M-H combined | 3.329908 2.345418 4.727639 ------------------------------------------------------------------- Test of homogeneity (M-H) chi2(1) = 0.004 Pr>chi2 = 0.9479

4 . mhodds dead anycac, by(ageover60) Maximum likelihood estimate of the odds ratio Comparing anycac==1 vs. anycac==0 by ageover60 ------------------------------------------------------------------------------- ageov~60 | Odds Ratio chi2(1) P>chi2 [95% Conf. Interval] ----------+-------------------------------------------------------------------- 0 | 3.343423 31.95 0.0000 2.14383 5.21426 1 | 3.537836 20.94 0.0000 1.98502 6.30536 ------------------------------------------------------------------------------- Mantel-Haenszel estimate controlling for ageover60 ---------------------------------------------------------------- Odds Ratio chi2(1) P>chi2 [95% Conf. Interval] ---------------------------------------------------------------- 3.429722 51.90 0.0000 2.400138 4.900967 ---------------------------------------------------------------- Test of homogeneity of ORs (approx): chi2(1) = 0.02 Pr>chi2 = 0.8776

5 . xi: logistic dead i.anycac*i.ageover60 i.anycac _Ianycac_0-1 (naturally coded; _Ianycac_0 omitted) i.ageover60 _Iageover60_0-1 (naturally coded; _Iageover60_0 omitted) i.any~c*i.ag~60 _IanyXage_#_# (coded as above) Logistic regression Number of obs = 10372 LR chi2(3) = 188.43 Prob > chi2 = 0.0000 Log likelihood = -1065.5418 Pseudo R2 = 0.0812 ------------------------------------------------------------------------------ dead | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _Ianycac_1 | 3.343423.7564415 5.33 0.000 2.145898 5.209232 _Iageover6~1 | 3.075541 1.040157 3.32 0.001 1.585049 5.96761 _IanyXage_~1 | 1.058148.3922776 0.15 0.879.5116676 2.188289 ------------------------------------------------------------------------------

6 . logistic dead anycac ageover60 Logistic regression Number of obs = 10372 LR chi2(2) = 188.41 Prob > chi2 = 0.0000 Log likelihood = -1065.5534 Pseudo R2 = 0.0812 ------------------------------------------------------------------------------ dead | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- anycac | 3.415374.6105826 6.87 0.000 2.40583 4.848547 ageover60 | 3.223499.4453269 8.47 0.000 2.458861 4.225919 ------------------------------------------------------------------------------

7 . cs dead anycac, by(male) male | RR [95% Conf. Interval] M-H Weight -----------------+------------------------------------------------- 0 | 5.901622 3.668887 9.493106 8.3619 1 | 4.287304 2.679298 6.860369 11.74511 -----------------+------------------------------------------------- Crude | 4.763402 3.413478 6.64718 M-H combined | 4.95865 3.549869 6.926513 ------------------------------------------------------------------- Test of homogeneity (M-H) chi2(1) = 0.883 Pr>chi2 = 0.3473

8 Housekeeping Lab 5 cleanup –Which p-value is which? –Deciding when to “call” an interaction Final Project questions? –Print and hand in to Olivia or Allison (5 th floor) by the end of the day on 9/19/06 –20 points docked for each 1 day late –Email or call for help! PLEASE DO COURSE EVALUATIONS –You’ll get a link by email

9 Today... Figure basics –Why make a figure? –Types of figures –Elements of a figure Steps in making a figure Stata versus Excel The Final Project, grading

10 Figures Figures are GOOD for presenting overall effects Figure are NOT GOOD for presenting specific measurements Browner, W. Publishing and Presenting Clinical Research

11 Figures “A picture is worth a thousand words”

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

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

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

15 Figures “A picture is worth a thousand words” How many words is this picture worth? WhiteBlack Drinks/dayn=1935n=1727 040%57% 0.1-0.939%26% 1-1.913%9% 2+8%8% Worth = 1 small table

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

17 Figures “A picture is worth a thousand words” How many words is this picture worth? % with CAC AbstainerMod drinker Black women.047.036 White women.054.049 Black men.068.132 White men.180.167

18 Figures “A picture is worth a thousand words” How many words is this picture worth? Worth = “A thousand words”?

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

20 Figures “A picture is worth a thousand words” How many words is this picture worth? Worth = 968 data points + lines > 1000 words?

21 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

22 Figures Types of figures –Photographs –Diagrams –Data representation Browner, W. Publishing and Presenting Clinical Research

23 Figures Types of data figures –Pie charts –Bar graphs –Line graphs –Scatter plots –Box plots Browner, W. Publishing and Presenting Clinical Research

24 Figures Elements of a figure –Graphics (non-text) –Labels (axes, lines/bars, etc), other text –Figure legend (Title, explanations, p-values) Browner, W. Publishing and Presenting Clinical Research

25 Steps in making a Figure In Stata: –Sketch the Figure, with title –Write a do file –Format so it makes sense and looks nice –Compose a figure legend In Excel: –Sketch the Figure, with title –Dummy data table in Excel –Write a do file to fill in table –Copy and paste the data in –Format so it makes sense and looks nice –Compose a figure legend

26 Steps in making a Figure Sketch the Figure, with title –Try several versions –Point should be clear at a glance –Requires some artistic vision…

27 Steps in making a Figure Can I make this figure with Stata?

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 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

30 Stata vs. Excel for Figures Both Stata and Excel can produce very nice- looking figures.

31 Steps in making a Figure Write a do file –If making a figure with Stata, your do file might contain only 1 actual Stata command

32 Steps in making a Figure Write a do file –If making a figure with Stata, your do file might contain only 1 actual Stata command twoway (scatter dfev1 cumpy10 if menthol1==1, msymbol(plus) msize(small) mcolor(black)) /// (scatter dfev1 cumpy10 if menthol1==0, msymbol(circle_hollow)) /// (line m cumpy10 if menthol1==1, sort clcolor(black) clpat(dash) clwidth(thick)) /// (line nm cumpy10 if menthol1==0, 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))

33 Steps in making a Figure Write a do file –If making a figure with Stata, your do file might contain only 1 actual Stata command Compose using dialog box from menu

34 Steps in making a Figure Write a do file –If making a figure with Stata, your do file might contain only 1 actual Stata command Compose using dialog box from menu –If making it with Excel, you’ll need to produce all the numbers with analysis Paste into Excel from log file Use Chart Wizard

35 Steps in making a Figure Write a do file –If making a figure with Stata, your do file might contain only 1 actual Stata command Compose using dialog box from menu –If making it with Excel, you’ll need to produce all the numbers with analysis Paste into Excel from log file Use Chart Wizard –Either way, you may need additional Stata commands for p-values, figure legend, etc

36 Steps in making a Figure Format so it looks nice, and makes sense –With Stata: Use dialog box Submit, modify, submit again, etc –With Excel Point, click, modify

37 Steps in making a Figure Compose a figure legend –Title, explanations, p-values, etc –Separate section in manuscript or at bottom of page – depends on journal

38 Steps in making a Figure Example – Excel Example - Stata

39 twoway (scatter dfev1 cumpy10 if menthol1==1, msymbol(plus) msize(small) mcolor(black)) /// (scatter dfev1 cumpy10 if menthol1==0, msymbol(circle_hollow)) /// (line m cumpy10 if menthol1==1, sort clcolor(black) clpat(dash) clwidth(thick)) /// (line nm cumpy10 if menthol1==0, 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 Final Project, grading Grading –80% (256 out of 319 possible) required to get a “Satisfactory” score in the class –Also need to turn in all the Labs, even if they are late

43 Final Project, grading Final Project will count for 150/319 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

44 Final Project, grading Final Project will count for 150/319 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

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

46 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

47 That’s it! Thanks for your active participation in the course.


Download ppt "Making a figure with Stata or Excel Biostatistics 212 Lecture 7."

Similar presentations


Ads by Google