Auxiliary Functions for Formulas and Model Objects

Description

Various auxiliary functions to facilitate the work with formulas and fitted model objects.

Usage

response_name(formula)

Arguments

formula A formula, Formula, or a fitted model object.

Value

Function response_name extracts the response name as a character vector.

See Also

gamlss2

Examples

library("gamlss2")

## basic formula
f <- y ~ x1 + x2 + log(x3)
response_name(f)
[1] "y"
## formula with multiple responses
f <- y1 | y2 | y3 ~ x1 + s(x2) + x3 + te(log(x3), x4) | x2 + ti(x5)
response_name(f)
[1] "y1" "y2" "y3"
## list of formulas
f <- list(
  y1 ~ x1 + s(x2) + x3 + te(log(x3), x4),
  y2  ~ x2 + sqrt(x5),
  y3  ~ z2 + x1 + exp(x3) + s(x10)
)
response_name(f)
[1] "y1" "y2" "y3"