I have estimated the following GAM using the mgcv package:

sex ~ factor + s(x0, by = factor, bs = "ps", k = 20) + 
    s(x1, bs = "ps", k = 20) + s(x2, bs = "ps", 
    k = 20) + s(x3, bs = "ps", k = 20) + s(x4, bs = "ps", 
    k = 20) + s(x5, bs = "ps", k = 20) + s(x6, bs = "ps", 
    k = 20) + s(mun, bs = "re") + s(region, bs = "mrf", 
    xt = xt)

However, when plotting the results, the random effect does not seem to follow a Gaussian distribution.

enter image description here

Is there a way to correct that to improve the model?

  • $\begingroup$ What information, coming out of the model, are you hoping to improve? $\endgroup$ – whuber Nov 22 '18 at 15:08
  • 1
    $\begingroup$ @whuber: I am guessing he would like the distribution of the random effects for municipalities (mun) to look closer to normal? 🤔 $\endgroup$ – Isabella Ghement Nov 22 '18 at 15:15
  • 1
    $\begingroup$ Yes, that is exactly what I am looking for. Thanks Isabella $\endgroup$ – Johny Arm Nov 22 '18 at 15:17
  • 1
    $\begingroup$ This article - albeit about GLMMs not GAMMs - may come in handy: arxiv.org/pdf/1201.1980.pdf. $\endgroup$ – Isabella Ghement Nov 22 '18 at 18:07
  • 1
    $\begingroup$ For more reading, see also: niasra.uow.edu.au/content/groups/public/@web/@inf/@math/…. $\endgroup$ – Isabella Ghement Nov 22 '18 at 18:23

You may not want or need to worry about the departure from the normality assumption. Wood (2013) shows (in the Supplementary Materials, and mentioned in the text) that the test of the random effect term (as shown/performed in a call of summary() on the estimated GAM) is quite robust to failures of the normality assumption for the random effects.

So, if you are wanting to improve the distribution of the random effects to better meet the assumptions of the test of the variance component, you may not need to, except at quite small sample sizes (Simon mentions some loss of power at a sample size of 100, for example).

Should you (we) even care about the distribution? If you are just including this in the model to account for clustering in the data, perhaps we could simply appeal to Hodges (2016) and consider the penalized spline version of random effects as a convenient computational trick to estimate the things we want to estimate?


  • Hodges, J. S. 2016. Richly Parameterized Linear Models: Additive, Time Series, and Spatial Models Using Random Effects, CRC Press.
  • Wood, S. N. 2013. A simple test for random effects in regression models. Biometrika 100: 1005–1010. doi:10.1093/biomet/ast038

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.