See also the course s documents Making Contingency Tables in Stata and Editing Stata estab and outreg2 Tables in MS-Word.



Similar documents
Using Stata s esttab and outreg2 with MS-Word to make publication-style regression tables

outreg help pages Write formatted regression output to a text file After any estimation command: (Text-related options)

<next> Italian Stata Users Group meeting. Tutorial: Output processing and automatic reporting with Stata. Ben Jann, ETH Zurich,

<next> <PDF version> Tutorial: Automated table generation and reporting with Stata. Ben Jann, ETH Zurich,

Getting Started in Frequencies, Crosstab, Factor and Regression Analysis (ver. 2.0 beta, draft)

1. What is the critical value for this 95% confidence interval? CV = z.025 = invnorm(0.025) = 1.96

Basic Statistical and Modeling Procedures Using SAS

Data Analysis Tools. Tools for Summarizing Data

Failure to take the sampling scheme into account can lead to inaccurate point estimates and/or flawed estimates of the standard errors.

MULTIPLE REGRESSION EXAMPLE

Ian Watson

Regression step-by-step using Microsoft Excel

From this it is not clear what sort of variable that insure is so list the first 10 observations.

Scatter Plots with Error Bars

EXCEL Analysis TookPak [Statistical Analysis] 1. First of all, check to make sure that the Analysis ToolPak is installed. Here is how you do it:

CREATING FORMAL REPORT. using MICROSOFT WORD. and EXCEL

Introduction to Quantitative Methods

How to set the main menu of STATA to default factory settings standards

Introduction to Microsoft Excel 2007/2010

Bill Burton Albert Einstein College of Medicine April 28, 2014 EERS: Managing the Tension Between Rigor and Resources 1

An introduction to using Microsoft Excel for quantitative data analysis

Lab 5 Linear Regression with Within-subject Correlation. Goals: Data: Use the pig data which is in wide format:

SAS R IML (Introduction at the Master s Level)

Data analysis and regression in Stata

Handling missing data in Stata a whirlwind tour

Generalized Linear Models

There are six different windows that can be opened when using SPSS. The following will give a description of each of them.

ITS Training Class Charts and PivotTables Using Excel 2007

Using Stata 9 & Higher for OLS Regression Richard Williams, University of Notre Dame, Last revised January 8, 2015

Polynomial Neural Network Discovery Client User Guide

Data analysis process

Milk Data Analysis. 1. Objective Introduction to SAS PROC MIXED Analyzing protein milk data using STATA Refit protein milk data using PROC MIXED

Introduction to STATA 11 for Windows

SPSS and AM statistical software example.

Formatting Formatting Tables

Bowerman, O'Connell, Aitken Schermer, & Adcock, Business Statistics in Practice, Canadian edition

Marginal Effects for Continuous Variables Richard Williams, University of Notre Dame, Last revised February 21, 2015

SIMPLE LINEAR CORRELATION. r can range from -1 to 1, and is independent of units of measurement. Correlation can be done on two dependent variables.

A Brief Introduction to SPSS Factor Analysis

Multicollinearity Richard Williams, University of Notre Dame, Last revised January 13, 2015

Microsoft Office. Mail Merge in Microsoft Word

Minitab Tutorials for Design and Analysis of Experiments. Table of Contents

Multinomial and Ordinal Logistic Regression

The importance of graphing the data: Anscombe s regression examples

Correlation and Regression

1.1. Simple Regression in Excel (Excel 2010).

Dealing with Data in Excel 2010

Intellicus Enterprise Reporting and BI Platform

INTRODUCTION TO EXCEL

Getting Started with Minitab 17

Instructions for data-entry and data-analysis using Epi Info

Using outreg2 to report regression output, descriptive statistics, frequencies and basic crosstabulations (v1.6 draft)

Regression Analysis: A Complete Example

Figure 1. An embedded chart on a worksheet.

KSTAT MINI-MANUAL. Decision Sciences 434 Kellogg Graduate School of Management

Appendix III: SPSS Preliminary

3. Add and delete a cover page...7 Add a cover page... 7 Delete a cover page... 7

GeoGebra Statistics and Probability

Spreadsheet software for linear regression analysis

Please follow the directions once you locate the Stata software in your computer. Room 114 (Business Lab) has computers with Stata software

Addressing Alternative. Multiple Regression Spring 2012

Lesson 07: MS ACCESS - Handout. Introduction to database (30 mins)

Odds ratio, Odds ratio test for independence, chi-squared statistic.

Data exploration with Microsoft Excel: analysing more than one variable

Reporting with Pentaho. Gabriele Pozzani

An introduction to IBM SPSS Statistics

Psych. Research 1 Guide to SPSS 11.0

Importing and Exporting With SPSS for Windows 17 TUT 117

ln(p/(1-p)) = α +β*age35plus, where p is the probability or odds of drinking

Integrating Microsoft Word with Other Office Applications

Using Excel for descriptive statistics

Using SPSS, Chapter 2: Descriptive Statistics

Calculator Notes for the TI-Nspire and TI-Nspire CAS

The Center for Teaching, Learning, & Technology

Intermediate PowerPoint

VI. Introduction to Logistic Regression

Merging Labels, Letters, and Envelopes Word 2013

containing Kendall correlations; and the OUTH = option will create a data set containing Hoeffding statistics.

Using the Cute Rich-Text Editor

Univariate Regression

The Chi-Square Test. STAT E-50 Introduction to Statistics

Two Correlated Proportions (McNemar Test)

Summary of important mathematical operations and formulas (from first tutorial):

Data exploration with Microsoft Excel: univariate analysis

Introduction Course in SPSS - Evening 1

Minitab 17 Statistical Software

MS Excel. Handout: Level 2. elearning Department. Copyright 2016 CMS e-learning Department. All Rights Reserved. Page 1 of 11

HYPOTHESIS TESTING: CONFIDENCE INTERVALS, T-TESTS, ANOVAS, AND REGRESSION

CREATING EXCEL PIVOT TABLES AND PIVOT CHARTS FOR LIBRARY QUESTIONNAIRE RESULTS

Introduction. Hypothesis Testing. Hypothesis Testing. Significance Testing

Graphing Parabolas With Microsoft Excel

Using Microsoft Word. Working With Objects

Quick Stata Guide by Liz Foster

Engineering Problem Solving and Excel. EGN 1006 Introduction to Engineering

An Introduction to Excel Pivot Tables

McAfee Endpoint Encryption Reporting Tool

Basic Microsoft Excel 2007

Outline. Topic 4 - Analysis of Variance Approach to Regression. Partitioning Sums of Squares. Total Sum of Squares. Partitioning sums of squares

Estimating a market model: Step-by-step Prepared by Pamela Peterson Drake Florida Atlantic University

Formulas, Functions and Charts

Transcription:

Making Working & Publication-style Tables in Stata See also the course s documents Making Contingency Tables in Stata and Editing Stata estab and outreg2 Tables in MS-Word. Gary Klass, How to Construct Bad Charts and Graphs http://lilt.ilstu.edu/gmklass/pos138/datadisplay/badchart.htm Gary Klass, Presenting Data: Tabular and graphic display of social indicators http://lilt.ilstu.edu/gmklass/pos138/datadisplay/ Jon Kolko, Edward Tufte (on principles of data presentation) http://facultypages.scad.edu/~jkolko/_iact370_informationarchitecture/iact370_0 5_TuftePrinciples.pdf Note: Copying tables directly from the Stata Results-window to MS-Word works well if MS-Word is formatted to display Courier 11 point or less (which is a fixed-space font). If necessary you can then change to a proportionally spaced font (such as Times New Roman) in MS-Word, but doing so may involve considerable formatting (see the course web document Editing estab and outreg2 Tables in MS-Word ). Here are examples of Stata table-making commands, which you can obtain by using findit, help, Stata listserv, UCLA Resources for Learning Stata, and ssc whatsnew. tabstat, statsmat, tablemat, fsum, and tabform: summary tables (see also findit for svytabs and svytabform). tabout: publication-style summary and contingency tables (see also svytabs and svytabform). mkcorr, corrtab, and makematrix: publication-style correlation matrices. The combination of eststo and esttab (which is a spin-off from estout; see below): not only displays publication-style regression tables in the Stata results window, but also can directly produce them in Word or Excel, and output them to LaTeX. outreg2: can directly create regression tables in Word or Excel, and output them to LaTeX. Formatting by group : By-group as row variable Ave. Income % Poverty Community1 12,636 34.3 Community2 15,151 31.1 Community3 16,204 29.5 1

By-group as column variable Community1 Community 2 Community 3 Ave. income 12,236 15,151 16,204 % poverty 34.3% 31.1% 29.5% tabstat help tabstat tabstat read write math science, stats(mean med sd min max) format(%9.2f) tabstat read write math science, stats(mean med sd min max) format(%9.2f) col(stats) tabstat read write math science, stats(mean med sd min max) format(%9.2f) by(female) col(stats) Note: semean displays standard error, cv displays coefficient of variation. statsmat (findit & download; basically the same as tabstat, but displays & exports table as matrix) findit statsmat help statsmat statsmat science, by(female) f(%9.0f) s(n min q max) matrix(m1) statsmat science, by(female) f(%9.0f) s(n min q max) xpose matrix(m2) tablemat (findit & download; permits more flexible use of by-variables and labeling than tabstat & statsmat; displays the same statistics as tabstat, but displays only one statistic at a time) findit tablemat help tablemat tablemat read write math, st(mean) by(ses) name(table) format(%9.2f) tablemat read write math, st(mean) by(female ses prog) name(table) format(%9.2f) fsum (findit & download; permits display of # missing & lower-upper confidence intervals, which tabstat, statsmat, & tablemat do not) findit fsum help fsum fsum read write math, s(n miss mean sd lci uci) format(%9.2f) 2

tabform (findit & download; permits display of confidence intervals, which tabstat & tablemat do not; tests & displays results of equality of means, which tabstat, statsmat, tablemat, & fsum do not) findit tabform help tabform tabform read write math using table.xls, by(ses) sd ci dec(2) sdbracket cibrace nototal Open Excel, navigate to table.xls, and follow the wizard instructions to display the table. tabform displays only the mean if other statistics are not requested. tabform read write math using table.xls, by(ses) sd ci bdec(2) sdbracket cibrace nototal vertical Publication-style summary & contingency tables (tabout): findit tabout help tabout use hsb2, clear la var schtyp School Type la def st 0 Public 1 Private la val schtyp st tab schtyp la var ses SES la def ses 1 Low 2 Middle 3 High la val ses ses tab ses tabout ses schtyp using sesst, cell(col) format(1) clab(col_%) stats(chi2) replace Select MS-Word file sesst (located in current folder), and edit in Word or copy/paste to Excel. Some options: cell: freq, cell, row, col, cum [all can be specified) format: # decimal points; specify in order of types of cell entries specified clab: table s title layout: how the columns are laid out stats: types of statistics specified Publication-style correlation matrix (mkcorr): findit mkcorr help mkcorr 3

mkcorr read write math science socst, log(hsb2corr) sig means cdec(2) mdec(2) casewise Note: The default is pairwise (pwcorr). You must specify casewise if you want the equivalent results of corr. Select file hsb2corr (located in current folder) in Word, and edit in Word or copy/paste to Excel. Options: sig: display significance test p-values cdec( ): # decimal points displayed in correlation coefficients means: display descriptive numerical summary mdec( ): # decimal points displayed in descriptive numerical summary casewise: display casewise results (instead of default pairwise results) Publication-style correlation matrix (corrtab): findit corrtab help corrtab corrtab read write math science, obs sig bonf vsort(read) format(%9.2f) corrtab read write math science, cwd obs sig bonf vsort(read) format(%9.2f) corrtab read write math science, spearman obs sig bonf vsort(read) format(%9.2f) Note: pairwise (the equivalent of pwcorr in Stata) is the default unless cwd (casewise, equivalent to corr in Stata) is not specified. Spearman may also be specified. corrtab is designed for a maximum of eight variables. Publication-style correlation matrix (makematrix) : findit makematrix help makematrix makematrix, from(r(rho)) format(%9.2f): corr read-socst makematrix, from(r(rho)) col(socst) format(%9.2f): corr read-socst Working or publication-style OLS regression table (esttab): findit esttab help esttab help eststo la var math Math la var read Read la var female Female reg science math read female eststo [eststo refers to estimates store ] 4

reg science math read female schtyp eststo esttab, se starlevels(+.10 *.05 **.01) b(%9.2f) r2(%9.2f) ar2(%9.2f) aic bic nodepvars nomtitles title( OLS Science Models ) addnotes( Note: Put your notes here. ) Or to directly produce an MS-Word table: esttab using science.rtf, se b(%9.2f) starlevels(+.10 *.05 **.01) r2(%9.2f) ar2(%9.2f) aic bic nodepvars nomtitles title( OLS Science Models ) addnotes( Note: Put your notes here. ) Then click on the link in the Stata results window. Note: csv instead of rtf creates an Excel document. See help esttab regarding drop, keep, order ; formatting numbers; compress (which squeezes the column space); wide (to display standard errors next to coefficients); ci (to display confidence intervals); beta (to display standardized coefficients); optional specification of replace or append ; and other options. Note: see help eststo. Publication-style logistic regression table (esttab): la var white White la var science Science xi3:logistic white math science i.prog, nolog eststo esttab, eform se b(%9.3f) starlevels(+.10 *.05 **.01) scalars(ll df_m aic bic) sfmt(%9.3f %9.0f %9.3f) nodepvars title( Logistic Whites vs. Others Model ) addnotes( Note: Put your notes here. ) Or: estab using whites.rtf, eform se b(%9.3f) starlevels(+.10 *.05 **.01) scalars(ll df_m aic bic) sfmt(%9.3f %9.0f %9.3f) nodepvars title( Logistic Whites vs. Others Model ) addnotes( Note: Put your notes here. ) Note: eform to display odds ratios Publication-style multinomial logit regression table (esttab): tab prog tab prog, nolabel mlogit prog math read science female, base(2) rrr nolog eststo esttab m1, eform se unstack b(%9.3f) starlevels(+.10 *.05 **.01) scalar(ll chi2 df_m aic bic) scalars(ll df_m aic bic) sfmt(%9.3f %9.0f %9.3f) nodepvars nomtitles title( Multinomial Logit Model ) addnotes( Note: Put your notes here. ) 5

Or: estab using whites.rtf, eform se unstack b(%9.3f) starlevels(+.10 *.05 **.01) scalar(ll chi2 df_m aic bic) scalars(ll df_m aic bic) sfmt(%9.3f %9.0f %9.3f) nodepvars nomtitles title( Multinomial Logit Model ) addnotes( Note: Put your notes here. ) Note: eform, as well as unstack to display sub-equations in separate columns. Using esttab in profile.do to make easy regression tables You can routinely make easy-to-read, full-feature regression tables for exploratory analysis if you include the following commands in profile.do (specifying any function keys you wish): * eststo global F1 = eststo * esttab OLS regression table global F2 = "esstab, se r2 ar2 aic bic starlevels(+.10 *.05 **.01 ***.001) nodepvars nomtitles compress" * esttab logistic regression table global F3 = "estabb, eform se starlevels(+.10 *.05 **.01 ***.001) scalars(ll chi2 df_m aic bic) nodepvars nomtitles compress" * esttab multinomial logistic regression table global F4 = "esstab, eform se unstack starlevels(+.10 *.05 **.01 ***.001) scalars(ll chi2 df_m aic bic) nodepvars nomtitles compress" Here s how to use the first of these commands to make an OLS regression working table, given that you ve inserted the above commands into profile.do: use hsb2, clear regress science read write F1 regress science read write math female F1 F2 [or whatever function key you may have programmed, to produce the table] 6

Here s the result: ----------------------------------------------- (1) (2) ----------------------------------------------- read 0.435*** 0.261*** (0.0633) (0.0680) write 0.315*** 0.303*** (0.0684) (0.0747) math 0.282*** (0.0755) female -3.570*** (1.059) _cons 12.51*** 9.291** (3.160) (3.123) ------------------------------------------------ N 200 200 R-sq 0.456 0.527 adj. R-sq 0.450 0.518 AIC 1367.9 1343.7 BIC 1377.8 1360.2 ------------------------------------------------ Standard errors in parentheses + p<.10, * p<.05, ** p<.01, *** p<.001 Publication-style OLS regression table (outreg2): reg science math read female outreg2 using m1, replace [Click seeout in Stata results window.] outreg2 using m1s, word replace [Click ols_science.rtf.] outreg2 using m1, excel replace [Click ols_science.xml.] outreg2 using m1, alpha(0.001, 0.01, 0.05) symbol(***, **, *) adjr bdec(2) ctitle(science) addnote(do not try this at home.) onecol long replace outreg2 using m1, ci replace outreg2 using m1, beta replace [betas in parentheses, in place of se s] outreg2 read female, replace [Displays only the specified explanatory variables.] Click on seeout to see Stata display & ols.rtf to see Word display. Table>Format>Hide gridlines reg science math read outreg2 using m1, onecol long replace reg science math read female prog outreg2 using m1, onecol long append [to display results of both models] Click on seeout to see STATA display & ols.rtf to see Word display. Table>Format>Hide gridlines 7

Some options (after, ): word: output text to a Word file, which is saved in the current directory excel: output text to an Excel file onecol: suppresses multi-column format if relevant long: accompanies onecol, forcing Word of Excel to adopt one-column format replace: replaces previous model or format append: appends additional models (instead of replace ) ci: specifies confidence intervals instead of coefs beta: specifies standardized coefs bdec(): specifies # decimal places for regression coefs (default=3) tdec(): if t-values are displayed, specifies # decimal places (default=3) rdec(): if r2 or adj r2 is displayed, specifies # decimal places (default=3) adec(): if additional stats are displayed (see e and addstat ) bfmt(): specifies format for regress coefs f, fixed; g, general symbol(): specifies significance values; default is symbol(***, **, *) alpha(): specifies significance levels; default is alpha(0.000, 0.01, 0.05) adjr2: specifies adjusted r2 nor2: specifies not to display r2 e(): specify added stats, e.g., e(ll df_m chi2 aic); or e(all); does not display publication-style stat names (see addstat ). After estimating a model, type ereturn list to obtain options and codes. addstat(): to add other stats along with stat names. E.g., addstat(log likelihood, e(ll), DF, e(df_m), chi2, e(chi2), AIC, e(aic)). After estimating a model, type ereturn list to obtain options and codes. title(): specifies title ctitle(): specifies column title addnote(): to add notes Note: title and note options give the same output whether or not the text is enclosed within quotation marks. outreg2 gives an error message if addnote is formatted as follows: addnote(source: my data). So don t include a colon in the text. E.g.: reg science math read outreg2 using m1, bdec(2) bfmt(f) alpha(0.01, 0.05, 0.10) adjr2 addstat(aic, e(aic)) title(ols) addnote(study data) word replace Click on seeout to see STATA display & m1.rtf to see Word display. Table>Format>Hide gridlines Note: To display more than three levels of significance - alpha(0.001 0.01, 0.05, 0.10) symbol(***, **, *, +). To display two or more models in the same table outreg2 using m1, append 8

Publication-style logistic regression table (outreg2) See the course document Editing Stata s esttab or outreg2 regression tables in MS- Word. logistic female math read white outreg2 using m1, eform nor2 replace outreg2 using m1, eform nor2 e(ll df_m chi2 aic) word replace outreg2 using m1, eform nor2 addstat(log likelihood, e(ll), DF, e(df_m), Chi2, e(chi2)) word replace Note: eform specifies odds-ratios. See other outreg2 options above. To display more than three levels of significance - alpha(.001.01,.05,.10) symbol(***, **, *, +). To display two or more models in the same table outreg using m1, append Publication-style multinomial logit regression table (outreg2) mlogit ses math read, base(1) nolog outreg2 using m1, eform nor2 addstat(ll, e(ll), df_m, e(df_m), chi2, e(chi2)) word replace mlogit ses math read write science, base(1) nolog outreg2 using m1, eform nor2 e(ll df_m chi2) append Note: See other outreg2 options above. 9