[R] GAMS, std errors and confidence intervals

Dan Jaffe djaffe at uw.edu
Mon Jul 4 20:44:17 CEST 2016


Can anyone help me calculating CIs from a GAM analysis?

I have calculated a GAM fit (m3) and the associated std errors using
predict.gam
I assume that the 95% CI around each fit value would be 1.96
times the se.    But when I do this both on the original and a test
dataset, I find the CI's only encompass about half of the true response
values.     I have  tried this using predict.gam using both type="response"
and type="link"  and get nearly the same result.  What am I  doing wrong?

Here is the code I am using to get the 95% CIs.

se3=predict.gam(m3,dat, type="response", se.fit=TRUE)

upr <- se3$fit + (1.96 * se3$se.fit)
upr <- m3$family$linkinv(upr)
lwr <- se3$fit - (1.96 * se3$se.fit)
lwr <- m3$family$linkinv(lwr)
CI95=upr-lwr
CI95=CI95/2

	[[alternative HTML version deleted]]



More information about the R-help mailing list