Description Usage Arguments Details See Also Examples
This function runs a multinomial logistic regression model on a data.frame or
'mice::mids' object, currently using try_vglm
(which runs
VGAM::vglm(..., family = multinomial(...))
, but if the model fails to
converge - ie, warning or error - the warning/error message is returned
instead).
1 | fit_multinom(formula, df, ref_level, fitter = try_vglm)
|
formula |
|
df |
|
ref_level |
numeric (representing factor level) or character; level of outcome variable to use as reference. |
fitter |
Function to use for model fitting. Currently only option is
|
This wrapper function is necessary to perform this operation on
mids
objects, which require a with(..., )
syntax.
vglm
; multinomial
for model
fitting. mice
for imputation.
1 2 3 4 5 6 7 8 9 10 | 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)
)
## Works whether df is a data.frame or mice() object
fit_multinom(y ~ x1 + x2, my_df, ref_level = "A")
fit_multinom(y ~ x1 + x2, mice::mice(my_df), ref_level = "A")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.