extract_multinom_info: Extract information from a single try_vglm fit

Description Usage Arguments Value See Also Examples

Description

This function extracts summary information from a model fit using try_vglm and returns it in a list for easy access.

Usage

1
extract_multinom_info(modobj, coef_only = TRUE, ...)

Arguments

modobj

Object created using try_vglm, of class try-error, vglm, or mids.

coef_only

logical; whether to return only model coefficients (recommended to save memory; in the context of bootstrapping, coefficients are often the only required information) or entire model object. Defaults to TRUE.

coef_matrix

logical; whether to return a matrix of all coefficient estimates from each imputation in a mids object, in addition to the averages for each coefficient. Defaults to FALSE.

fail_pct

numeric, used if df is a mids object; proportion of imputed datasets that can have errors or warnings and still be able to calculate point estimates. Defaults to 0.8 (80% of imputations must fit with no errors or warnings).

Value

List containing the following elements:

If df is a mice::mids object, the following elements are also returned:

See Also

vglm; multinomial for model fitting. mice for imputation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
my_df <- data.frame(
  id = sample(1:50, size = 500, replace = TRUE),
  x1 = sample(c(NA, 1:100), size = 500, replace = TRUE),
  x2 = sample(c(NA, 1:100), size = 500, replace = TRUE),
  y = sample(c(NA, LETTERS[1:3]), size = 500, replace = TRUE)
)

## Basic usage
my_mod <- fit_multinom(formula = y ~ x1 + x2, df = my_df, ref_level = "A")
extract_multinom_info(my_mod)

## Handle missingness with multiple imputation using mice
## Also try a more complicated formula that might fail to converge
my_df_mice <- mice(my_df)
my_mod_mice <- fit_multinom(
  formula = y ~ rcs(x1, 5) * rcs(x2, 5),
  df = my_df_mice,
  ref_level = "A"
)

extract_multinom_info(my_mod_mice, coef_matrix = TRUE)

jenniferthompson/ClusterMultinom documentation built on May 7, 2019, 8:59 p.m.