50% off | Unlimited Data & AI Learning

Last chance! 50% off unlimited learning

Sale ends in


LMMstar (version 1.1.0)

ranef.lmm: Estimate Random Effect From a Linear Mixed Model

Description

Recover the random effects from the variance-covariance parameter of a linear mixed model.

Usage

# S3 method for lmm
ranef(
  object,
  effects = "mean",
  scale = "absolute",
  se = FALSE,
  df = NULL,
  transform = (effects %in% c("std", "variance")),
  p = NULL,
  newdata = NULL,
  format = "long",
  simplify = TRUE,
  ...
)

Value

A data.frame or a list depending on the argument format.

Arguments

object

a lmm object.

effects

[character] should the estimated random effects ("mean") or the estimated variance/standard deviation of the random effects ("variance","std") be output?

scale

[character] should the total variance, variance relative to each random effect, and residual variance be output ("absolute"). Or the ratio of these variances relative to the total variance ("relative").

se

[logical] should standard error and confidence intervals be evaluated using a delta method? Will slow down the execution of the function.

df

[logical] Should degrees of freedom, computed using Satterthwaite approximation, be output.

transform

[logical] should confidence intervals for the variance estimates (resp. relative variance estimates) be evaluated using a log-transform (resp. atanh transformation)?

p

[numeric vector] value of the model coefficients to be used. Only relevant if differs from the fitted values.

newdata

[data.frame] dataset relative to which the random effects should be computed. Only relevant if differs from the dataset used to fit the model.

format

[character] should each type of random effect be output in a data.frame (format="long")

simplify

[logical] when relevant will convert list with a single element to vectors and omit unessential output.

...

for internal use.

Details

Consider the following mixed model: Y=Xβ+ϵ=Xβ+Zη+ξ where the variance of ϵ is denoted Ω, the variance of η is denoted Ωη, and the variance of ξ is σ2I with I is the identity matrix.
The random effets are estimating according to: E[Y|η]=ΩηZtΩ1(YXβ)

Examples

Run this code
if(require(nlme)){
data(gastricbypassL, package = "LMMstar")

## random intercept
e.RI <- lmm(weight ~ time + (1|id), data = gastricbypassL)
ranef(e.RI, effects = "mean")
ranef(e.RI, effects = "mean", se = TRUE)

ranef(e.RI, effects = "variance")
ranef(e.RI, effects = "variance", format = "wide")

}

Run the code above in your browser using DataLab