getPval: Extracting P-values, Coefficients or OR (95% CI) from a lm or...

Description Usage Arguments Details Value Functions See Also Examples

View source: R/statTools_code_OTHER.R

Description

Functions for fancy printing P-values, Coefficients or OR (95% CI) from glm object. Prepared for bivarTable FUN.model.

Usage

 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)

Arguments

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.

Details

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.

Value

A vector with p-values, Beta's(SD) or OR (95% CI)

Functions

See Also

GoF, nagelkerke

Examples

 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.

gcastella/statTools documentation built on May 16, 2019, 11:10 p.m.