I am fitting a GAM to a time series, to check for any trend and seasonality. I expect my data to be autocorrelated and as I am fitting some models I need to check if there is autocorrelation in the residuals, as part of model diagnostics.
I've read that it's recommended to apply the ACF() function to normalized residuals to accurately assess autocorrelation. Is this correct? If so, how can I get normalized residuals from a gam()-fitted (from MGCV package) model in R?
My model is something like this:
gam(abundance ~ species + s(year_factor, bs= "re") +
s(julian_day_number, by=species)+s(month_as_numeric, bs="cc", by=species),
data=data, method="REML", family=tw())
I have 5 species and I want to see if there are significant trends and seasonality in each.
- Trend is Julian day number
- Seasonality is month as numeric
- Random effect is year as factor
I have tried to plot ACF on Pearson residuals,
residuals(model, type="Pearson")
as they seemed the closest type to normalized residuals after reading some help documents on R Documentation.
You only need normalized or standardized residuals when you have fitted a correlation function in the model. As you haven't done that here, you can just use the standard residuals for the ACF diagnostic. The Pearson residuals would work too; they are standardized by the estimated variance of the observations.