Here's my code (looking at only one variable):
gam <- gam(heart_data$DEATH_EVENT~ s(age) + anaemia +
s(creatinine_phosphokinase) + diabetes +
s(ejection_fraction) + high_blood_pressure +
s(platelets) + s(serum_creatinine) +
s(serum_sodium) + sex + smoking, family = "binomial",
data = heart_data, method = "REML")
plot(gam, select = c(5), trans = plogis, rug = TRUE,
residuals = TRUE,
pch = 1, cex = 1, shift = coef(gam)[1], seWithMean = TRUE)
visreg(gam, "serum_creatinine", scale="response", rug=2,
xlab="serum creatinine",
ylab="P(mortality)")
I get:
I assumed that after correcting for the intercept they should match. What am I missing?

