hUM.post {MADPop} | R Documentation |
Posterior sampling from a hierarchical Unconstrained-Multinomial model
Description
MCMC sampling from a Dirichlet-Multinomial model using stan
.
Usage
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 |
popId |
Optional vector of population identifiers. See |
rhoId |
Populations for which posterior samples of the genotype probability vector |
full.stan.out |
Logical. Whether or not to return the full |
... |
Further arguments to be passed to the |
Details
The hierarchical Dirichlet-Multinomial model is given by
Y_k \mid \rho_k \sim_{\textrm{ind}} \textrm{Multinomial}(\rho_k, N_k),
\rho_k \sim_{\textrm{iid}} \textrm{Dirichlet}(\alpha).
where \alpha_0 = \sum_{i=1}^C \alpha_i
and \bar \alpha = \alpha/\alpha_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
-
A
: The unique allele names. -
G
: The 4-column matrix Package libcurl was not found in the pkg-config search path.of unique genotype combinations. -
rho
: A matrix withncol(rho) == nrow(G)
, where each row is a draw from the posterior distribution of inheritance probabilities. -
sfit
: Iffull.stan.out = TRUE
, the fittedstan
object.
Examples
# 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")