Learn R Programming

vcdExtra (version 0.9.1)

get_model: Extract Model Formula from a loglm or glm Object

Description

get_model() extracts the model formula or bracket notation from a single loglm or glm object. This is useful for labeling models in summaries and plots. See get_models for the corresponding function for loglmlist and glmlist objects.

Usage

get_model(x, type = c("brackets", "formula"), abbrev = FALSE, ...)

Value

A character string with the model formula or bracket notation.

Arguments

x

A loglm or glm object

type

Type of output: "brackets" for loglinear bracket notation (e.g., "[AB] [C]"), or "formula" for R formula notation. For glm objects, only "formula" is meaningful.

abbrev

Logical or integer. If TRUE or a positive integer, abbreviate factor names to that many characters (default 1 when TRUE). Only applies to bracket notation.

...

Additional arguments passed to loglin2string such as sep and collapse.

Details

For loglm objects created by seq_loglm, the bracket notation is stored in the model.string component. For other loglm objects, it is constructed from the margin component using loglin2string.

For glm objects, the formula is extracted using formula().

See Also

get_models for glmlist and loglmlist objects, loglin2string, seq_mosaic

Other loglinear models: glmlist(), joint(), seq_loglm()

Examples

Run this code
data(Titanic)
tit.joint <- seq_loglm(Titanic, type = "joint")
get_model(tit.joint[[2]])
get_model(tit.joint[[4]])
get_model(tit.joint[[4]], abbrev = TRUE)
get_model(tit.joint[[4]], type = "formula")

Run the code above in your browser using DataLab