iid.lmm: Extract the Influence Function From a Linear Mixed Model

View source: R/iid.R

iid.lmmR Documentation

Extract the Influence Function From a Linear Mixed Model

Description

Extract the influence function for an ML or REML estimator of parameters from a linear mixed model.

Usage

## S3 method for class 'lmm'
iid(
  x,
  effects = "mean",
  p = NULL,
  robust = TRUE,
  type.information = NULL,
  transform.sigma = NULL,
  transform.k = NULL,
  transform.rho = NULL,
  transform.names = TRUE,
  REML2ML = NULL,
  ...
)

Arguments

x

a lmm object.

effects

[character] Should the influence function for all coefficients be output ("all"), or only for coefficients relative to the mean ("mean" or "fixed"), or only for coefficients relative to the variance structure ("variance"), or only for coefficients relative to the correlation structure ("correlation"). Can also contain "gradient" to also output the gradient of the influence function.

p

[numeric vector] value of the model coefficients at which to evaluate the influence function. Only relevant if differs from the fitted values.

robust

[logical] If FALSE the influence function is rescaled to match the model-based standard errors. The correlation however will not (necessarily) match the model-based correlation.

type.information

[character] Should the expected information be used (i.e. minus the expected second derivative) or the observed inforamtion (i.e. minus the second derivative).

transform.sigma

[character] Transformation used on the variance coefficient for the reference level. One of "none", "log", "square", "logsquare" - see details.

transform.k

[character] Transformation used on the variance coefficients relative to the other levels. One of "none", "log", "square", "logsquare", "sd", "logsd", "var", "logvar" - see details.

transform.rho

[character] Transformation used on the correlation coefficients. One of "none", "atanh", "cov" - see details.

transform.names

[logical] Should the name of the coefficients be updated to reflect the transformation that has been used?

...

Not used. For compatibility with the generic method.

Details

The influence function equals the individual score rescaled by the (inverse) information. With the expected information and for a lmm fitted using ML, the information is block diagonal so the influence function for the mean and variance parameters can be computed separately. Otherwise the information and individual score relative to all model parameters should be considered. The later is probablematic when using REML as the REML term is the ratio of two term linear in the individual contributions which is not itself linear in the individual contributions. As an add-hoc solution, the denominator is treated as fixed so the ratio is decomposed w.r.t. its numerator.

Value

A matrix with one row per observation and one column per parameter.

  • df=TRUE: with an attribute "df" containing a numeric vector with one element per parameter.

  • effects includes "gradient": with an attribute "gradient" containing a 3 dimensional array with dimension the number of parameters.

Examples

data(gastricbypassL)

#### Case WITHOUT cross terms ####
e.lmmREML <- lmm(weight ~ visit, method.fit = "REML", df = FALSE,
                 repetition = ~ visit|id, data = gastricbypassL)
e.lmmML <- lmm(weight ~ visit, method.fit = "ML", df = FALSE,
              repetition = ~ visit|id, data = gastricbypassL)

name.mu <- names(coef(e.lmmREML, effects = "mean"))
name.sigmakrho <- names(coef(e.lmmREML, effects = c("variance","correlation")))
info.REML <- information(e.lmmREML, effects = "all", transform.names = FALSE)
info.ML <- information(e.lmmML, effects = "all", transform.names = FALSE)
info.REML2ML <- information(e.lmmML, p = coef(e.lmmREML, effects = "all"),
                            effects = "all", transform.names = FALSE)

range(info.REML[name.mu,name.sigmakrho])
range(info.ML[name.mu,name.sigmakrho])
range(info.REML[name.mu,]-info.REML2ML[name.mu,])
range(iid(e.lmmREML, REML2ML = TRUE) - iid(e.lmmREML, REML2ML = FALSE))
## neglectable differences

#### Case WITH cross terms ####
e2.lmmREML <- lmm(glucagonAUC ~ visit + weight, method.fit = "REML", df = FALSE,
                 repetition = ~ visit|id, data = gastricbypassL)
e2.lmmML <- lmm(glucagonAUC ~ visit + weight, method.fit = "ML", df = FALSE,
              repetition = ~ visit|id, data = gastricbypassL)

name2.mu <- names(coef(e2.lmmREML, effects = "mean"))
name2.sigmakrho <- names(coef(e2.lmmREML, effects = c("variance","correlation")))
info2.REML <- information(e2.lmmREML, effects = "all", transform.names = FALSE)
info2.ML <- information(e2.lmmML, effects = "all", transform.names = FALSE)
info2.REML2ML <- information(e2.lmmML, p = coef(e2.lmmREML, effects = "all"),
                            effects = "all", transform.names = FALSE)

range(info2.REML[name.mu,]-info2.REML2ML[name.mu,])
## neglectable difference
range(info2.REML[name.mu,name.sigmakrho])
range(info2.ML[name.mu,name.sigmakrho])
range(iid(e2.lmmREML, REML2ML = TRUE) - iid(e2.lmmREML, REML2ML = FALSE))
## non-neglectable differences
diag(crossprod(iid(e2.lmmREML, REML2ML = TRUE)))/diag(vcov(e2.lmmREML))
diag(crossprod(iid(e2.lmmREML, REML2ML = FALSE)))/diag(vcov(e2.lmmREML))

bozenne/repeated documentation built on July 16, 2025, 11:16 p.m.