Learn R Programming

parameters (version 0.22.0)

format_parameters: Parameter names formatting

Description

This functions formats the names of model parameters (coefficients) to make them more human-readable.

Usage

format_parameters(model, ...)

# S3 method for default format_parameters(model, brackets = c("[", "]"), ...)

Value

A (names) character vector with formatted parameter names. The value names refer to the original names of the coefficients.

Arguments

model

A statistical model.

...

Currently not used.

brackets

A character vector of length two, indicating the opening and closing brackets.

Interpretation of Interaction Terms

Note that the interpretation of interaction terms depends on many characteristics of the model. The number of parameters, and overall performance of the model, can differ or not between a * b a : b, and a / b, suggesting that sometimes interaction terms give different parameterizations of the same model, but other times it gives completely different models (depending on a or b being factors of covariates, included as main effects or not, etc.). Their interpretation depends of the full context of the model, which should not be inferred from the parameters table alone - rather, we recommend to use packages that calculate estimated marginal means or marginal effects, such as modelbased, emmeans, ggeffects, or marginaleffects. To raise awareness for this issue, you may use print(...,show_formula=TRUE) to add the model-specification to the output of the print() method for model_parameters().

Examples

Run this code
model <- lm(Sepal.Length ~ Species * Sepal.Width, data = iris)
format_parameters(model)

model <- lm(Sepal.Length ~ Petal.Length + (Species / Sepal.Width), data = iris)
format_parameters(model)

model <- lm(Sepal.Length ~ Species + poly(Sepal.Width, 2), data = iris)
format_parameters(model)

model <- lm(Sepal.Length ~ Species + poly(Sepal.Width, 2, raw = TRUE), data = iris)
format_parameters(model)

Run the code above in your browser using DataLab