posterior_summary: Summarize posterior samples

Description Usage Arguments Value Examples

View source: R/posterior_summary.R

Description

This function allows for easy summaries of the posterior samples drawn by msocc_mod.

Usage

1
2
3
4
5
6
7
8
posterior_summary(
  msocc_mod,
  burnin = 0,
  print = F,
  level = "overall",
  quantiles = c(0.025, 0.975),
  unique = T
)

Arguments

msocc_mod

output from msocc_mod (object of class msocc)

burnin

number of samples to discard as burnin when summarizing the posterior

print

should summaries be printed in the console?

level

one of c('overall', 'site', 'sample', 'rep'); which level of the design should be summarized?

quantiles

vector of quantiles for credibility intervals

unique

should only unique rows be printed?

n

number of rows to print in the console for the posterior summary

Value

object of class data.frame providing summaries of the posterior organized by site, sample, and replicate.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
data(fung)

# prep data
fung.detect <- fung %>%
  dplyr::select(1:4)

site.df <- fung %>%
  dplyr::select(-sample, -pcr1, -pcr2) %>%
  dplyr::distinct(site, .keep_all = TRUE) %>%
  dplyr::arrange(site)

sample.df <- fung %>%
  dplyr::select(-pcr1, -pcr2) %>%
  dplyr::arrange(site, sample)

# model sample level occurence by frog density
fung_mod2 <- msocc_mod(wide_data = fung.detect, progress = T,
                       site = list(model = ~ 1, cov_tbl = site.df),
                       sample = list(model = ~ frogs, cov_tbl = sample.df),
                       rep = list(model = ~ 1, cov_tbl = sample.df),
                       num.mcmc = 1000, beta_bin = T)

# overall summary
posterior_summary(fung_mod2)

# site level
posterior_summary(fung_mod2, level = 'site')

# sample level
posterior_summary(fung_mod2, level = 'sample')

# rep level
posterior_summary(fung_mod2, level = 'rep')

StrattonCh/msocc documentation built on Dec. 22, 2020, 2:51 a.m.