build.formula: Convert a buildmer term list into a proper model formula

build.formulaR Documentation

Convert a buildmer term list into a proper model formula

Description

Convert a buildmer term list into a proper model formula

Usage

build.formula(dep, terms, env = parent.frame())

Arguments

dep

The dependent variable.

terms

The term list.

env

The environment of the formula to return.

Value

A formula.

Examples

library(buildmer)
form1 <- Reaction ~ Days + (Days|Subject)
terms <- tabulate.formula(form1)
form2 <- build.formula(dep='Reaction',terms)

# check that the two formulas give the same results
library(lme4)
check <- function (f) resid(lmer(f,sleepstudy))
all.equal(check(form1),check(form2))

# can also do double bars now
form1 <- Reaction ~ Days + (Days||Subject)
terms <- tabulate.formula(form1)
form2 <- build.formula(dep='Reaction',terms)
all.equal(check(form1),check(form2))

cvoeten/buildmer documentation built on March 3, 2023, 3:25 p.m.