I am modeling the seasonal occurrence of a species at different sites (count data). I am specifically trying to identify potential drivers of the seasonal pattern. To this end, I have selected a number of environmental variables and I am planning on using the gam() function in mgcv to fit hierarchical GAMs allowing variation of smoothers across sites. I am using the negative binomial distribution for count data. However, the range of the candidate predictor varies across groups (see Plot 1 below, y is the count response per day, x is the environmental variable, and facets represent sites). Plot 2 is a time series of this predictor across sites.

Should I transform the predictor scale prior to fitting the model? Maybe by standardizing or normalizing the data (per site) ? For some predictors, I may be able to remove a few isolated points, treating them as outliers (even if ecologically plausible) to reduce the range and fit the regression better for most of the sites. But for others, such as the one plotted below, I cannot discard points as they just reflect different dynamics of the predictor at different sites...

This thread does not recommend scaling, while this one answers a similar question on GLMMs. I am worried that leaving the data as they are now will affect the model by increasing the importance of one site (within a single predictor). Similarly, I wonder if such issues would arise among predictors (one variable weighing more in a model), as they are measured on different scales (e.g chlorophyll concentration, day of the year, temperature...). On the other hand; normalizing the data erases the information on inter-site variability in environmental conditions. Are there common practices for such questions in GAMs?

Plot 1:

enter image description here

Plot 2:

enter image description here


1 Answer 1


GLMM Scaling

The reason you are getting different answers on a thread from GLMM and a thread on GAM(M)s is that scaling affects each differently. Regarding GLMMs, there are generally a number of reasons for transforming the data, which may include:

  • The data is not linear and a simple transformation may make the relationship linear.
  • There is an interaction and the scales of each variable involved are not comparable.
  • The response variable is not normally distributed, and transforming it to be normal allows one to apply a Gaussian mixed effects model to the data.

Specific to the interaction case, here is a useful quote from Harrison et al., 2018 that highlights why this is specifically done for standardized scaling:

Transformations of predictor variables are common, and can improve model performance and interpretability (Gelman & Hill, 2007). Two common transformations for continuous predictors are (i) predictor centering, the mean of predictor x is subtracted from every value in x, giving a variable with mean 0 and SD on the original scale of x; and (ii) predictor standardising, where x is centred and then divided by the SD of x, giving a variable with mean 0 and SD 1. Rescaling the mean of predictors containing large values (e.g. rainfall measured in 1,000s of millimetre) through centring/standardising will often solve convergence problems, in part because the estimation of intercepts is brought into the main body of the data themselves. Both approaches also remove the correlation between main effects and their interactions, making main effects more easily interpretable when models also contain interactions (Schielzeth, 2010). Note that this collinearity among coefficients is distinct from collinearity between two separate predictors (see above). Centring and standardising by the mean of a variable changes the interpretation of the model intercept to the value of the outcome expected when x is at its mean value. Standardising further adjusts the interpretation of the coefficient (slope) for x in the model to the change in the outcome variable for a 1 SD change in the value of x. Scaling is therefore a useful tool to improve the stability of models and likelihood of model convergence, and the accuracy of parameter estimates if variables in a model are on large (e.g. 1,000s of millimetre of rainfall), or vastly different scales. When using scaling, care must be taken in the interpretation and graphical representation of outcomes.

From personal experience, not scaling an interaction almost always leads to model convergence failure unless the predictors are on very similar scales, so it can often be a matter of practical importance. However, for other transformations of the data, it depends on what you are trying to achieve (such as normality, linearity, etc.).

GAMM Scaling

I was the one who originally answered the question you linked and it's important to recognize the context of what I was stating there. First, I don't know if they understood the gam function arguments so they had applied it blindly without understanding what they did. Second, my answer is more specific to standardized scaling, which typically involves transforming data from raw scores to z-scores. This is generally a bad idea for GAMMs because it can totally mess up the interpretation of the model due to the lack of context it provides. However, that doesn't mean that scaling or transformation in general is bad.

A great example is from Pedersen et al., 2019, which highlights a a GAMM that includes log concentration of CO2 and log uptake of C02 for some plants. They don't show the original data they applied this to, but I suspect the reason they did this was for reasons similar to your plots in your Plot 1 area. When data is "smooshed into the left corner" as I horribly describe it, it is typical for people to use a log-log regression in the linear case to spread out the distribution of values to be more meaningful. I imagine this was applied to similar effect in the GAMM data. For examples of this kind of regression and why it is done, I recommend reading Chapter 3 of Regression and Other Stories, which has a worked example in R.

In any case, you can theoretically scale the data, just understand that your interpretation of the data will have to change with it, which is why caution should be taken when doing so. In the case where data is transformed from log-log, they are no longer in raw form and represent percent increases/decreases along the x/y axes.


  • Gelman, A., Hill, J., & Vehtari, A. (2022). Regression and other stories. Cambridge University Press.
  • Harrison, X. A., Donaldson, L., Correa-Cano, M. E., Evans, J., Fisher, D. N., Goodwin, C. E. D., Robinson, B. S., Hodgson, D. J., & Inger, R. (2018). A brief introduction to mixed effects modelling and multi-model inference in ecology. PeerJ(6), e4794. https://doi.org/10.7717/peerj.4794
  • Pedersen, E. J., Miller, D. L., Simpson, G. L., & Ross, N. (2019). Hierarchical generalized additive models in ecology: An introduction with mgcv. PeerJ(7), e6876. https://doi.org/10.7717/peerj.6876
  • $\begingroup$ Thank you for taking the time to provide a very comprehensive and detailed answer, and references ! It's much clearer to me know. I was also unsure whether I interpreted the other posts right given a different model framework and contexts, so thanks for clarifying the difference between both cases. So, if I understood correctly, transformation might help in case of a skewed data distribution (as in Pedersen et al. 2019), or if I want to specify interaction terms between variables measured on different scales (in GLMMs), but may not be necessary otherwise. Is this correct? $\endgroup$
    – Timelate
    Mar 6, 2023 at 9:46
  • $\begingroup$ There are other cases where it may matter, but the reasons to apply scaling to GAMs become less important in terms of fixing nonlinearity, interactions, etc. Those citations may provide some more useful information. $\endgroup$ Mar 6, 2023 at 10:20
  • 1
    $\begingroup$ Thank you very much ! I am reading the Gelman et al. 2022 book at the moment it is very informative :) $\endgroup$
    – Timelate
    Mar 6, 2023 at 10:27
  • $\begingroup$ Yes I think it should be required reading for grad stats classes. Its an excellent resource. $\endgroup$ Mar 6, 2023 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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