Description Usage Arguments Details Value Functions See Also Examples
View source: R/statTools_code_OTHER.R
Functions for fancy printing P-values, Coefficients or OR (95% CI) from glm object. Prepared for bivarTable
FUN.model.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | getPval(model, vars = 2)
getBetaSd(model, vars = 2)
getORCI(model, vars = 2, between = ";")
verticalgetPval(model, vars = grep(pattern = "invar", x = names(model$coef)),
reference = 1)
verticalgetBetaSd(model, vars = grep(pattern = "invar", x =
names(model$coef)), reference = 1)
verticalgetORCI(model, vars = grep(pattern = "invar", x = names(model$coef)),
between = ";", reference = 1)
|
model |
glm or lm object. |
between |
String for collapsing lower and upper limits of the CI. |
reference |
Which value is the refference level in case of categorical variable?. |
var |
Vector for extracting values from the summary(model)$coef matrix. Row 1 is for the intercept. |
These functions are mainly thought to be used in the bivarTable FUN.model argument. The first argument has to be a model. They all get some information from the model (OR, p-values, coefficients, etc.) and display them as a vector. The vertical version of the functions, return a one column matrix with the results: one value for each level of the variable. Appends "Ref." or "1" to the reference level. In case of quantitative input variable, the output is the same for the vertical and non-vertical versions. See examples.
A vector with p-values, Beta's(SD) or OR (95% CI)
getBetaSd
: Get the coefficients of the model and SD from lm or glm.
getORCI
: For glm models, get the OR and 95% CI.
verticalgetPval
: Vertical version of getPval. Used in bivarTable.
verticalgetBetaSd
: Vertical version of getBetaSd. Used in bivarTable.
verticalgetORCI
: Vertical version of getORCI. Used in bivarTable.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | m <- glm(I(Sepal.Width > 3) ~ Species + Sepal.Length, iris, family = binomial)
getPval(m, vars = -1) # p-values from everything but the intercept
getPval(m, vars = 2:3) # p-values from rows 2 and 3 of the matrix
getPval(m, vars = grep(pattern = "Species", x = names(m$coeff))) # or coefficients from Species
getORCI(m, vars = 2:3)
getBetaSd(m, vars = 2:3)
verticalgetBetaSd(m, vars = grep("Species", x = names(m$coeff)), reference = 1)
verticalgetPval(m, vars = grep("Species", x = names(m$coeff)), reference = 1)
verticalgetORCI(m, vars = grep("Species", x = names(m$coeff)), reference = 1)
bivarTable(I(Sepal.Width > 3) ~ . - Sepal.Length - Sepal.Width, data = iris,
fit.model = list(adjusted = ~ . + Sepal.Length), # model to fit for every variable in rhs of the formula.
outcome = 2, # the output of the models is the variable in the column (lhs of formula)
FUN.model = list(adjusted = c("verticalgetBetaSd", "verticalgetORCI", "verticalgetPval"))) # add columns with extra info for the adjusted model.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.