# Re: st: logistic regr followed by lowess

 From "stata_user stata_user" <[email protected]> To [email protected] Subject Re: st: logistic regr followed by lowess Date Sat, 02 Sep 2006 17:14:08 +0100

```Thanks a lot to Nick and Joseph for their useful comments

sysuse auto, clear
logit foreign mpg
predict p
sort mpg
line p  mpg || lowess  foreign mpg

What the lowess does here, nonparametric regression of the p and mpg?

Thanks a lot

S.

```
From: Joseph Coveney <[email protected]>
To: Statalist <[email protected]>
Subject: Re: st: logistic regr followed by lowess
Date: Sat, 02 Sep 2006 11:31:10 +0900

Sami wrote:

I have an outcome y dichotomous (0/1) and a continuous predictor X1

I use
logit y X1
I predict
p
and then I use the lowess smooth curve

I have a confusion about the lowess.

I am not sure if the lowess fits smooth successive non paramteric regression
(Y X1) for successive small intervals of X1 (starting with the smallest
values of X1), and then produces a smooth option of the predicted
probabilities

Or if it fits successive logistic regression models followed by a smooth
graph of these probabilities of these models

--------------------------------------------------------------------------------

Are you asking about the -logit- option to -lowess-? It just affects the
display scale of the y-axis and omits the scatterplot of the observed
values. -lowess- does LOWESS (LOESS) smoothing and doesn't perform
logistic regression to my knowledge.

If you're looking to create a logistic regression calibration plot as
advocated in Frank E. Harrell Jr, _Regression Modeling Strategies_ (N.Y.:
Springer, 2001), then you can overlay a -twoway function- (for the logistic
regression fit) and -lowess-. That's shown below; it follows the lead of
Nick's post in this thread. Professor Harrell plots these on the
probability scale. If you want to show the calibration plot on the logit
scale, then follow the second syntax below. Note that you'll lose the
scatterplot of the observed values when plotting on the logit scale. The
latter highlights discrepancies at the extremes, which are not always greatest of interest.

Joseph Coveney

sysuse auto, clear
logit foreign mpg
predict probability
graph twoway ///
( function y = invlogit(_b[_cons] + _b[mpg] * x) , ///
range(mpg) lcolor(black) ) ///
( lowess foreign mpg, ///
lcolor(black) lpattern(dash) ) ///
( scatter foreign mpg, ///
msymbol(circle) mcolor(black) ///
ytitle(Probability That Car Manufacturer is Foreign) ///
ylabel( , format(%02.1f) angle(horizontal) nogrid) ///
xtitle(Miles per Gallon) legend(off) name(Probability) )
predict logits, xb
lowess foreign mpg, logit lineopts(lcolor(black) lpattern(dash)) ///
legend(off) ///
ytitle(Log Odds That Manufacturer is Foreign) ///
ylabel( , angle(horizontal) nogrid) title("") ///
subtitle("") note("") name(Logit) )
exit

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
_________________________________________________________________