multi.bootstrap: Run Multinomial Regression Models on a List of Data Sets

Description Usage Arguments Value See Also Examples

Description

Run vglm() on a master data set and each of a list of data sets created from it (often using create.sampdata()), saving original model object, all successful model objects, and number of models with errors.

Usage

1
2
multi.bootstrap(org.data, data.sets, ref.outcome, multi.form,
  n.boot = length(data.sets)/1.25, xvar = "Exposure")

Arguments

org.data

Original data set, of class data.frame.

data.sets

List of data sets with same variables as org.data.

ref.outcome

Integer; level of outcome variable to use as reference.

multi.form

Formula used for all models.

n.boot

Integer representing number of successful model fits required. Defaults to 80% of length of data.sets.

xvar

String to include in printed status updates. Defaults to "Exposure."

Value

List of 1) org.model (model fit to org.data); 2) boot.models (fits for all successful models); and 3) num.failed (number of models which failed).

See Also

vglm().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
df <- data.frame(id = sample(1:20, size = 100, replace = TRUE),
                 x1 = rnorm(n = 100),
                 x2 = rbinom(p = 0.75, n = 100, size = 1),
                 y = sample(LETTERS[1:3], size = 100, replace = TRUE))
df <- df[order(df$id),]
df$time <- unlist(lapply(1:length(unique(df$id)),
                         FUN = function(idnum){ 1:nrow(df[df$id == unique(df$id)[idnum],]) }))

## Using create.sampdata(), generate list of cluster bootstrapped data sets
bootdata.list <- create.sampdata(org.data = df,
                                 id.var = 'id',
                                 n.sets = 25)

## Fit model to original and bootstrapped data frame,
##   saving errors and warnings to .txt file
boot.fits.a <- multi.bootstrap(org.data = df,
                               data.sets = bootdata.list,
                               ref.outcome = grep('A', levels(df$y)),
                               multi.form = as.formula('y ~ x1 + x2'))

jenniferthompson/ClusterBootMultinom documentation built on May 19, 2019, 4:03 a.m.