13.7 Uncertainty intervals on states
We will look at the effect of missing data on the uncertainty intervals on estimates states using a DFA on the harbor seal dataset.
data(harborSealWA, package = "MARSS")
# the first column is year
matplot(harborSealWA[, 1], harborSealWA[, -1], type = "l", ylab = "Log abundance",
xlab = "")
Assume they are all observing a single trend.
<- bayesdfa::fit_dfa(y = t(harborSealWA[, -1]), num_trends = 1,
seal.mod chains = 1, iter = 1000)
<- rstan::extract(seal.mod$model) pars
<- c(apply(pars$x, c(2, 3), mean))
pred_mean <- c(apply(pars$x, c(2, 3), quantile, 0.025))
pred_lo <- c(apply(pars$x, c(2, 3), quantile, 0.975))
pred_hi
plot(pred_mean, type = "l", lwd = 3, ylim = range(c(pred_mean,
main = "Trend")
pred_lo, pred_hi)), lines(pred_lo)
lines(pred_hi)