Description Usage Arguments Value See Also Examples
This function extracts summary information from a model fit using
try_vglm
and returns it in a list for easy access.
1 | extract_multinom_info(modobj, coef_only = TRUE, ...)
|
modobj |
Object created using |
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 |
fail_pct |
numeric, used if |
List containing the following elements:
fitsucc
: logical indicating whether the model was successfully fit,
with no warnings/errors
coefs
: numeric vector of model coefficients (NULL if
fitsucc
= FALSE)
msgs
: character vector of warnings/error messages (NULL if
fitsucc
= TRUE)
modobj
: full model object of class VGAM::vglm()
. Only
returned if requested (coef_only
= FALSE).
If df
is a mice::mids
object, the following elements are also
returned:
nfailsucc
: numeric vector; number of successful and failed model
fits among imputations
impcoefs
(if coef_matrix = TRUE
): MxP matrix of
coefficients from each individual imputation
vglm
; multinomial
for model
fitting. mice
for imputation.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.