Describe the process of using generalized additive models (GAMs) for non-linear trend analysis in time series data.
Instruction: Include an example scenario where GAMs would be preferred over other models.
Updated
Official answer
For daily demand, consider a GAM with a suitable link and response family: g(E[Y_t]) = α + f1(time_t) + f2(temperature_t) + f3(day_of_year_t) + weekday_terms. A cyclic seasonal smooth can connect the end and beginning of the year; a long-term smooth represents gradual trend.
Choose predictors available at the forecast origin and fit penalized smooths, with smoothing selection such as REML where supported. Basis size and smoothing penalty both matter. Inspect residual autocorrelation, dispersion and the adequacy of basis dimensions; an ordinary GAM does not automatically model serial dependence.
Evaluate forecasting with rolling or blocked time splits rather than random row splits. Fit preprocessing and tuning inside the training periods, compare with seasonal baselines, and account for uncertainty in future predictors. Extrapolation beyond the observed range can be poor even when the fitted curve is smooth.
A GAM can be useful when interpretable, smooth nonlinear effects are plausible and a straight-line model misses them. It is not universally preferable to other time-series models. Additive structure may miss interactions unless modeled, and smooth associations do not establish causality.
Reference: mgcv GAM documentation.