remove.terms: Remove terms from a formula

remove.termsR Documentation

Remove terms from a formula

Description

Remove terms from a formula

Usage

remove.terms(formula, remove, check = TRUE)

Arguments

formula

The formula.

remove

A vector of terms to remove. To remove terms nested inside random-effect groups, use ‘(term|group)’ syntax. Note that marginality is respected, i.e. no effects will be removed if they participate in a higher-order interaction, and no fixed effects will be removed if a random slope is included over that fixed effect.

check

A logical indicating whether effects should be checked for marginality. If TRUE (default), effects will not be removed if doing so would violate marginality. Setting check to FALSE will remove terms unconditionally.

Examples

library(buildmer)
remove.terms(Reaction ~ Days + (Days|Subject),'(Days|Subject)')
# illustration of the marginality checking mechanism:
# this refuses to remove the term:
remove.terms(Reaction ~ Days + (Days|Subject),'(1|Subject)')
# so does this, because marginality is checked before removal:
remove.terms(Reaction ~ Days + (Days|Subject),c('(Days|Subject)','(1|Subject)'))
# but it works with check=FALSE
remove.terms(Reaction ~ Days + (Days|Subject),'(1|Subject)',check=FALSE)

buildmer documentation built on Oct. 25, 2023, 9:08 a.m.