dummy.coef.lmm: Extract Mean Coefficients in Original Coding From a Linear...

View source: R/dummy.coef.R

dummy.coef.lmmR Documentation

Extract Mean Coefficients in Original Coding From a Linear Mixed Model

Description

This expands the mean coefficients of the linear mixed model into one coefficient per level of the original variable, i.e., including the reference level(s) where the fitted coefficients are 0.

Usage

## S3 method for class 'lmm'
dummy.coef(object, use.na = FALSE, ...)

Arguments

object

a lmm object.

use.na

[logical] Should NA or 0 be used to represent excluded coefficients in singular models.

...

Not used. For compatibility with the generic method.

Examples

## simulate data in the long format
set.seed(10)
dL <- sampleRem(100, n.times = 3, format = "long")
dL$group <- as.factor(paste0("d",dL$X1))

## fit mixed model with interaction
eUN.lmm <- lmm(Y ~ visit*group, repetition =~visit|id, data = dL, df = FALSE)
dummy.coef(eUN.lmm)

## fit mixed model with baseline constraint
dL$drug <- dL$group
dL[dL$visit==1,"drug"] <- "d0"
eUN.clmm <- lmm(Y ~ visit + visit:drug, repetition =~visit|id, data = dL, df = FALSE)
dummy.coef(eUN.clmm)

dL$drug <- factor(dL$group, levels = c("none","d0","d1"))
dL[dL$visit==1,"drug"] <- "none"
eUN.clmm.none <- lmm(Y ~ visit:drug, repetition =~visit|id, data = dL, df = FALSE)
dummy.coef(eUN.clmm.none)


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