2
$\begingroup$

I followed the instructions here to create credible intervals for the smoothed terms, but these include random effects:

How I've specified my model:

library(mgcv)
gam(Secondary_yes ~ s(Year, sp=0.1) + LocSub +  s(Region, bs = "re") + s(Primary, bs = "re") + s(Primary, Year, bs = "re"), data = df_spec3 , family = binomial, method = "REML")
confint(f8, parm = "Region", type = "confidence")

output:

Smooth      Region          est         se          crit         lower       upper
s(Region)   East Midlands   -1.895607   0.06660352  1.959964    -2.026148   -1.765067
s(Region)   East of England -2.519618   0.06759729  1.959964    -2.652107   -2.387130
s(Region)   Kent, Surrey & Sussex   -2.549306   0.06568403  1.959964    -2.678044   -2.420568
s(Region)   London  -1.618823   0.05005137  1.959964    -1.716922   -1.520724
s(Region)   North East  -1.866264   0.08419919  1.959964    -2.031291   -1.701236
s(Region)   North West  -2.314324   0.05016013  1.959964    -2.412636   -2.216012
s(Region)   Northern Ireland    -2.388770   0.08680925  1.959964    -2.558913   -2.218627
s(Region)   Scotland    -2.377226   0.06396141  1.959964    -2.502588   -2.251864
s(Region)   South West  -2.477095   0.06698421  1.959964    -2.608382   -2.345809
s(Region)   Thames Valley   -2.512398   0.11049565  1.959964    -2.728966   -2.295831

I can generate intervals for all the terms but does this make sense for the smoothed random effects? What is going on in the output?

$\endgroup$
3
$\begingroup$

When using bs = "re" you are not "smoothing" the random effects, you are just exploiting the fact that a model with iid normally distributed random effects can be constructed and estimated in a GAM framework. As the documentation of random effect smooth (?mgcv::smooth.construct.re.smooth.spec) state: gam can deal with simple independent random effects, by exploiting the link between smooths and random effects to treat random effects as smooths, meaning that for each factor in Region, you assume an independent normal prior with common variance.

This means that you will get one parameter estimate and one confidence interval for each level in the factor (in this case Region).

You would get the same estimates if you (for example) used lme4 to estimate the random effects.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.