1
$\begingroup$

When we have response variable that is of binary type and our interest is to know how probability is associated with covariates then we use logistic regression.

But I specifically want to know about logistic generalized additive models (gam).

Suppose, I have a data with binary response. How can I know whether here I need a linear or a gam logistic?

As for other data type, I can plot scatter plot of response vs covariate and if I see nonlinear pattern I can use gam. But for binary response, I can not have that choice.

(Adding mgcv tag as anyone using it may have understanding on this issue).

$\endgroup$
4
  • 1
    $\begingroup$ Does this answer your question? When to use a GAM vs GLM $\endgroup$
    – usεr11852
    Apr 6, 2023 at 11:26
  • $\begingroup$ (In short: We never do know beforehand if there is non-linearity in how a predictor affects our outcome. That is true for all modelling endeavours unless we have intricate knowledge about the system's dynamics.) $\endgroup$
    – usεr11852
    Apr 6, 2023 at 11:30
  • 3
    $\begingroup$ @TanIa What about that does not answer your question? At a glance, it sure looks like a duplicate. Is the question not the same as yours (and, if so, why)? Is the question the same but the answer inadequate? $\endgroup$
    – Dave
    Apr 6, 2023 at 12:10
  • $\begingroup$ @Dave One could interpret the question as asking "how can I test statistically if I need a smooth over a linear function?", which is what I answer below (and which isn't addressed at the other Q&A). But I only interpreted the question that way because I get asked this question a lot when teaching GAM - it's not at all clear from the Q if this is what is being asked; "how can I know..." isn't very precise/clear. $\endgroup$ Apr 6, 2023 at 12:43

1 Answer 1

3
$\begingroup$

A logistic GLM will fit linear functions of covariates on the scale of the link function (linear predictor), whereas a GAM would fit smooth functions on this scale. If you aren't sure if you need a GAM, you could just fit the GAM, check if the size of the basis expansion for each smooth was sufficiently large (via k.check() or gam.check()), and rely on the smoothing parameters to shrink away unnecessary wiggliness.

If you want a formal test for the necessity or otherwise of the wiggly bits of the smooth over a purely linear effect, you can do this with a modification to the null space for the default thin plate spline basis.

# pseudo code
m <- gam(y ~ x + s(x, m = c(2, 0), bs = "tp"),
         data = foo, method = "REML", family = binomial())

where we fit a linear term in x plus a smooth function of x, but we have modified the basis for the smooth so that it no longer includes linear functions in the span of the basis. This modification is done by m = c(2, 0), which indicates we want the usual second order derivative penalty but with a 0 size null space (the span of functions that aren't affected by the penalty because they have 0 second derivative). With this specification, the output from summary() will give a test for the necessity of the wiggliness provided by the smooth over the linear effect estimated by the linear term.

$\endgroup$
1
  • 1
    $\begingroup$ The assumptions of the two methods are very different; it makes no sense to assume that the estimated function(s) are smooth and that the functions are piecewise constant. What does "observed linear predictor" mean? The linear predictor is not observed, it is a linear combination of terms, the constants therefor having been estimated from the observed data. If you mean't can we predict from the model for the observed data on the scale of the linear predictor, then yes predict(m, type = "link"), which is the default. $\endgroup$ Apr 6, 2023 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.