OR: *O*dds *r*atio for binary regression models fit with 'glm'

Description Usage Arguments Value Note See Also Examples

View source: R/OR.R

Description

Odds ratio for binary regression models fit with glm

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
OR(x, ...)

## Default S3 method:
OR(x, ...)

## S3 method for class 'glm'
OR(
  x,
  ...,
  newdata = rep(1L, length(stats::coef(x))),
  ci = TRUE,
  alpha = 0.95,
  what = c("model", "all", "data")
)

Arguments

x

A numeric object containing probabilities P.
I.e. the range of P must be 0 to 1.
The odds ratio OR is given by:

OR = P[i] / (1-P[i]) = odds[1] / odds[0]

There is a method for regression models with class(x)==glm and x$family$family == "binomial".

...

Not used.

newdata

A vector of new variables to use.
There should be one value, in sequence, for each coefficient in the model.
By default, values are calculated for a change in the value of the coefficient for the predictor from 0 to 1.
For continuous predictors changes of > 1 unit may have more practical significance.

ci

If ci=TRUE (the default), include a confidence interval for P[i] and OR[i] in the returned values.

alpha

Used to cacluate the confidence interval, which is:

CI = x +- Z[1-alpha].SD

where the normal distribution Z = N(0,1) and SD is the standard deviation.

what

See Value below.

Value

A data.table. Columns give the model, the value of the link function and the associated probability P[i] and odds ratio OR[i].

If ci=TRUE, will also give upper and lower bounds of the confidence intervals for these values.

Rows are determined by what:

what="model"

The value of the link function is given for the full model.
If an intercept term is included, the value if given with and without the intercept.

what="all"

The value of the link function is given for each combination of coefficients in the model.

what="data"

The value of the link function is given for each set of predictors in the data with which the model was fit.
This option will ignore the argument newdata.

Note

In the model formulas, the intercept term is specified as 0 (absent) or 1 (present).
The variance of the values of the link function is:

Var = SUM(x[i]^2.var(B[i])) + SUM(2.x[i][x[j]].cov(B[i], B[j]))

where Var is the variance and cov is the covariance.

See Also

?stats::predict.glm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
if(require("graphics")){
    plot(x <- seq(from=0.1, to=0.9, by=0.05), y=OR(x))}

## End(Not run)
## H&L 2nd ed. Table 1.3. Page 10.
data(ageChd)
summary(g1 <- glm(chd ~ age, data=ageChd, family=binomial))
OR(g1)
attributes(OR(g1))
## Table 1.4. Page 20.
stats::vcov(g1)
## Table 2.3. Page 38.
data(lbw)
summary(g1 <- glm(LOW ~ LWT + RACE, data=lbw, family=binomial))
## Table 2.4. Page 42.
vcov(g1)
ageChd$gr54 <- ageChd$age > 54
OR(glm(chd ~ gr54, data=ageChd, family=binomial))

LogisticDx documentation built on Dec. 20, 2021, 5:07 p.m.