Description Usage Arguments Value See Also Examples
This function calls fit_extract_multinom()
(which calls
fit_multinom()
+ extract_multinom_info
) on a list of data
objects (data.frame
or mice
), then summarizes the
results of each.
1 2 3 4 5 |
formula |
|
df_list |
|
ref_level |
numeric (representing factor level) or character; level of outcome variable to use as reference. |
orgdf |
*(optional)* |
orginfo |
*(optional)*, if |
nsuccfits |
*(optional)* |
... |
Additional arguments to pass to |
List containing the following elements:
allresults
: [tibble]tibble
containing one row
per element of df_list
, with the following information for each
included as variables or [list columns](https://www.rstudio.com/resources/videos/using-list-cols-in-your-dataframe/):
fitsucc
: logical; indicates whether model was successfully
fit to that data object
coefs
: tibble with one row, and one column per coefficient
impcoefs
, if requested: tibble with coefficient estimates
from each imputation
msgs
: list of character strings; errors/warning messages
from unsuccessful fits
modobj
, if requested: full model object
fitsucc
: numeric vector including number of model fit Successes,
Failures, and (if applicable) Imputation Successes/Failures
coefs
: tibble with one row per element of df_list
and one
column per model coefficient (no rows for unsuccessful model fits)
impcoefs
, if requested: tibble with one row per *imputation* of
df_list
with a successful model fit and one column per model
coefficient (no rows for unsuccessful model fits)
orgcoefs
, if orgdf
is supplied and
orginfo = "coefs"
: named vector of coefficients from model fit on
starting data frame (eg, original data frame from which df_list
is
bootstrapped)
orgmod
, if orgdf
is supplied and
orginfo = "modobj"
: full model fit on starting data frame (eg,
original data frame from which df_list
is bootstrapped)
fit_multinom
, extract_multinom_info
,
fit_extract_multinom
. 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 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 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_dflist <- create_bootdata(my_df, cluster_var = "id", nboot = 10)
my_mod_summary <- summarize_multinom_list(
formula = y ~ x1 + x2,
df_list = my_dflist,
ref_level = "A",
orgdf = my_df
)
## Supply original data frame as testdf; see what happens when model is too
## complex
my_df_small <- my_df[1:100,]
my_dflist_small <- create_bootdata(my_df_small, cluster_var = "id", nboot = 10)
my_mod_summary <- summarize_multinom_list(
formula = y ~ rms::rcs(x1, 4) * rms::rcs(x2, 4),
df_list = my_dflist_small,
ref_level = "A",
orgdf = my_df_small
)
## Handle missingness with multiple imputation using mice
## Also try a more complicated formula that might fail to converge
my_dflist_mice <- create_bootdata(
my_df[1:100,], cluster_var = "id", nboot = 10, impute = TRUE
)
my_mod_info_mice <- summarize_multinom_list(
formula = y ~ rcs(x1, 4) * rcs(x2, 4),
df_list = my_dflist_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.