writeBugsModel {glmmBUGS}R Documentation

Write a bugs model file for a Generalised Linear Mixed Model

Description

Given a list of effect groups, and the covariates associated with each level, a bugs model file is written using ragged arrays corresponding to output from winBugsRaggedArray

Usage

writeBugsModel(file, effects, covariates, observations, 
family = c("bernoulli", "binomial", "poisson", "normal", "other"), spatial = NULL, 
prefix = "",reparam=NULL, brugs=FALSE, priors=NULL)

Arguments

file a character string denoting the name of the bugs model file writen.
effects vector of effect groups
covariates A list with names corresponding to effects and each element being a vector of covariates applicable at that level
observations A character string giving the column of observations, or a vector where the first element is the observations and the remaning are offsets.
family Response distribution
spatial name of the spatial random effect
prefix the prefix
reparam vector of random effect names, subtract covariates at this level from the intercept.
brugs make the model file compatible with BRugs by using the inprod function in place of inprod2
priors character string of prior distributions, with the name of each element referring to the parameter it is the prior for

Details

The arguments to the function specify a generalised linear mixed model. A file containing code for a corresponding bugs model is written. The model uses ragged arrays to specify grouping factors, and includes covariates at the appropriate levels to aid in chain convergence. It is intended that the user will edit this file before it's use. The prior distributions in particular may not be appropriate.

Value

A file, suitable for passing to the bugs function in R2WinBUGS.

Warning

You are strongly encouraged to modify the model file prior to using it.

Author(s)

Patrick Brown, patrick.brown@utoronto.ca

References

"Handling unbalanced datasets" in the "Tricks: Advanced Use of the BUGS Language" section of the bugs manual, at http://mathstat.helsinki.fi/openbugs/data/Docu/Tricks.html

Examples

writeBugsModel("model.bug", effects="Strip",  observations="conc",
  covariates=list(observations="length"),
  family="normal", priors=c(intercept="dunif(-10,10)") ) 

[Package glmmBUGS version 1.6.4 Index]