Supplement 1. The code and sample data for state–space analysis of Argos movement data. D. JonsenIan Mills FlemmingJoanna A. MyersRansom 2016 <h2>File List</h2><table> <tbody><tr> <td>Files for running analyses from the WinBUGS gui (Windows or Linux)</td> </tr> <tr> <td><a href="sfiles/DCRW.txt">DCRW.txt</a></td> <td>WinBUGS code for "DCRW" model, a first-difference correlated random walk </td> <td>2 KB</td> </tr> <tr> <td><a href="sfiles/DCRWS.txt">DCRWS.txt</a></td> <td>WinBUGS code for "DCRWS" model, a first-difference CRW with switching</td> <td>2 KB</td> </tr> <tr> <td><a href="sfiles/hsdata.txt">hsdata.txt</a></td> <td>Hooded seal movement data</td> <td>12 KB</td> </tr> <tr> <td><a href="sfiles/hsDCRWinits.txt">hsDCRWinits.txt</a></td> <td>Hooded seal initial values for DCRW model</td> <td>3 KB</td> </tr> <tr> <td><a href="sfiles/hsDCRWSinits.txt">hsDCRWSinits.txt</a></td> <td>Hooded seal initial values for DCRWS model</td> <td>5 KB</td> </tr> <tr> <td><a href="sfiles/gs617data.txt">gs617data.txt</a></td> <td>Grey seal 617 movement data</td> <td>59 KB</td> </tr> <tr> <td><a href="sfiles/gs617DCRWinits.txt">gs617DCRWinits.txt</a></td> <td>Grey seal 617 initial values for DCRW model</td> <td>3 KB</td> </tr> <tr> <td><a href="sfiles/gs617DCRWSinits.txt">gs617DCRWSinits.txt</a></td> <td>Grey seal 617 initial values for DCRWS model</td> <td>4 KB</td> </tr> <tr> <td><a href="sfiles/gs2986data.txt">gs2986data.txt</a></td> <td>Grey seal 2986 movement data</td> <td>71 KB</td> </tr> <tr> <td><a href="sfiles/gs2986DCRWinits.txt">gs2986DCRWinits.txt</a></td> <td>Grey seal 2986 initial values for DCRW model</td> <td>3 KB</td> </tr> <tr> <td><a href="sfiles/gs2986DCRWSinits.txt">gs2986DCRWSinits.txt</a></td> <td>Grey seal 2986 initial values for DCRWS model</td> <td>5 KB</td> </tr> <tr> <td></td> </tr> <tr> <td>Files for running analyses by calling WinBUGS from within R (Linux)</td> </tr> <tr> <td><a href="sfiles/DCRW.rbugs.R">DCRW.rbugs.R</a> </td> <td>R script for fitting DCRW model to hooded seal data </td> <td>1 KB</td> </tr> <tr> <td><a href="sfiles/DCRWS.rbugs.R">DCRWS.rbugs.R</a> </td> <td>R script for fitting DCRWS model to hooded seal data</td> <td>1 KB</td> </tr> <tr> <td><a href="sfiles/dat4bugs.R">dat4bugs.R</a></td> <td>R code required by DCRW.rbugs.R and DCRW.rbugs.R</td> <td>4 KB</td> </tr> <tr> <td><a href="sfiles/hseal.dat">hseal.dat</a> </td> <td>Hooded seal data for analysis from within R (Linux) </td> <td>6 KB</td> </tr> <tr> <td><a href="sfiles/gs617.dat">gs617.dat</a> </td> <td>Grey seal 617 data for analysis from within R (Linux) </td> <td>27 KB</td> </tr> <tr> <td><a href="sfiles/gs2986.dat">gs2986.dat</a> </td> <td>Grey seal 2986 data for analysis from within R (Linux) </td> <td>35 KB</td> </tr> <tr> <td></td> </tr> <tr> <td><a href="sfiles/allfiles.zip">allfiles.zip</a></td> <td>All files together</td> <td>48 KB</td> </tr> </tbody></table> <p> </p><h2>Description</h2><p>WinBUGS version 1.4.1 was used to run the code and is freely available at <a href="http://www.mrc-bsu.cam.ac.uk/bugs/winbugs/contents.shtml">http://www.mrc-bsu.cam.ac.uk/bugs/winbugs/contents.shtml</a>. 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 <a href="http://www.r-project.org/">R</a>, a freely available statistical computing environment, using the R2WinBUGS package (see <a href="http://www.stat.columbia.edu/%7Egelman/bugsR/">http://www.stat.columbia.edu/~gelman/bugsR/</a> for details). </p> <p>In Linux, WinBUGS can be run via Wine (available at <a href="http://www.winehq.com/">http://www.winehq.com/</a>). 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 <a href="http://www.r-project.org">http://www.r-project.org</a>). We provide sample R scripts and associated R code (in <a href="#anchorFilelist">File list</a>) 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 <a href="http://www.r-project.org/">http://www.r-project.org</a>). The following commands in R will fit the DCRW model to the hooded seal data:</p> <p>source('~/pathtofile/dat4bugs.R')</p> <p>hseal.dat <- read.csv('~/pathtofile/hseal.dat')</p> <p>source('~/pathtofile/DCRW.rbugs.R')</p> 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: <p>plot(density(hsealDCRW.out$gamma))</p>