knitr::opts_chunk$set(echo = FALSE)
This is a vignette to run the plotting functions and check that outputs look ok.
Load MARSS and check that I am checking the right version.
library(MARSS) library(ggplot2) packageVersion("MARSS")
# Little harder model dat <- t(harborSealWA) dat <- dat[2:4, ] # remove the year row Qvals <- list("unconstrained", "diagonal and equal", "equalvarcov", "zero")[[1]] Bvals <- c("identity", "diagonal and unequal")[1] Rvals <- list("unconstrained", "diagonal and equal", "equalvarcov", "zero")[[2]] plottypes <- eval(formals(MARSS:::autoplot.marssMLE)$plot.type) plottypes <- plottypes[!(plottypes %in% c("residuals", "all"))] for (Q in Qvals) { for (B in Bvals) { for (R in Rvals) { if (B == "diagonal and unequal" && (is.list(Q) || is.list(R))) next mod <- list(Q = Q, Z = "identity", R = R, B = B, U = "zero", x0 = dat[, 1, drop = FALSE] * 1.1) if (B != "identity" && R != "zero") mod$tinitx <- 1 if (Q == "zero" && R == "zero") next if (Q == "zero" && B != "identity") next kemfit1 <- MARSS(dat, model = mod, silent = TRUE) }}}
for(cstan in c("Cholesky", "marginal", "Block.Cholesky")){ for(type in c("tt1", "tT", "tt")){ resids <- residuals(kemfit1, type=type, standardization=cstan) for(plt in c("all")){ plot(resids, plot.type=plt, silent=TRUE) autoplot(resids, plot.type=plt, silent=TRUE) } } }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.