R code for fitting Generalized Additive Models to wildlife census data

e-mail to r.fewster@auckland.ac.nz

This page gives R versions of the SPLUS code used in the paper Analysis of population trends for farmland birds using generalized additive models (Ecology 81, 1970-1984 (2000)), by R.M. Fewster, S.T. Buckland, G.M. Siriwardena, S.R. Baillie, and J.D. Wilson. For more information see the SPLUS code page.

R is free statistical software available for Windows, UNIX, LINUX, and MacOS. Full information about R is here, or skip straight to download.

For the functions to run in R, the library mgcv by Simon Wood is required. To see whether mgcv is already installed with your R installation, type
>library(mgcv)
at the R command line. If you get an error, go here to download the library from Simon Wood's web pages. It's a good idea to check the link to Simon's page anyway, to make sure you have the latest version of the library.

The functions should work on any platform (Windows, UNIX, LINUX, etc). However, they have only been tested on UNIX/LINUX, and some of the installation instructions are specific to these platforms.

Note: the R functions have not been tested to the same extent as the SPLUS functions, and the documentation is a quick rehash of the SPLUS documentation. Before applying these functions to your own data, please read the code carefully and modify it as necessary. Apologies for any SPLUS-specific comments that are still lurking in the documentation.

All comments are welcome. Thanks to Tsu-Yun Tso for help with translating the SPLUS code into R.

Important Notes:

Rachel Fewster      24th June 2002


Tar archive: all functions, example data set, and instructions for demonstration analysis

Typical output obtained from the demonstration data can be viewed here.

Note: the data used in the Ecology paper were part of the Common Birds Census coordinated by the British Trust for Ornithology (BTO). Information about other BTO surveys and availability of BTO data is here.


To avoid manipulating the tar archive, here are the individual functions one by one. They can each be downloaded into the working directory (all of them are needed), together with instructions.txt and the example data set cb from above. Then follow the instructions in instructions.txt for a demonstration analysis.

Fitting the model and extracting indices

Bootstrapping

Second derivatives

Confidence intervals

Plotting final output

Sourcing the functions


Last updated:  18th September 2002