## Contents

2. Linear Models for Continuous Data

2.4. Simple Linear Regression

2.5. Multiple Linear Regression

2.6. One-Way Analysis of Variance

2.7. Two-Way Analysis of Variance

2.8. Analysis of Covariance Models

2.9. Regression Diagnostics

2.10. Transforming the Data

2.a. The Anscombe Datasets

3. Logit Models for Binary Data

3.4. The Comparison of Several Groups

3.5. Models With Two Predictors

3.6. Multi-factor Models: Model Selection

3.7. Other Choices of Link

3.8. Regression Diagnostics for Binary Data

4. Poisson Models for Count Data

4.a.1 Extra-Poisson Variation

4.a.2 Negative Binomial Regression

4.a.3 Zero-Inflated Poisson Regression

6. Multinomial Response Models

6.2. The Multinomial Logit Model

6.3. The Conditional Logit Model

6.4. The Sequential Logit Model

6.5. Models for Ordinal Responses

## Introduction

The "Stata Logs" collect the transcripts of six sessions using the statistical package Stata. Each session reproduces the results of (practically) all the analyses in one of the Chapters of my lecture notes on Generalized Linear Models.

The material is organized by Chapters and Sections using exactly the same numbering system as the notes, so section 2.8 of the logs deals with the analysis of covariance models described in section 2.8 of the notes.

The transcripts are formatted versions of actual Stata logs run using version 13. The text boxes set in a typewriter font contain commands or instructions to Stata, followed by the resulting output. You can tell the commands apart because they appear on lines beginning with a dot, or on continuation lines beginning with a greater than sign.

The rest of the text set in the standard font represents comments or annotations, except for references to Stata commands which are also set in a typewriter-style font. The overall format is similar to that used in the Stata manuals themselves.

The best way to use these transcripts is sitting by a computer, trying the different commands as you read along, probably with a printed copy of the notes by the side. I also recommend that you try to answer the few questions and exercises posed along the way.

If you follow this procedure you will notice that sometimes I use the continuation comment /// to indicate that a command continues on another line. If you are using Stata interactively, just keep typing on the same line.

While interactive use is probably good for learning, for more serious work I recommend that you prepare your commands in a "do file" and then ask Stata to run it. If nothing else, this will help document your work and ensure that you can reproduce your results. These logs were all produced using do files.

Stata 8 introduced a graphical interface that lets you use menus and dialogs to specify your analyses. This feature can help beginners learn the commands, but I recommend that you get used to typing your commands from the outset, so you make an easy transition to do files.

On the same vein, Stata 10 introduced a Graphics Editor that lets you modify a graph using a point-and-click interface. While this is convenient, once you have edited a graph interactively you can't easily reproduce it.

Stata 11 moved further along these lines by introducing a Variables Manager that lets you modify variable and value labels and other properties of your variables using a dialog. For serious research, however I recommend that you do all work using commands stored in a do file.

The purpose of these notes is to illustrate the use of Stata in statistical analysis, not to provide a primer or tutorial. I have, however, written a short tutorial that you can find at http://data.princeton.edu/stata. Please consult the Stata online help and manuals for more details.

## Revision History

The "Stata Logs" were first published in January 1993 and targeted version 3. Revisions were completed to target newer releases roughly every couple of years. The current edition targets version 13.

Continue with 2. Linear Models