formfuns: expand double-bar RE notation by splitting

expandDoubleVertR Documentation

expand double-bar RE notation by splitting

Description

Modeled after lme4:::expandSlash, by Doug Bates. However, all formula operators that apply to factors (*, /, +) are applicable: the results are expanded into a list of independent (additive) random effect terms

Usage

expandDoubleVert(term)

RHSForm(formula) <- value

sumTerms(termList)

reOnly(f, response = FALSE, bracket = TRUE)

makeOp(x, y, op = NULL)

addForm0(f1, f2)

addForm(...)

expandAllGrpVar(bb)

findbars_x(
  term,
  debug = FALSE,
  specials = character(0),
  default.special = "us",
  target = "|",
  expand_doublevert_method = c("diag_special", "split")
)

inForm(form, value)

extractForm(term, value)

dropHead(term, value)

drop.special(x, value = quote(offset), preserve = NULL)

replaceForm(term, target, repl)

Arguments

term

expression/formula

formula

a formula object

value

term to remove from formula

termList

a list of formula terms

f

a formula

response

include response variable?

bracket

bracket-protect terms?

x

formula

y

a formula term (or an operator)

op

an operator

f1

formula #1

f2

formula #2

...

arguments to pass through to addForm0

bb

a list of naked grouping variables, i.e. 1 | f

debug

(logical) debug?

specials

list of special terms

default.special

character: special to use for parenthesized terms - i.e. random effects terms with unspecified structure

expand_doublevert_method

method for handling || operator: split into separate terms or replace by diag? Inherited from previous call where it was specified. 1. atom (not a call or an expression): NULL 2. special, i.e. foo(...) where "foo" is in specials: return term 3. parenthesized term: if the head of the head is | (i.e. it is of the form (xx|gg), then convert it to the default special type; we won't allow pathological cases like ((xx|gg)) ... [can we detect them?]

preserve

(integer) retain the specified occurrence of "value"

Value

a list of expressions

Examples

addForm0(y~x,~1)
addForm0(~x,~y)
ff <- lme4::findbars(y~1+(x|f/g))
expandAllGrpVar(ff)
expandAllGrpVar(quote(1|(f/g)/h))
expandAllGrpVar(quote(1|f/g/h))
expandAllGrpVar(quote(1|f*g))
expandAllGrpVar(quote(1|f+g))
expandAllGrpVar(quote(a+b|f+g+h*i))
splitForm(quote(us(x,n=2)))
findbars_x(~ 1 + (x + y || g), expand_doublevert_method = "diag_special")
findbars_x(~ 1 + (x + y || g), expand_doublevert_method = "split")
findbars_x(~ 1 + (1 | f) + (1 | g))
findbars_x(~ 1 + (1 | f) + (1 | g))
findbars_x(~ 1 + (1|h) + (x + y || g), expand_doublevert_method = "split")
findbars_x(~ 1 + (1|Subject))
findbars_x(~ (1||Subject))
findbars_x(~ (1|Subject))
findbars_x(~ (1|Subject), default.special = NULL)
findbars_x(~ 1 + x)
findbars_x(~ s(x, bs = "tp"))
findbars_x(y ~ a + log(b) + s(x, bs = "tp") + s(y, bs = "gp"),
   target = "s", default.special = NULL)
inForm(z~.,quote(.))
inForm(z~y,quote(.))
inForm(z~a+b+c,quote(c))
inForm(z~a+b+(d+e),quote(c))
f <- ~ a + offset(x)
f2 <- z ~ a
inForm(f,quote(offset))
inForm(f2,quote(offset))
extractForm(~a+offset(b),quote(offset))
extractForm(~c,quote(offset))
extractForm(~a+offset(b)+offset(c),quote(offset))
extractForm(~offset(x),quote(offset))
dropHead(~a+offset(b),quote(offset))
dropHead(~a+poly(x+z,3)+offset(b),quote(offset))
drop.special(x~a + b+ offset(z))
replaceForm(quote(a(b+x*c(y,z))),quote(y),quote(R))
ss <- ~(1 | cask:batch) + (1 | batch)
replaceForm(ss,quote(cask:batch),quote(batch:cask))
replaceForm(ss, quote(`:`), quote(`%:%`))

glmmTMB documentation built on Oct. 7, 2023, 5:07 p.m.