Datatab

Odds Ratios in Logistic Regression

In this tutorial we start with a quick overview of logistic regression, then dive into what odds are and how they work. From there, we'll break down the odds ratio, and finally, we’ll bring it all together to see what the odds ratio means within the context of logistic regression.

Basic concept of logistic regression

First of all, what is a Logistic Regression? More precisely what is a binary Logistic Regression?

In a Regression analysis you want to infer or predict an outcome variable based on one or more other variables. The outcome variable is also called the dependent variable, and the other variables are independent variables.

Logistic Regression and odds

A binary Logistic Regression is a type of regression analysis used when the outcome variable is binary, meaning it has two possible values, like 'Yes' or 'No,' 'Success' or 'Failure.'

Example binary logistic regression

Let's say we are researchers, and we want to know whether a particular medication and a person's age have an influence on whether a person gets a certain disease or not.

Example Logistic Regression and odds

So, the outcome we're interested in is whether the patients developed the disease or did not develop it. And our independent variables are medication and age of a person. Now with the help of a logistic Regression, we want to infer or predict the outcome variable based on the independent variables. Now let’s take a look at what odds mean.

Odds in logistic regression

Let’s say we have two possible outcomes of something: success and failure. For example, if a therapy is successful or not. The probability that the therapy is successful is 0.7 (or 70%) and thus the probability of failure is 1 - 0.7 = 0.3.

What are odds

What are the odds?

Odds are defined as the ratio of the probability of success and the probability of failure. In other words, odds represent the ratio of the probability of an event happening to the probability of it not happening.

odds

If we look at our example, the odds are 0.7 divided by 0.3, which equals 2.33. This means the event “success” is 2.33 times more likely to happen than not.

odds example

So odds give us a measure of the likelihood of an event happening versus not happening.

definition odds

What are Odds Ratios?

Let's say we have a Group A (Patients with medication) and a Group B (Patients without medication). In Group A, we calculated a probability of 60% (or 0.6) of getting diseased. So the odds of getting diseased is 0.6 divided by 0.4, which is 1.5.

In Group B, where the patients didn’t get the medication, the probability of getting diseased is 80% (or 0.8). So the odds in Group B of getting diseased are 0.8 divided by 0.2, which is 4.

Odds Ratios Example

With the odds ratio, we can now compare the two groups. To do this, we can compare the odds of getting the disease in Group A relative to the odds of getting the disease in Group B.

The odds ratio is simply calculated by dividing the odds in Group A by the odds in Group B. This results in an odds ratio of 0.38.

Odds Ratios of two groups

The odds ratio of 0.38 means that the odds of being diseased in Group A are 0.38 times the odds of being diseased in Group B.

Odds Ratios interpretation

Of course we can also switch the order, then the odds ratio would be the odds in Group B divided by the odds in Group A. In this case, the odds ratio of approximately 2.67 means that the odds of being diseased in Group B are 2.67 times higher than the odds of being diseased in Group A.

If the odds ratio is greater than 1, the event is more likely to occur in the first group. If it’s less than 1, the event is less likely in the first group.

Odds ratio in Logistic Regression

First of all, to calculate a logistic regression we need data. Let’s say we have data from 50 patients. Our outcome variable is Disease, which is coded as 0 for 'not diseased' and 1 for 'diseased.' And we have two independent variables: Medication and Age. For the Medication variable, 0 indicates 'no medication,' and 1 indicates 'medication taken.'

Odds ratio in Logistic Regression Data

Now we can use this data to calculate a logistic regression.

Load data set

Calculate Odds Ratios

When you click on this link, the data is directly opened in DATAtab. We want to calculate a logistic regression, so we choose Regression. Here we can select the dependent and the independent variable. So, we select “disease” as our dependent variable and “medication” and “age” as our independent variables. Now we get the results of the logistic regression.

Logistic regression with DATAtab

Now we get the results of the logistic regression. Here we see the table that we will now take a closer look at.

Logistic regression results table odds ratio

In the first column, we can see the coefficients that define our model. These coefficients can be entered into the logistic regression formula.

Logistic regression coefficients and odds

If you want to learn more about this formular, feel free to check out our in-depth tutorial on logistic regression.

Now, we just need to enter a value for Medication—such as 1, indicating the patient received medication—and a value for Age, for example, 50.

Logistic regression formular odds

Then we can calculate the probability. In this case, the probability of being diseased is 0.55, or 55%. Okay, but we're not interested in the odds alone—we're interested in the odds ratio.

Again, the odds ratio is simply a comparison of the odds of an event occurring in two different groups.

Therefore, we just need to compare the odds of a person who took the medication with the odds of a person who did not take the medication. So to get the odds ratio, we just need to divide the odds of a person who took the medication by the odds of a person who did not take the medication. This results in an odds ratio of 0.64.

Logistic regression formular odds ratio

The odds ratio of 0.64 for Medication indicates that for individuals who took the medication, the odds of the outcome diseased are 0.64 times the odds for those who did not take the medication.

Odds ratios of continuous variables

With medication, we have two groups to compare. But what about a continuous variable like age? In this case, we simply look at what happens when we increase age by one unit. For example, we might compare the odds of the outcome for someone aged 50 versus someone aged 51. This allows us to calculate the odds ratio by comparing the two odds.

In this case, we get an odds ratio of 1.04. So for each one-year increase in age, the odds of the outcome 'diseased' increase by a factor of 1.04.

Odds ratio or exp(B)

There is one important thing: The odds ratio can actually be calculated simply by exponentiating each coefficient. So, exp(-0.45) is 0.64, which is the odds ratio of medication. And exp(0.04) is 1.04. which is the odds ratio for age.

Odds ratio or exp(B)

Statistics made easy

  • many illustrative examples
  • ideal for exams and theses
  • statistics made easy on 412 pages
  • 5rd revised edition (April 2024)
  • Only 8.99 €
Free sample
Datatab

"Super simple written"

"It could not be simpler"

"So many helpful examples"

Cite DATAtab: DATAtab Team (2024). DATAtab: Online Statistics Calculator. DATAtab e.U. Graz, Austria. URL https://datatab.net

Contact & Support FAQ & About Us Privacy Policy Statistics Software