Skip to content
Prev 66920 / 398513 Next

using GAM to assess the linearity in logistic regression

Dear ronggui,

There are several approaches you can take, one of which is to fit a GAM and
simply look to see whether the relationships appear linear on the logit
scale. As well, you could compare the fit of the GAM with semiparametric
models in which each smooth term in turn is replaced by a linear term; see
?anova.gam in the mcgv or gam package and the on-line appendix on
nonparametric regression to my R and S-PLUS Companion to Applied Regression
(at
http://socserv.socsci.mcmaster.ca/jfox/Books/Companion/appendix-nonparametri
c-regression.pdf, and slightly out of date).

Another approach is to fit the linear logit model with glm() and examine
component+residual (partial-residual) plots via the cr.plots() function or
the ceres.plots() function, both in the car package. 

If nonlinearity in, say, x is correctable by a power transformation, you can
get an approximate score test for the need to transform x by adding the
"constructed variable" I(x*log(x)) to the model and examining its Wald
statistic; an added-variable plot (av.plots in car) for the constructed
variable shows leverage and influence on the decision to transform x. You
can also compute a suggested power transformation as p = 1 - b/g, where b is
the coefficient of x in the *original* model and g that of the constructed
variable. Details are in the R and S-PLUS Companion. Some further examples
are in lecture notes at
http://socserv.socsci.mcmaster.ca/jfox/Courses/soc740/lecture-11.pdf.

If x is quantitative but discrete, refitting the logit model replacing x
with as.factor(x) and comparing via anova() to the original model gives a
test of nonlinearity.

I hope this helps,
 John

--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
--------------------------------