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:
Plot 2:
Best Answer
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:
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:
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.
Citations