summarize_multinom_list: Fit multinomial model and extract summary info on a list of...

Description Usage Arguments Value See Also Examples

Description

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.

Usage

1
2
3
4
5
summarize_multinom_list(formula, df_list, ref_level, orgdf = NULL,
  orginfo = c("coefs", "nothing", "modobj"), nsuccfits = NULL, ...)

summarise_multinom_list(formula, df_list, ref_level, orgdf = NULL,
  orginfo = c("coefs", "nothing", "modobj"), nsuccfits = NULL, ...)

Arguments

formula

formula; see formula for more details.

df_list

list of either data.frame or mice::mids objects on which to run model.

ref_level

numeric (representing factor level) or character; level of outcome variable to use as reference.

orgdf

*(optional)* data.frame or mice::mids object to "test" the model. If the model does not converge successfully with this data, the function will stop. (Example: If df_list is a list of bootstrapped data frames, orgdf would likely be the data frame from which the bootstraps come.)

orginfo

*(optional)*, if orgdf supplied; one of coefs (default), nothing, or modobj. If coefs, returns only a named vector of coefficients. If modobj, returns entire model fit on orgdf. If nothing, returns nothing; only uses orgdf to test whether model runs successfully.

nsuccfits

*(optional)* numeric; number of successful fits requested. If specified, and more than nsuccfits successful model fits result from df_list, only the first nsuccfits will be returned in the final function information. If specified and fewer than nsuccfits are available, all information will be returned and a warning message will display.

...

Additional arguments to pass to fit_extract_multinom().

Value

List containing the following elements:

See Also

fit_multinom, extract_multinom_info, fit_extract_multinom. 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
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
)

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