or_glm | R Documentation |
This function calculates odds ratio(s) for specific increment steps of GLMs.
or_glm(data, model, incr, ci = 0.95)
data |
The data used for model fitting. |
model |
A fitted GLM(M). |
incr |
Increment values of each predictor given in a named list. |
ci |
Which confidence interval to calculate. Must be between 0 and 1. Default to 0.95 |
ci_low
and ci_high
are only calculated for GLM models because
MASS::glmmPQL()
does not return confident intervals due to its penalizing
behavior.
Currently supported functions: stats::glm,MASS::glmmPQL
A data frame with five columns:
predictor |
Predictor name(s) |
oddsratio |
Calculated odds ratio(s) |
ci_low |
Lower confident interval of odds ratio |
ci_high |
Higher confident interval of odds ratio |
increment |
Increment of the predictor(s) |
or_gam()
## Example with glm()
library(oddsratio)
# load data (source: http://www.ats.ucla.edu/stat/r/dae/logit.htm) and
# fit model
fit_glm <- glm(admit ~ gre + gpa + rank,
data = data_glm,
family = "binomial"
) # fit model
# Calculate OR for specific increment step of continuous variable
or_glm(data = data_glm, model = fit_glm, incr = list(gre = 380, gpa = 5))
# Calculate OR and change the confidence interval level
or_glm(
data = data_glm, model = fit_glm,
incr = list(gre = 380, gpa = 5), ci = .70
)
## Example with MASS:glmmPQL()
# load data
library(MASS)
data(bacteria)
fit_glmmPQL <- glmmPQL(y ~ trt + week,
random = ~ 1 | ID,
family = binomial, data = bacteria,
verbose = FALSE
)
# Apply function
or_glm(data = bacteria, model = fit_glmmPQL, incr = list(week = 5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.