writeBugsModel: 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
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
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.
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.
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#HandlingUnbalancedDatasets