Description Usage Value See Also Examples
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.
1 | fit_extract_multinom(formula, df, ref_level, ...)
|
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
fit_multinom
, extract_multinom_info
.
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 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
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.