gather_sims: Extract parameter simulations from the joint precision matrix

View source: R/gather-spread.R

spread_simsR Documentation

Extract parameter simulations from the joint precision matrix

Description

spread_sims() returns a wide-format data frame. gather_sims() returns a long-format data frame. The format matches the format in the tidybayes spread_draws() and gather_draws() functions.

Usage

spread_sims(object, nsim = 200, n_sims = deprecated())

gather_sims(object, nsim = 200, n_sims = deprecated())

Arguments

object

Output from sdmTMB().

nsim

The number of simulation draws.

n_sims

Deprecated: please use nsim.

Value

A data frame. gather_sims() returns a long-format data frame:

  • .iteration: the sample ID

  • .variable: the parameter name

  • .value: the parameter sample value

spread_sims() returns a wide-format data frame:

  • .iteration: the sample ID

  • columns for each parameter with a sample per row

Examples

m <- sdmTMB(density ~ depth_scaled,
  data = pcod_2011, mesh = pcod_mesh_2011, family = tweedie())
head(spread_sims(m, nsim = 10))
head(gather_sims(m, nsim = 10))
samps <- gather_sims(m, nsim = 1000)

if (require("ggplot2", quietly = TRUE)) {
  ggplot(samps, aes(.value)) + geom_histogram() +
    facet_wrap(~.variable, scales = "free_x")
}

pbs-assess/sdmTMB documentation built on April 27, 2024, 2:05 p.m.