Learn R Programming

unmarked (version 1.4.3)

posteriorSamples: Draw samples from the posterior predictive distribution

Description

Draw samples from the empirical Bayes posterior predictive distribution derived from unmarked models or ranef objects

Usage

# S4 method for unmarkedRanef
posteriorSamples(object, nsims=100, ...)
# S4 method for unmarkedFit
posteriorSamples(object, nsims=100, ...)

Value

unmarkedPostSamples object containing the draws from the posterior predictive distribution. The draws are in the @samples slot.

Arguments

object

An object inheriting class unmarkedRanef or unmarkedFit

nsims

Number of draws to make from the posterior predictive distribution

...

Other arguments

Author

Ken Kellner contact@kenkellner.com

See Also

ranef, predict

Examples

Run this code

# Simulate data under N-mixture model
set.seed(4564)
R <- 20
J <- 5
N <- rpois(R, 10)
y <- matrix(NA, R, J)
y[] <- rbinom(R*J, N, 0.5)

# Fit model
umf <- unmarkedFramePCount(y=y)
fm <- pcount(~1 ~1, umf, K=50)

# Estimates of conditional abundance distribution at each site
(re <- ranef(fm))

#Draw from the posterior predictive distribution
(ppd <- posteriorSamples(re, nsims=100))

Run the code above in your browser using DataLab