mm: Mixed Models with covariance relationship matrices

Description Usage Arguments Details Value References Examples

View source: R/mm.R

Description

Fit (Generalized) Linear Mixed Models with user defined 'G-site' covariance relationship matrices. Derifed from pedigreemm.

Usage

1
2
3
mm(formula, data, family = NULL, REML = TRUE, covarrel = list(),
  control = list(), start = NULL, verbose = FALSE, subset, weights,
  na.action, offset, contrasts = NULL, devFunOnly = FALSE, ...)

Arguments

formula

a two-sided linear formula object describing both the fixed-effects and random-effects part of the model, with the response on the left of a ~ operator and the terms, separated by + operators, on the right. Random-effects terms are distinguished by vertical bars (|) separating expressions for design matrices from grouping factors. Two vertical bars (||) can be used to specify multiple uncorrelated random effects for the same grouping variable. (Because of the way it is implemented, the ||-syntax works only for design matrices containing numeric (continuous) predictors; to fit models with independent categorical effects, see dummy or the lmer_alt function from the afex package.)

data

an optional data frame containing the variables named in formula. By default the variables are taken from the environment from which lmer is called. While data is optional, the package authors strongly recommend its use, especially when later applying methods such as update and drop1 to the fitted model (such methods are not guaranteed to work properly if data is omitted). If data is omitted, variables will be taken from the environment of formula (if specified as a formula) or from the parent frame (if specified as a character vector).

family

a GLM family, see glm and family.

REML

logical scalar - Should the estimates be chosen to optimize the REML criterion (as opposed to the log-likelihood)?

covarrel

a named list of relationship matrices. The names must correspond to the names of grouping factors for random-effects terms in the formula argument.

control

a list (of correct class, resulting from lmerControl() or glmerControl() respectively) containing control parameters, including the nonlinear optimizer to be used and parameters to be passed through to the nonlinear optimizer, see the *lmerControl documentation for details.

start

a named list of starting values for the parameters in the model. For lmer this can be a numeric vector or a list with one component named "theta".

verbose

integer scalar. If > 0 verbose output is generated during the optimization of the parameter estimates. If > 1 verbose output is generated during the individual PIRLS steps.

subset

an optional expression indicating the subset of the rows of data that should be used in the fit. This can be a logical vector, or a numeric vector indicating which observation numbers are to be included, or a character vector of the row names to be included. All observations are included by default.

weights

an optional vector of ‘prior weights’ to be used in the fitting process. Should be NULL or a numeric vector. Prior weights are not normalized or standardized in any way. In particular, the diagonal of the residual covariance matrix is the squared residual standard deviation parameter sigma times the vector of inverse weights. Therefore, if the weights have relatively large magnitudes, then in order to compensate, the sigma parameter will also need to have a relatively large magnitude.

na.action

a function that indicates what should happen when the data contain NAs. The default action (na.omit, inherited from the 'factory fresh' value of getOption("na.action")) strips any observations with any missing values in any variables.

offset

this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be NULL or a numeric vector of length equal to the number of cases. One or more offset terms can be included in the formula instead or as well, and if more than one is specified their sum is used. See model.offset.

contrasts

an optional list. See the contrasts.arg of model.matrix.default.

devFunOnly

logical - return only the deviance evaluation function. Note that because the deviance function operates on variables stored in its environment, it may not return exactly the same values on subsequent calls (but the results should always be within machine tolerance).

...

other potential arguments. A method argument was used in earlier versions of the package. Its functionality has been replaced by the REML argument.

Details

All arguments to this function are the same as those to the function lmer (or in case of family glmer) except covarrel which must be a named list of relationship matrices. Each name (frequently there is only one) must correspond to the name of a grouping factor in a random-effects term in the formula. The observed levels of that factor must be contained in the column and row names of the relationship matrix. For each relationship matrix the (left) Cholesky factor of the observed levels is calculated and applied to the model matrix for that term.

Value

a pedigreemm object.

References

Vazquez, A.I., D.M. Bates, G.J.M. Rosa, D. Gianola and K.A. Weigel. (2010). Technical Note: An R package for fitting generalized linear mixed models in animal breeding. Journal of Animal Science, 88:497-504.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# modifide from pedigreemm example
# pedigree and relationship matrix
p1 <- new("pedigree",
          sire = as.integer(c(NA, NA, 1, 1, 4, 5, 1, 4, 4, 5)),
          dam  = as.integer(c(NA, NA, 2, NA, 3, 2, 3, 6, 6, 2)),
          label = as.character(1:10))
A <- pedigreemm::getA(p1)
cholA <- chol(A)
# variance componens
varU <- 2
varE <- 6
# number of observations
rep <- 20
n <- rep * 10
ID <- rep(1:10, each = rep)
# simulated random effects
set.seed(108)
bStar <- rnorm(10)
bStar <- bStar * (sqrt(varU) / sd(bStar[ID]))
b <- as.vector(crossprod(cholA, bStar))
# simulated error
e0 <- rnorm(n)
e0 <- e0 * (sqrt(varE) / sd(e0))
# simulated observations
y <- 10 + b[ID] + e0
# models
fm1 <- pedigreemm(y ~ (1 | ID) , pedigree = list(ID = p1))
fm2 <- mm(formula = y ~ (1 | ID) , covarrel = list(ID = A))

# require(coxme)
# fm3 <- lmekin(y ~ (1 | ID) , varlist = list(ID = A), method = "REML")

jrklasen/relMM documentation built on May 19, 2019, 11:53 p.m.