Learn R Programming

LogisticDx (version 0.1)

logiProb: Logit, odds ratio and probability for coefficients of a logistic regression

Description

Generate logit, log odds ratio, odds ratio and probability for coefficients in a logistic regression. Can be generalized to all combinations of coefficients. Values are calculated for a change in the value of the coeffient for the predictor from $0$ to $1$. (For continuous predictors changes of more than one unit may have more practical significance).

Usage

logiProb(x, usePrim = FALSE, all = FALSE)

Arguments

x
A logistic regression model of class glm
all
If all=FALSE (the default) return values for all coefficients in model, considered together. If all=TRUE return values for all combinations of coefficients in model.
usePrim
If usePrim=FALSE (the default) use utils::combn to generate combinations. If usePrim=TRUE use gRbase::combnPrim instead (faster).

Value

  • If all=TRUE, a data.table giving, for each combination of coefficients:
  • coefCombination of coefficients
  • logitThe logit for a given combination of coefficients
  • lnORNatural log of Odds Ratio
  • OROdds Ratio
  • pprobability
  • This is sorted by OR (low to high). If all=FALSE, a data.frame giving the above values for all predictors.

Examples

Run this code
set.seed(1)
f1 <- genLogiDf(n=50)$model
logiProb(f1)
d1 <- genLogiDt(n=50, model=FALSE)
logiProb(glm(y ~ x1 + x3 -1, data=d1, family=binomial()), all=TRUE)

Run the code above in your browser using DataLab