util_margins_lm function

Utility function to create a margins plot from linear regression models

Utility function to create a margins plot from linear regression models

util_margins_lm( resp_vars = NULL, group_vars = NULL, co_vars = NULL, threshold_type = NULL, threshold_value, min_obs_in_subgroup = 5, ds1, label_col, levels = NULL, adjusted_hint = "", title = "", n_violin_max = getOption("dataquieR.max_group_var_levels_with_violins", dataquieR.max_group_var_levels_with_violins_default), sort_group_var_levels = getOption("dataquieR.acc_margins_sort", dataquieR.acc_margins_sort_default), include_numbers_in_figures = getOption("dataquieR.acc_margins_num", dataquieR.acc_margins_num_default) )

Arguments

  • resp_vars: variable the name of the measurement variable
  • group_vars: variable the name of the observer, device or reader variable
  • co_vars: variable list a vector of covariables, e.g. age and sex for adjustment
  • threshold_type: enum empirical | user | none. See acc_margins.
  • threshold_value: numeric see acc_margins
  • min_obs_in_subgroup: integer from=0. This optional argument specifies the minimum number of observations that is required to include a subgroup (level) of the group_var in the analysis.
  • ds1: data.frame the data frame that contains the measurements, after replacing missing value codes by NA, excluding inadmissible values and transforming categorical variables to factors.
  • label_col: variable attribute the name of the column in the metadata with labels of variables
  • levels: levels() of the original ordinal variable, if applicable. Used for axis tick labels.
  • adjusted_hint: character hint, if adjusted for co_vars
  • title: character title for the plot
  • n_violin_max: integer from=0. This optional argument specifies the maximum number of levels of the group_var for which violin plots will be shown in the figure.
  • sort_group_var_levels: logical Should the levels of the grouping variable be sorted descending by the number of observations (in the figure)?
  • include_numbers_in_figures: logical Should the figure report the number of observations for each level of the grouping variable?

Returns

A table and a matching plot.

  • Maintainer: Stephan Struckmann
  • License: BSD_2_clause + file LICENSE
  • Last published: 2025-03-05