fmt_effect_md: Format an effect from a model object in markdown

View source: R/models.R

fmt_effect_mdR Documentation

Format an effect from a model object in markdown

Description

Format an effect from a model object in markdown

Usage

fmt_effect_md(
  model,
  effect,
  terms = "besp",
  digits = 2,
  statistic = NULL,
  b_lab = NULL,
  ci_width = 0.95,
  p_value_method = NULL
)

Arguments

model

a model object

effect

string naming an effect from a model

terms

a string representing the terms about the effect to extract and format and the order to print the terms. See details below. Defaults to "besp" for parameter estimate, standard error, statistic, p-value.

digits

a vector of digits to use for non-p-value terms. Defaults to 2 for 2 decimal places of precision for all terms. This argument can be a vector to set the digits for each term, but in this case, the digits is still ignored for p-values.

statistic

symbol to use for statistic. Defaults to t (or z in glmer models).

b_lab

label to print in subscripts after b for when "B" is one of the terms.

ci_width

width to use for confidence intervals when the term "i" is used.

Details

Currently only effects fit by stats::lm() and lme4::lmer().

The supported terms are:

  • "b" - parameter estimate (think b for beta)

  • "B" - parameter estimate with a subscript label provided by b_lab

  • "e" - standard error

  • "s" - statistic. The symbol for the statistic is set by statistic. The default value is "t" for a t-statistic. Example output: t = 1.

  • "S" - statistic as in "s" but with degrees of freedom. Example output: t(12) = 1.

  • "i" - confidence interval. Width is set by ci_width.

  • "p" - p-value. The p-value is formatted by fmt_p_value_md().

Degrees of freedom and p-values for lmer() models use the Kenwood-Rogers approximation provided by parameters::p_value_kenward(). This computation can take a while. The confidence-interval calculation uses default confidence interval calculation method used by broom.mixed::tidy.merMod().

Examples

model <- lm(breaks ~ wool * tension, warpbreaks)

# default to: b (beta), e (error), s (statistic), p (p value)
fmt_effect_md(model, "woolB", "besp")

fmt_effect_md(model, "woolB", "Besp", b_lab = "WoolB")

fmt_effect_md(model, "woolB", "i")

tjmahr/printy documentation built on March 4, 2024, 1:25 a.m.