Description Motivation Modularization
lme4ord
: Generalized Linear Mixed Models with Flexible
(Co)Variance Structures
The lme4ord
package was written to solve applied problems
in biology and ecology, but should be more general than that. The
original goal of lme4ord
is to provide a flexible platform
and API, for using the computational machinery from the
lme4
package to fit generalized linear mixed models to
ecological community data. Models for community data typically
require more flexibility than the standard lme4
interface
can provide, despite the fact that lme4
can usually be
hacked to fit such models. lme4ord
was developed to avoid
such hacking by providing infrastructure for specifying a wide
range of models. For example, lme4ord
is able to fit the
following types of models:
Factor analytic and structural equation latent variable
models (factAnal
)
Models with phylogenetic correlations
(phyloEdge
)
Models with spatial correlations (expDecay
)
Any corStruct
model from the nlme
package (nlmeCorStruct
)
Despite this origin in community ecology, lme4ord
is more
broadly useful for fitting a very wide variety of structured
generlized linear mixed models.
The design of lme4ord
is intended to facilitate use by
people with a range of skill levels and interests. In order to
achieve this goal, lme4ord
is composed of several modules
(illustrated in the figure below). Those who choose to interact
with all modules will benefit from maximum flexibility, whereas
more simple uses may require only a few modules.
Arrows point from modules that make use of functions from the module to which they point.
The model fitting module consists of a
single function, strucGlmer
. This function calls the
next four modules in the order given.
The formula parsing module takes a mixed
model formula and data, and returns a set of objects required to
fit the specified model. This module may be accessed directly via
the strucParseFormula
function. In addition to
standard lme4
-style random effects terms, mixed model
formulas may consist of special reTrmStruct
object
constructed using the random-effects structures module described
below. The findReTrmClasses
function may be used to
list all such special structures that are available. Also see:
splitForm
;
simulate.strucParseFormula
.
This module is what links a
strucParseFormula
object with the underlying
C++
machinery of lme4
. The function
mkGeneralGlmerDevfun
may be used to construct a
function that uses C++
code to compute the deviance (minus
twice the log-likelihood) for a given set of parameters. Also see
mkPenaltyFun
.
Currently lme4ord
uses the
bobyqa
function in the minqa
package to
optimize deviance functions.
There are a variety of methods and extractor
functions for exploring fitted models of
strucGlmer-class
. These objects are constructed by
strucGlmer
, which calls
mkStrucGlmer
. There are many methods for
strucGlmer-class
objects including
print.strucGlmer
; summary
;
pars.strucGlmer
; fixef.strucGlmer
;
covar.strucGlmer
; loads.strucGlmer
;
ranef.strucGlmer
; nobs.strucGlmer
;
residuals.strucGlmer
;
fitted.strucGlmer
; vcov.strucGlmer
;
VarCorr.strucGlmer
; isREML.strucGlmer
;
df.residual.strucGlmer
;
deviance.strucGlmer
;
logLik.strucGlmer
; formula.strucGlmer
;
family.strucGlmer
; weights.strucGlmer
;
model.matrix.strucGlmer
;
simulate.strucGlmer
. Also see:
getStrucGlmerPar
; parPerTerm
;
covarPerTerm
; loadsPerTerm
;
nRePerTrm
; reIndsPerTrm
;
getOffset
; simStrucParsedForm
;
printReTrm
; getReTrm
;
compressStrucGlmer
.
One may specify new special
random effects structures by defining new methods for the
setReTrm
generic. To get started constructing such
methods see showSkeleton("setReTrm")
. The
findReTrmClasses
function may be used to list all
methods that are currently available. Also see:
mkReTrmStructs
; getModMatAndGrpFac
;
packReTrm
; update.reTrmStruct
;
setLowerDefault
; simReTrm
;
mkSparseTrans
.
Many contemporary mixed models
and latent variable models involve large matrices, which at each
iteration of an optimization algorithm need to (1) have their
values updated and (2) be involved in matrix algebra. Fortunately
these large matrices have structure that can be exploited for
developing better fitting algorithms. The first type of structure
is that these matrices are constructed by applying a small number
of simple operations on relatively small building-block
matrices. This basis in build-block matrices makes it simpler to
update mixed model matrices. The second type of structure is that
these mixed model matrices are often sparse, in that they contain
a relatively large number of zeros. This sparsity allows for more
efficient matrix operations involved in the fitting
proceedure. There is quite alot of machinery in the Matrix
package for exploiting sparsity. There is less machinery for
exploiting the building-block structure of mixed-model
matrices. The strucMatrix
objects in the
lme4ord
package provide such machinery.
A utility is a function that does _not_ make use
of functions from any other module. The purpose of separating
utilities in this way is to preserve modularity. Currently, the list of
utilities is: mkParInds
; getInit
;
getInit
; factors
,
stanCov
; nChoose2Inv
;
familySimFun
; triInds
;
countUnique
; flattenIntVec
;
assignWith
; showSkeleton
;
listTranspose
; denseDiagInds
;
edgeTipIndicator
; covExpDecay
;
orthProcrustesRotMat
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.