fit_extract_multinom: Fit multinomial model and extract summary info on a single...

Description Usage Value See Also Examples

Description

This is a wrapper for fit_multinom() + extract_multinom_info; it fits a model and extracts summary information (indicator for successful fit, vector of coefficients, and character vector of errors/warnings) given a formula, a single data object (data.frame or mice::mids object), and a reference level for the outcome.

Usage

1

Value

List containing the following elements:

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

See Also

fit_multinom, extract_multinom_info. 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
22
23
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_info <- fit_extract_multinom(
  formula = y ~ x1 + x2,
  df = my_df,
  ref_level = "A"
)

## Handle missingness with multiple imputation using mice
## Also try a more complicated formula that might fail to converge
my_df_mice <- mice(my_df[1:125,])
my_mod_info_mice <- fit_extract_multinom(
  formula = y ~ rcs(x1, 5) * rcs(x2, 5),
  df = my_df_mice,
  ref_level = "A",
  coef_matrix = TRUE
)

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