extract_param: Extract and interpret model parameters

View source: R/extract_param.R

extract_paramR Documentation

Extract and interpret model parameters

Description

extract_param() extracts model coefficients and inferential statistics using parameters::model_parameters(). It returns a compact, non-redundant parameter table and, when appropriate, transforms coefficients and confidence intervals into a more directly interpretable metric.

Depending on the model family and link function, the interpreted estimate may represent an odds ratio, risk ratio, incidence rate ratio, hazard ratio, or another multiplicative ratio. For models for which no meaningful automatic transformation is available, the original coefficient is retained.

The function also computes an approximate Cohen's d for each coefficient: from the log odds ratio for logistic models, and from the coefficient-level t or z statistic otherwise.

Usage

extract_param(
  model,
  conf_level = 0.95,
  include_intercept = FALSE,
  effects = "fixed",
  component = "conditional",
  transform = c("auto", "none", "exponentiate")
)

Arguments

model

A fitted statistical model supported by parameters::model_parameters().

conf_level

A single numeric value between 0 and 1 specifying the confidence level. The default is 0.95.

include_intercept

Logical. Should the intercept be included in the returned table? The default is FALSE.

effects

Character string specifying the model effects to extract for models that distinguish between fixed and random effects. The default is "fixed".

component

Character string specifying the model component to extract for models with multiple components, such as zero-inflated or hurdle models. The default is "conditional".

transform

Character string specifying how model coefficients should be transformed for interpretation. Possible values are:

"auto"

Automatically exponentiate coefficients from models with log or logit links and from Cox proportional-hazards models.

"none"

Retain the original coefficient and confidence interval as the interpreted estimate.

"exponentiate"

Exponentiate the coefficient and confidence interval regardless of the detected model family or link.

The default is "auto".

Details

The Estimate column always contains the coefficient on the scale on which the model was fitted. For generalized models, this is generally the scale of the linear predictor.

When transform = "auto", the following transformations are applied:

Identity link

No transformation. Interpreted_Estimate is equal to Estimate.

Binomial model with logit link

The coefficient is exponentiated and interpreted as an odds ratio.

Binomial model with log link

The coefficient is exponentiated and interpreted as a risk ratio.

Poisson or negative-binomial model with log link

The coefficient is exponentiated and interpreted as an incidence rate ratio.

Other models with a log link

The coefficient is exponentiated and interpreted as a multiplicative ratio.

Cox proportional-hazards model

The coefficient is exponentiated and interpreted as a hazard ratio.

No automatic exponentiation is performed for links such as probit, cauchit, or cloglog, because exponentiating an individual coefficient does not generally produce a standard effect measure with a direct interpretation.

The interpreted estimates are not necessarily predictions on the response scale. For example, an odds ratio is a ratio of odds rather than a predicted probability. Predicted probabilities or expected responses require the intercept and values of the other model predictors.

Confidence intervals and p-values use the same inferential method as the significance labels of the plotting functions, so that an interval excluding zero always corresponds to a significant coefficient:

  • linear mixed models fitted with lme4 or lmerTest use Satterthwaite degrees of freedom when lmerTest is installed, as in their p-values;

  • generalized linear (mixed) models use Wald intervals, which correspond to the Wald z tests reported by summary(); profile intervals can disagree with these tests near the significance threshold;

  • other models use the default method of parameters::model_parameters().

Approximate Cohen's d values are computed as follows, as reported in d_method:

  • for models with a logit link, the log odds ratio is converted as d = \beta \sqrt{3} / \pi (Chinn, 2000), which treats the logistic distribution of the latent response as the reference standard deviation; the same conversion is applied to the confidence limits;

  • t statistics are converted using effectsize::t_to_d() with the coefficient-specific degrees of freedom;

  • z statistics are converted using effectsize::z_to_d() with the number of observations returned by stats::nobs().

The conversions based on t or z do not depend on how the contrast is scaled. The conversion from the log odds ratio refers to the coefficient as coded: for a contrast whose coefficient equals a scale factor s multiplied by the compared difference (for example Helmert contrasts; see contrasts_onepred()), the d of the compared difference is d / s. The plotting functions apply this rescaling.

These conversions are approximations and assume conditions implicit in the conversion formulas. In particular, the conversion to Cohen's d assumes two groups of approximately equal size, and the conversion from the log odds ratio assumes a logistic latent response. Directly estimated effect sizes should be preferred when the necessary data and an appropriate estimator are available.

Value

A data frame with one row for each extracted model parameter and the following columns:

Parameter

Name of the model parameter.

Estimate

Untransformed model coefficient on the model scale.

SE

Standard error of the untransformed coefficient.

CI

Confidence level used for the interval.

CI_low

Lower confidence limit of Estimate.

CI_high

Upper confidence limit of Estimate.

Statistic

Coefficient-level test statistic.

Statistic_type

Type of test statistic, usually "t" or "z".

df

Coefficient-level degrees of freedom, when available.

p

Coefficient-level p-value, when available.

Interpreted_Estimate

Coefficient transformed into the interpretation indicated by Estimate_type.

Interpreted_CI_low

Lower confidence limit of the interpreted estimate.

Interpreted_CI_high

Upper confidence limit of the interpreted estimate.

Estimate_type

Interpretation of Interpreted_Estimate, such as "Coefficient", "Odds ratio", "Risk ratio", "Incidence rate ratio", "Hazard ratio", or "Multiplicative ratio".

d

Approximate Cohen's d.

d_CI_low

Lower confidence limit of approximate Cohen's d.

d_CI_high

Upper confidence limit of approximate Cohen's d.

d_method

Conversion used for d: "log odds ratio", "t", or "z"; NA when no conversion was possible.

Note

The coefficient transformation is based on the model family and link detected through stats::family() whenever available. Some model classes may use non-standard structures or parameterizations and may therefore require transform = "none" or transform = "exponentiate" to override automatic behaviour.

In models with multiple components, the interpretation may depend on the component selected through component.

References

Chinn, S. (2000). A simple method for converting an odds ratio to effect size for use in meta-analysis. Statistics in Medicine, 19(22), 3127-3131.

Examples

set.seed(123)

# Linear regression
dat_lm <- data.frame(
  y = rnorm(120),
  x = rnorm(120),
  group = factor(rep(c("A", "B", "C"), each = 40))
)

contrasts(dat_lm$group) <- contr.sum(3)

mod_lm <- lm(y ~ x + group, data = dat_lm)

extract_param(mod_lm)

# Binomial logistic regression
dat_glm <- data.frame(
  y = rbinom(200, size = 1, prob = 0.40),
  x = rnorm(200),
  group = factor(sample(c("A", "B", "C"), 200, replace = TRUE))
)

contrasts(dat_glm$group) <- contr.sum(3)

mod_glm <- glm(
  y ~ x + group,
  data = dat_glm,
  family = binomial(link = "logit")
)

extract_param(mod_glm)

# Disable automatic coefficient transformation
extract_param(mod_glm, transform = "none")


MoPlot documentation built on Nov. 25, 2026, 5:10 p.m.