Learn R Programming

gremlin (version 0.1.0.1)

gremlinR: Mixed-effect modeling functions.

Description

Create and fit linear mixed-effect model (Gaussian data) or checking if an object is a fitted model.

Usage

gremlinR(formula, random = NULL, rcov = ~units, data = NULL,
  ginverse = NULL, Gstart = NULL, Rstart = NULL, Bp = NULL,
  maxit = 20, algit = NULL, vit = 10, v = 1, ...)

mkModMats(formula, random = NULL, rcov = ~units, data = NULL, subset = NULL, ginverse = NULL, na.action = na.pass, offset = NULL, contrasts = NULL, Xsparse = TRUE, ...)

Arguments

formula

A formula for the response variable and fixed effects.

random

A formula for the random effects.

rcov

A formula for the residual covariance structure.

data

A data.frame in which to look for the terms in formula, random, and rcov.

ginverse

A list of (preferably sparse) inverse matrices that are proportional to the covariance structure of the random effects. The name of each element in the list should match a column in data that is associated with a random term. All levels of the random term should appear as rownames for the matrices.

Gstart

A list of starting (co)variance values for the the G-structure or random terms.

Rstart

A list of starting (co)variance values for the R-structure or residual terms.

Bp

A prior specification for fixed effects.

maxit

An integer specifying the maximum number of likelihood iterations.

algit

A character vector of length 1 or more or an expression to be evaluated that specifies the algorithm to use for proposing (co)variances in the next likelihood iteration.

vit

An integer value specifying the verbosity of screen output on each iteration. A value of zero gives no iteration specific output and larger values increase the amount of information printed on the screen.

v

An integer value specifying the verbosity of screen output regarding the model fitting process. A value of zero gives no details and larger values increase the amount of information printed on the screen.

Additional arguments to be passed to control the model fitting.

subset

An expression for the subset of data to use.

na.action

What to do with NAs.

offset

Should an offset be specified.

contrasts

Specify the type of contrasts for the fixed effects.

Xsparse

Should sparse matrices be used for the fixed effects design matrix.

Value

A list of class gremlin or gremlinModMats:

call

The model call.

modMats

A list of the model matrices used to construct the mixed model equations.

y

The response vector.

ny

The number of responses.

ncy

The number of columns of the original response.

X

The fixed effects design matrix.

nb

The number of columns in X.

Zr

The residual design matrix.

Zg

A list of the design matrices for each random term.

nG

The number of parameters in the G structure.

listGeninv

A list of generalized inverse matrices.

logDetG

The log-determinants of the generalized inverse matrices - necessary to calculate the log-likelihood.

itMat

A matrix of details about each iteration.

sln

A two column matrix of solutions and their sampling variances from the mixed model.

residuals

A vector of residual deviations, response minus the values expected based on the solutions, corresponding to the order in modMats$y.

theta

A matrix of (co)variance components at the last iteration.

AI

A matrix of values containing the Average Information matrix, or second partial derivatives of the likelihood with respect to the (co)variance components. The inverse of this matrix gives the sampling variances of the (co)variance components.

dLdtheta

A single column matrix of first derivatives of the (co)variance parameters with respect to the log-Likelihood.

Functions

  • mkModMats: Generates model matrices.

References

Henderson Mrode. 2005.

Examples

Run this code
# NOT RUN {
  library(nadiv)
  Ainv <- makeAinv(Mrode3[-c(1:2), 1:3])$Ainv
  mod11 <- gremlinR(WWG11 ~ sex - 1,
  	random = ~ calf,
  	data = Mrode11,
  	ginverse = list(calf = Ainv),
  	Gstart = matrix(0.2), Rstart = matrix(0.4),
  	maxit = 10, v = 2)

  is(mod11)
# }

Run the code above in your browser using DataLab