Open rpouillot opened 3 years ago
Hi @rpouillot
Thanks for the detailed description and sorry for my late answer (didn't watch the repo unfortunately). I think I've never aimed to fit a GLM without smoothing - to me, smoothing is the essential part of the GAM.
That being sad, I also cannot fully judge if the CI values of the GAM are possibly not sound when not using smoothers. Does this only apply to this case of also when using smoothers?
I'm open to approaches that outline the issue and propose an alternative solution (like yours). Is this still of interest to you?
Hi,
I had to estimate some odds-ratios from gam models and found your package. After some tries, I found that the confidence intervals were unexpectedly small. I checked the code of your
or_gam
function and found that the standard errors (se) of the odds-ratios (in the "link" scale) were estimated as the difference between the se of the estimates (sincepred_gam2_ci_low <- pred_gam1[1] - (2 * pred_gam1[2]) - pred_gam2[1] - (2 * pred_gam2[2])
which is equivalent topred_gam2_ci_low <- (pred_gam1[1] - pred_gam2[1]) - (2 * (pred_gam1[2] - pred_gam2[2]))
) and I think it is not statistically sound. The variance of the difference in the estimates is actually equal to the sum of the variances minus twice their covariances.I can illustrates the issue as following.
Here is a proposal to solve the issue. It is based on
help('predict.gam')
example to estimate the variance of sum of predictions usinglpmatrix
. Here, we want the variance of a difference but it is straightforward.We get much closer CIs. Note that they are not strictly the same because the se estimations in the gam function are completely different than in the glm function. Here is an example with real gam
This function could simply be adapted to your framework. Hope it helps. Let me know what you think.