Description Usage Arguments Value See Also Examples
From a matrix of coefficient estimates from B vglm() model fits on cluster bootstrapped data, calculate and plot odds ratios and 95 used within multi.plot.ors(), but can be called explicitly. Note: does not currently support group effects of variables with nonlinear terms; will calculate one odds ratio per coefficient.
1 2 | get.or.results(coef.matrix, remove.vars = NULL, round.vars = NULL,
round.digits = NULL, out.strings = NULL)
|
coef.matrix |
Matrix of coefficient estimates, with rows = number of bootstrapped data sets, columns = number of coefficients. |
remove.vars |
Character vector of variable names to **not** include in calculations/plots. Defaults to NULL (show all variables). |
round.vars |
Character vector of variable names whose results should be rounded to something other than two decimal places. Useful for variables with very small changes in odds for one-unit change in variable. Defaults to NULL. |
round.digits |
Integer; number of digits to round [round.vars] to. |
out.strings |
List of character strings to label outcome comparisons. Defaults to B vs. A, C vs. A, etc. Note that onus is on the user to supply correct labels. |
Data frame with one record per coefficient, including odds ratio estimate, lower and upper confidence limits, character string of results (format: "OR (LCL, UCL)") and text describing comparison.
vglm
, which this function assumes you are using;
multi.plot.ors
, which calculates p-values and plots all results using ggplot2.
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 | ## Create data frame
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'))
## Create matrices of coefficients for all bootstrap fits
boot.matrix.a <- do.call(rbind,
lapply(boot.fits.a$boot.models,
FUN = function(x){ x@coefficients }))
## Get odds ratios and CIs for x2
ors <- get.or.results(boot.matrix.a, remove.vars = 'x1')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.