UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

Graphing Residuals in Logistic Regression in Stata

Please Note: Stata graph commands changed with version 8 and this page was developed before version 8 was released and uses Stata 7 graph commands.  Please see How do I use version 7 graph commands in Stata version 8? for information on how to either run these Stata 7 graph commands in Stata version 8, or how you can covert these commands to use Stata 8 syntax.

* use a file
use http://www.ats.ucla.edu/stat/stata/notes/hsb2, clear

* make a 0/1 variable, 0 if < 60, 1 if >= 60
generate goodread = (read >= 60)
tab goodread


* run a logistic regression
logistic goodread write science math


* generate "pearson residual", see Hosmer & Lemewhow 1989
predict res, residual


* generate "standardized pearson residual", see Hosmer & Lemewhow 1989
predict stdres, rstandard


* 1. Graph residual vs outcome
* graph "pearson residual" vs. outcome
graph res goodread


* graph "standardized pearson residual" vs. outcome
graph stdres goodread


* 2. Graph residual vs. covariates

* graph "pearson residual" vs. write, science, math
graph res write
graph res science
graph res math


* graph "standardized pearson residual" vs. write, science, math
graph stdres write
graph stdres science
graph stdres math
 

How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California