Some changes to Simon Wood's mgcv library mean that a couple of minor changes are necessary to the trend-fitting code if you are using an old version of mgcv. The change comes at approximately MGCV version 0.9 (exact version unknown).
It is always recommended that you upgrade to the latest version of mgcv. If this is not possible, here are the necessary changes to make the code run under the older versions:
(i) | Change | srow <- length(pred.df[1,]) | |
to | srow <- length(pred.df[,1]) |
(ii) | Change | years.pred <- pred.df[reqd.entries, srow] | |
to | years.pred <- pred.df[srow, reqd.entries] |
(i) | Change | srow <- length(result[1,]) | |
to | srow <- length(result[,1]) |
(ii) | Change | pred.allyears <- result[1:Nyears, srow] | |
to | pred.allyears <- result[srow, 1:Nyears] |