1
Logistic Regression in Stata
* Here's a description of how to do logistic regression, as well as ordinal & multinomial logit
regression, in Stata.
The examples use the UCLA-ATS data set
hsb2.dta
. For logistic
regression, for the outcome variable use the dummy variable
hsci
(science achievement
score>60); if necessary create it yourself. For ordinal logistic regression you’ll create the
outcome variable
sci3
, as described later on. For the multinomial logistic example we'll use
race
as the outcome variable.
We'll begin with logistic regression, then we’ll do brief
examples of ordinal & multinomial logit.
Rick Tardanico, March 2008.
* See ‘Explanatory variables in logistic regression.doc’
* Open & examine the univariate characteristics the data set
u hsb2, clear
d
su
hist read, norm
[e.g.]
gr box read
[e.g.]
tab ses
[e.g.]
* The dependent variable is
hsci
(science achievement score>=60).
Graphically &
numerically examine the pertinent univariate, bivariate & (insofar as possible)
multivariate distributions, consider possible transformations or other manipulations,
& perhaps save a new data set consisting of listwise (i.e. ‘complete’) observations
(using the commands ‘mark’ and ‘markout’ [see Long/Freese]).
* Select the explanatory variables
* The procedure we'll use, as outlined in Hosmer & Lemeshow,
preliminarily
selects
independent indvariables based on, first, substantive & theoretical relevance, and second, on
pvalues<=.25 (which the procedure later modifies in view of more complete sets of variables
and the modelling of nonlinearities).
Begin by testing the potential explanatory variables with
the dependent variable in 'mini' logit & logistic models.
* Note: 'logit' yields the logit coefficient, while 'logistic' yields odds ratios. Specifying the
option 'or' after logit makes logit display odds ratios.
The Stata manual emphasizes that the
only distinction between 'logit' & 'logistic' is logit coefficients versus odds ratios.
The
conclusions reached by the two approaches are identical.
ci hsci, binomial
[options: agresti, jeffreys, wilson]
scatlog hsci math, ci
[download ‘scatlog’]
logit hsci math, or nolog
estimates store full
logit hsci, or
lrtest full