Learn R Programming

marked (version 1.2.8)

mixed.model.admb: Mixed effect model contstruction

Description

Functions that develop structures needed for a mixed effect model

Usage

mixed.model.admb(formula,data)

mixed.model(formula,data,indices=FALSE)

mixed.model.dat(x,con,idonly,n)

reindex(x,id)

Value

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.

Arguments

formula

formula for mixed effect mode in the form used in lme4; ~fixed +(re1|g1) +...+(ren|gn)

data

dataframe used to construct the design matrices from the formula

x

list structure created by mixed.model.admb

con

connection to data file which contents will be appended

id

vector of factor values used to split the data up by individual capture history

idonly

TRUE, if random effects not crossed

n

number of capture history records

indices

if TRUE, outputs structure with indices into dm for random effects

Author

Jeff Laake

Details

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.