theta_mcmc: Posterior samples of derived sample-level occurence...

Description Usage Arguments Details Value Examples

View source: R/theta_mcmc.R

Description

This function converts posterior samples from sample-level regression coefficients into posterior samples from the derived sample-level occurence probability using the logit link function. If theta was sampled directly using a beta-binomial sampler, if restructures these samples into an appropriate format.

Usage

1

Arguments

msocc_mod

output from msocc_mod

Details

This function returns one column for each replicate and arranges the columns by site, sample, and replicate.

Value

an object of class matrix of dimension num.mcmc by sum(K) of posterior samples of theta

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)

# fit intercept model at all three levels use beta-binomial sampler
fung_mod1 <- msocc_mod(wide_data = fung.detect, progress = T,
                       site = list(model = ~ 1, cov_tbl = site.df),
                       sample = list(model = ~ 1, cov_tbl = sample.df),
                       rep = list(model = ~ 1, cov_tbl = sample.df), # covariates aggregated at sample level
                       num.mcmc = 1000, beta_bin = T)

theta_mcmc(fung_mod1)

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