hUM.post: Posterior sampling from a hierarchical...

Description Usage Arguments Details Value Examples

Description

MCMC sampling from a Dirichlet-Multinomial model using stan.

Usage

1
hUM.post(nsamples, X, popId, rhoId, full.stan.out = FALSE, ...)

Arguments

nsamples

Number of posterior samples

X

4-column or 5-column matrix of observations in the correct format. See UM.suff.

popId

Optional vector of population identifiers. See UM.suff.

rhoId

Populations for which posterior samples of the genotype probability vector rho are desired. Defaults to all populations. Set rhoId = NULL not to output these for any populations.

full.stan.out

Logical. Whether or not to return the full stan output. For monitoring convergence of the MCMC sampling.

...

Further arguments to be passed to the sampling function in rstan.

Details

The hierarchical Dirichlet-Multinomial model is given by

Y_k | ρ_k ~ind Multinomial(ρ_k, N_k),

ρ_k ~iid Dirichlet(α).

where α_0 = ∑_{i=1}^C α_i and α_bar = α/α_0. MCMC sampling is achieved with the rstan package, which is listed as a dependency for MADPop so as to expose rstan's sophisticated tuning mechanism and convergence diagnostics.

Value

A list with elements

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# fit hierarchical model to fish215 data

# only output posterior samples for lake Simcoe
rhoId <- "Simcoe"
nsamples <- 500
hUM.fit <- hUM.post(nsamples = nsamples, X = fish215,
                    rhoId = rhoId,
                    chains = 1) # number of MCMC chains

# plot first 20 posterior probabilities in lake Simcoe
rho.post <- hUM.fit$rho[,1,]
boxplot(rho.post[,1:20], las = 2,
        xlab = "Genotype", ylab = "Posterior Probability",
        pch = ".", col = "grey")

MADPop documentation built on May 1, 2019, 6:47 p.m.