model.frame.lmm: Extracting the Model Frame from a Linear Mixed Model

View source: R/model.frame.R

model.frame.lmmR Documentation

Extracting the Model Frame from a Linear Mixed Model

Description

Contruct a data frame containing all the variables involved in a Linear Mixed Model.

Usage

## S3 method for class 'lmm'
model.frame(
  formula,
  newdata = NULL,
  type = NULL,
  add.index = FALSE,
  na.rm = TRUE,
  ...
)

Arguments

formula

a lmm object.

newdata

[data.frame] dataset relative to which the model frame should be constructed.

type

[character] by default returns the processed dataset used to fit the Linear Mixed Model (NULL). Can be used to add rows relative to missing repetitions ("add.NA") or obtain a dataset with unique sets of covariates ("unique") with respect to the mean structure.

add.index

[logical] should columns indexing the row number from the original dataset, time variable, cluster variable, strata variable be added to the output?

na.rm

[logical] should rows containing missing values for the variables used in the linear mixed model be removed? Not relevant when argument type is "unique".

...

not used. For compatibility with the generic method.

Details

Column "XXindexXX" refers to the row of the original dataset (i.e. passed to argument data when calling lmm). When adding rows relative to missing repetitions, since there is no row in the original dataset, a negative sign is used.

Examples

data("armd.wide", package = "nlmeU")
e.lmH <- lmm(visual52 ~ lesion, structure = IND(~treat.f), data = armd.wide)
model.frame(e.lmH)
model.frame(e.lmH, add.index = TRUE)
model.frame(e.lmH, type = "unique")

data("gastricbypassL", package = "LMMstar")
dfL.NNA <- na.omit(gastricbypassL)
e.lmm <- lmm(glucagonAUC ~ time, repetition = ~visit|id, data = dfL.NNA, df = FALSE)
model.frame(e.lmm, type = "unique")
model.frame(e.lmm, type = c("unique","correlation"))
model.frame(e.lmm, type = "add.NA", add.index = TRUE)

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