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

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

Arguments

object

An object inheriting class unmarkedRanef or unmarkedFit

nsims

Number of draws to make from the posterior predictive distribution

...

Other arguments

Value

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

Author

Ken Kellner contact@kenkellner.com

See also

Examples

# 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))
#> Mean Mode 2.5% 97.5% #> [1,] 5.456813 5 4 8 #> [2,] 12.263316 12 10 15 #> [3,] 11.974866 12 10 15 #> [4,] 12.512518 12 10 15 #> [5,] 7.515203 7 6 10 #> [6,] 6.910344 7 5 9 #> [7,] 11.772003 12 10 14 #> [8,] 11.590102 11 9 14 #> [9,] 11.957508 12 10 15 #> [10,] 5.239116 5 4 7 #> [11,] 12.811799 13 10 16 #> [12,] 6.871755 7 5 9 #> [13,] 9.393458 9 7 12 #> [14,] 13.201976 13 11 16 #> [15,] 4.531943 4 3 7 #> [16,] 7.803122 8 6 10 #> [17,] 7.961635 8 6 10 #> [18,] 6.365969 6 5 9 #> [19,] 11.728030 12 9 14 #> [20,] 13.016582 13 11 16
#Draw from the posterior predictive distribution (ppd <- posteriorSamples(re, nsims=100))
#> Posterior samples from unmarked model #> 20 sites x 1 primary periods x 100 sims #> Showing first 5 sites and first 3 simulations #> To see all samples, use print() #> [,1] [,2] [,3] #> [1,] 8 4 4 #> [2,] 12 10 11 #> [3,] 11 12 10 #> [4,] 15 11 11 #> [5,] 7 9 6