Functions for using GAMs to model time series