gibbsSampler: A blocked Gibbs sampler.

Description Usage Arguments Value Author(s) References Examples

Description

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

Usage

1
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

1
2
3
4
5
6
7
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)

Example output

Loading required package: igraph

Attaching package: 'igraph'

The following objects are masked from 'package:stats':

    decompose, spectrum

The following object is masked from 'package:base':

    union

bayesloglin documentation built on May 1, 2019, 9:45 p.m.