I have fit a generalized additive model with a binary response using the code below:
library(mgcv)
attach(mydata)
m = gam(y ~ dm + af + s(BMI) + s(sleepworkday), family=binomial(logit), data=mydata, method="REML")
summary(m)
Not that dm and af are also binary. The results are:
Family: binomial
Link function: logit
Formula:
y ~ dm + af + s(BMI) + s(sleepworkday)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.3683 0.1291 -10.600 < 2e-16 ***
dmyes -1.0930 0.3019 -3.621 0.000294 ***
afyes -2.5139 1.0209 -2.462 0.013801 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(BMI) 1.000 1.000 4.834 0.0279 *
s(sleepworkday) 1.112 1.216 5.700 0.0305 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
R-sq.(adj) = 0.0447 Deviance explained = 6.58%
-REML = 247.49 Scale est. = 1 n = 606
It seems that both of smooth terms are significant. But they ate just a simple line as I use:
plot(m)
Here is the plot:
The other smooth term is also like a simple line. Why the smooth terms are significant yet are not curved? Should I change any options?
The p-values are for testing whether the curve is equal to zero, rather than whether it is equal to a straight line (the latter being not the most natural test when smoothing parameters are estimated automatically).