gibbsSampler {bayesloglin}R Documentation

A blocked Gibbs sampler.

Description

Generates samples from the posterior distribution of the log-linear parameters.

Usage

gibbsSampler (formula, alpha = 1, data, nSamples = 10000, verbose = T)

Arguments

formula

A model formula.

alpha

The value of the hyperparameter alpha.

data

A data frame containing the contingency table. All cells must be included in data and the last column must be the cell counts. The number of variables in the contingency table must be at least 2.

nSamples

Number of iterations of the Gibbs sampler.

verbose

Displays current iteration number of the sampler.

Value

theta

An array where each row represents a sample from the Posterior distribution of the log-linear parameters. The first 5000 or so samples should be discarded as a burn-in period.

Author(s)

Matthew Friedlander

References

see vignette

Examples

data(czech)
formula <- freq ~ a*c + b*c + a*d + a*e + c*e + d*e + f
#s <- gibbsSampler (formula, alpha = 1, data = czech, 
#                   nSamples =  15000, verbose = TRUE)
#postMean <- colSums(s[5000:15000,]) / 10000
#postCov <- cov(s[5000:15000,])
#postVar <- diag(postCov)

[Package bayesloglin version 1.0.1 Index]