DOI: 10.6084/m9.figshare.3525350.v1
title: Supplement 1. The code and sample data for state–space analysis of Argos movement data.

description: File List Files for running analyses from the WinBUGS gui (Windows or Linux) DCRW.txt WinBUGS code for "DCRW" model, a first-difference correlated random walk 2 KB DCRWS.txt WinBUGS code for "DCRWS" model, a first-difference CRW with switching 2 KB hsdata.txt Hooded seal movement data 12 KB hsDCRWinits.txt Hooded seal initial values for DCRW model 3 KB hsDCRWSinits.txt Hooded seal initial values for DCRWS model 5 KB gs617data.txt Grey seal 617 movement data 59 KB gs617DCRWinits.txt Grey seal 617 initial values for DCRW model 3 KB gs617DCRWSinits.txt Grey seal 617 initial values for DCRWS model 4 KB gs2986data.txt Grey seal 2986 movement data 71 KB gs2986DCRWinits.txt Grey seal 2986 initial values for DCRW model 3 KB gs2986DCRWSinits.txt Grey seal 2986 initial values for DCRWS model 5 KB Files for running analyses by calling WinBUGS from within R (Linux) DCRW.rbugs.R R script for fitting DCRW model to hooded seal data 1 KB DCRWS.rbugs.R R script for fitting DCRWS model to hooded seal data 1 KB dat4bugs.R R code required by DCRW.rbugs.R and DCRW.rbugs.R 4 KB hseal.dat Hooded seal data for analysis from within R (Linux) 6 KB gs617.dat Grey seal 617 data for analysis from within R (Linux) 27 KB gs2986.dat Grey seal 2986 data for analysis from within R (Linux) 35 KB allfiles.zip All files together 48 KB DescriptionWinBUGS version 1.4.1 was used to run the code and is freely available at http://www.mrc-bsu.cam.ac.uk/bugs/winbugs/contents.shtml. In Windows, to run the DCRW model on the hooded seal data, open DCRW.txt in WinBUGS and paste in the data file hsdata.txt and hsDCRWinits.txt. For all models we ran 2 chains for 40 000 samples with a 20 000-sample burn-in and retained every 5th sample to reduce autocorrelation. See the WinBUGS manual, included with the software, for further details on running the models. Follow the same procedure to run models on the other datasets. Summary statistics and plots can be generated directly in WinBUGS or from other software by exporting results as text files. Alternatively, one can call WinBUGS from within R, a freely available statistical computing environment, using the R2WinBUGS package (see http://www.stat.columbia.edu/~gelman/bugsR/ for details). In Linux, WinBUGS can be run via Wine (available at http://www.winehq.com/). We recommend building Wine from sourcerather than installing the binary files (see documentation included in Wine download for details). We have found that WinBUGS works flawlessly using the 20050524 release of Wine compiled on Ubuntu Linux. In Linux, WinBUGS can be run via the gui (as above) or called from within R using the rbugs package (available on the CRAN site at http://www.r-project.org). We provide sample R scripts and associated R code (in File list) to illustrate this approach for both the DCRW and DCRWS models. Note that in addition to the rbugs package, these scripts also require the chron package (available on the CRAN site at http://www.r-project.org). The following commands in R will fit the DCRW model to the hooded seal data: source('~/pathtofile/dat4bugs.R') hseal.dat source('~/pathtofile/DCRW.rbugs.R') The scripts provided run the hooded seal analyses with a timestep of 1 day. The scripts will need to be modified to run analyses on the grey seal datasets with a timestep of 2 days. Note, also, that the path names in the scripts will need to be altered to reflect your file structure. The scripts create a data.frame object in R that contains all samples, after burn-in and thinning, for each of the unobserved states and model parameters. These can be summarized, for example by plotting the posterior densities: plot(density(hsealDCRW.out$gamma))