Fit Bayesian bivariate normal distributions to each group in each community

Share:

Description

This function loops over each community and then loops over each group member, fitting a Bayesian multivariate (bivariate in this case) normal distribution to each group of data. Not intended for direct calling by users.

Usage

1
siberMVN(siber, parms, priors)

Arguments

siber

a siber object as created by createSiberObject

parms

a list containing four items providing details of the rjags run to be sampled.

  • n.iterThe number of iterations to sample

  • n.burninThe number of iterations to discard as a burnin from the start of sampling.

  • n.thinThe number of samples to thin by.

  • n.chainsThe number of chains to fit.

priors

a list of three items specifying the priors to be passed to the jags model.

  • RThe scaling vector for the diagonal of Inverse Wishart distribution prior on the covariance matrix Sigma. Typically set to a 2x2 matrix matrix(c(1, 0, 0, 1), 2, 2).

  • kThe degrees of freedom of the Inverse Wishart distribution for the covariance matrix Sigma. Typically set to the dimensionality of Sigma, which in this bivariate case is 2.

  • tauThe precision on the normal prior on the means mu.

Value

A list of length equal to the total number of groups in all communities. Each entry is named 1.1 1.2... 2.1.. with the first number designating the community, and the second number the group within that community. So, 2.3 would be the third group within the second community. Each list entry is a 6 x n matrix representing the back-transformed posterior distributions of the bivariate normal distribution, where n is the number of posterior draws in the saved sample. The first two columns are the back- transformed means, and the remaining four columns are the covariance matrix Sigma in vector format. This vector converts to the covariance matrix as matrix(v[1:4], nrow = 2, ncol = 2).

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.