Chapter 7 MARSS models
This lab will show you how to fit multivariate state-space (MARSS) models using the MARSS package. This class of time-series model is also called vector autoregressive state-space (VARSS) models. This chapter works through an example which uses model selection to test different population structures in west coast harbor seals. See for a fuller version of this example.
A script with all the R code in the chapter can be downloaded here. The Rmd for this chapter can be downloaded here
Data and packages
All the data used in the chapter are in the MARSS package. For most examples, we will use the MARSS()
function to fit models via maximum-likelihood. We also show how to fit a Bayesian model using JAGS and Stan. For these sectiosn you will need the R2jags, coda and rstan packages. To run the JAGS code, you will also need JAGS installed. See Chapter 12 for more details on JAGS and Chapter 13 for more details on Stan.
library(MARSS)
library(R2jags)
library(coda)
library(rstan)