Functions that develop structures needed for a mixed effect model
mixed.model.admb(formula,data) mixed.model(formula,data,indices=FALSE)
mixed.model.dat(x,con,idonly,n)
reindex(x,id)
mixed.model.admb returns a list with elements re.dm, a combined design matrix for all of the random effects; and re.indices, matrix of indices into a single vector of random effects to be applied to the design matrix location. mixed.model returns a list (re.list) with an element for each random effect structure. The contents are a standard design matrix (re.dm) if indices==FALSE and a re.dm and re.indices which matches the structure of mixed.model.admb. mixed.model will be more useful with R than ADMB.
formula for mixed effect mode in the form used in lme4; ~fixed +(re1|g1) +...+(ren|gn)
dataframe used to construct the design matrices from the formula
list structure created by mixed.model.admb
connection to data file which contents will be appended
vector of factor values used to split the data up by individual capture history
TRUE, if random effects not crossed
number of capture history records
if TRUE, outputs structure with indices into dm for random effects
Jeff Laake
mixed.model.admb - creates design matrices and supporting index matrices for use of mixed model in ADMB
mixed.model - creates design matrices and supporting index matrices in an alternate list format that is not as easily used in ADMB
mixed.model.dat - writes to data file (con) for fixed and random effect stuctures
reindex - creates indices for random effects that are specific to the individual capture history; it takes re.indices, splits them by id and creates a ragged array by id (used.indices) with the unique values for that id. index.counts is the number of indices per id to read in ragged array. It then changes re.indices to be an index to the indices within the id from 1 to the number of indices within the id.