winBugsRaggedArray: Ragged Arrays for multilevel models in BUGS

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Suitable for unbalanced data.

Usage

1
2
3
4
winBugsRaggedArray(data, effects = names(data)[-length(names(data))], 
covariates = NULL, observations = names(data)[length(names(data))], 
returnData = FALSE,
prefix=NULL, reparam=FALSE)

Arguments

data

A data frame containing the response, covariates, and group membership.

effects

A vector of character strings containing the grouping levels, from most general to most specific. Defaults to the column names of data, excluding the last column.

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.

returnData

If true, returns the re-ordered data frame as well as the data frame

prefix

Character string to be appended to variable names

reparam

Vector of effect names, reparametrize the intercept by subtracting the mean of covariates at this level.

Details

This funciton creates a list of data suitable for passing to the bugs function, suitable for implimentation as a ragged array. The output can be passed to getStartingValues to manipulate the output from glmmPQLstrings, and to restoreParams to restore the original parametrisation from bugs output.

Value

A list with the following components

Nxx

The number of levels in the most general groupping

Syy

Indexing sequences, one for each level. If yy is level n, level n+1 has elements Syy[1] to Syy[2]-1 belonging to the first category of level n.

Xyy

Matrix or vector of covariates belonging to level yy

vector of observations.

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://www.openbugs.net/Manuals/Tricks.html

See Also

bugs

Examples

1
2
3
4
5
library(nlme)
data(Muscle)
muscleRagged = winBugsRaggedArray(Muscle, effects="Strip",  
observations="conc",
  covariates=list(observations="length"))

glmmBUGS documentation built on May 2, 2019, 6:08 p.m.