15 months ago

Republic of Ireland

Hey dude / dudette,

The odds ratio (OR) is the exponent of the beta coefficient. The beta coefficient itself is the unit increase in the exposure. A practical example will explain it better:

# create random data with a condition A + B ('outcome') and *gene1* ('exposure')

```
modeling <- data.frame(
condition=factor(c(rep("A",100), rep("B",100)), levels=c("A", "B")),
gene1=c(runif(100), runif(100)))
head(modeling)
condition gene1
1 A 0.3607443
2 A 0.3268301
3 A 0.4237005
4 A 0.7621534
5 A 0.1456797
6 A 0.3201094
```

Note that we have set `A`

as the reference level.

# create a binomial logistic regression model, with *gene1*'s expression 'predicting' the outcome

```
model <- glm(condition ~ gene1, data=modeling, family=binomial(link='logit'))
summary(model)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.03767 0.30014 -0.126 0.900
gene1 0.07294 0.51258 0.142 0.887
```

Here, the beta coefficient for *gene1* in relation to condition B versus A is 0.07294. So, *gene1* increases in expression in condition B (if it decreased, the beta coefficient would be negative). This is not a statistically significant finding, though, with *p*=0.887.

We can also test the *gene1* via the Wald test on the beta coefficient:

```
require(aod)
wald.test(b=coef(model), Sigma=vcov(model), Terms=2)
Wald test:
----------
Chi-squared test:
X2 = 0.02, df = 1, P(> X2) = 0.89
```

# obtain the odds ratio and upper / lower confidence intervals (CIs):

```
exp(cbind(OR=coef(model), confint(model, level = 0.95)))
OR 2.5 % 97.5 %
(Intercept) 0.9630288 0.5333548 1.737047
gene1 1.0756700 0.3930383 2.949061
```

So, odds ratio is just 1.1, which, as you can tell, is not huge and only reflects a slight increase.

# log OR

The log OR is just the natural logarithm of the OR. With regard to why we may even want to use log OR over OR, well, there are probably many reasons. One is that we can calculate the Z score from the log OR:

```
OR <- 1.0756700
lowerCI <- 0.3930383
upperCI <- 2.949061
logOR <- log(OR)
logORlowerCI <- log(lowerCI)
logORSE <- (logOR - logORlowerCI) / 1.96
```

Then calculate Z:

```
logOR / logORSE
[1] 0.1420052
```

Kevin