coef_to_table: Summarise model coefficients in a table

View source: R/coef_to_table.R

coef_to_tableR Documentation

Summarise model coefficients in a table

Description

Returns a table of coefficients, filtered by minimum absolute value and optionally separating into interactions and decomposing dummy variables into parent variable and factor level parts.

Usage

coef_to_table(fit, var_names = NULL, ..., min_coef = 1e-10)

Arguments

fit

A fitted model with coefficients (e.g. from glmnet).

var_names

(optional) A character vector of column names for the data used in fit.

...

Parameters passed to coef(). For cv.glmnet models this will most usually be the the regularisation parameter s of the desired model.

min_coef

Coefficients with smaller absolute value than this are excluded from the table.

Details

Only coefficients with absolute value greater than min_coef are included. If var_names is supplied then extra columns will be added which split the name into component parts. Where there are interactions, these are separated, and any dummy variables are split into their original variable and factor level names. See "Value" below for more details.

This was designed for glmnet models, but it also often works with other glm-type models.

Value

A tibble which will always contain name and coef columns. If var_names is supplied then there will be extra columns also. If there are no interactions then there will be two extra columns var and level which are extracted from name. If there are interactions, there will instead be three columns for each interaction: interact_dd, var_dd, and level_dd, where each "dd" gives the number of the interaction. The number of interactions displayed depends on which coefficients are included in the returned table, not the original model, so min_coef can change the number of output columns.


jedwards24/jemodel documentation built on July 1, 2023, 3:59 p.m.