What happens when you do the Odds Ratio calculation by hand?? Is it equal to 2?
Hi,
I'm trying to educate myself further on using GLM and to do so I figured it'd be easiest to conduct a simple experiment where I knew the outcome so that I could see what it looked like when I ran the GLM.
To do so, I made a simple table up, consisting of a single IV and DV.
The basic idea is that if a person has property "A" they have a certain odds of having a disease and if they have property "B" they have a much higher odds of having the disease.Code:Obs Prop Disease 1 B 1 2 A 0 3 B 1 . . . 499 B 1
You get a table that looks like this from my made up data:
Because of the way I set it up, someone with property "A" has a 21% chance of having the imaginary disease while someone with property "B" has a 42% chance of having it. Or about 2x.Code:Row Labels 0 1 Grand Total A 192 52 244 B 148 107 255 Grand Total 340 159 499
When I run the GLM, this is the result I get:
Based on what I read online, the presence of Property B is 2.7x more likely to have disease than Propery A, right? But I know, because I set it up that way, that the effect is 2x, not close to 3x.Code:Call: glm(formula = Disease ~ Prop, family = "binomial", data = l) Deviance Residuals: Min 1Q Median 3Q Max -1.0431 -1.0431 -0.6924 1.3179 1.7584 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -1.3063 0.1563 -8.356 < 2e-16 *** PropB 0.9819 0.2013 4.876 1.08e-06 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 624.59 on 498 degrees of freedom Residual deviance: 599.69 on 497 degrees of freedom AIC: 603.69 Number of Fisher Scoring iterations: 4 > exp(coef(lr)) (Intercept) PropB 0.2708333 2.6694387 >
So, my question, what am I thinking about wrong here that causes me misinterpret the coefficient?
Thanks!
What happens when you do the Odds Ratio calculation by hand?? Is it equal to 2?
Stop cowardice, ban guns!
I get 2.6694387 when calculating it by hand using the contingency table values in the second code box in your first post.
This would mean the exp(beta) and the raw data give the exact same answer.
Stop cowardice, ban guns!
What are you trying to calculate? And how are you doing it? ...
I would do it like this
Centering the columns so the table is more readable (hopefully )...Code:Row Labels 0 1 Grand Total A 192 52 244 B 148 107 255 Grand Tota 340 159 499
Pr(Y=1|B)=107/255 = = 42%
Pr(Y=1|A)=52/244 = = 21%
Pr(Y=1| B)/Pr(Y=1| A) = 2
schwartzaw (03-09-2015)
I was calculating the odds ratio. 107/148 over 52/192, with a and b being the exposure and 1 being the outcome of interest.
That is the way the model is set up.
Stop cowardice, ban guns!
Side note JesperHP's method gets you the probability or ratio of probability.
Stop cowardice, ban guns!
schwartzaw (03-09-2015)
Thanks for all the responses! I think I need an "explain it like I'm 5". JesperHP's result of 2, the ratio of probability as hlsmith called it, is what I was expecting the coefficient to be. Is that not what the coefficient means? Am I misunderstanding the concept of odds ratio perhaps?
No that is not what the COEFFICIENT means .... because if you look at the formulas I used to calculate the probabilities entering the odds calculations I understood you to be asking for they were functions of the coefficientS not just the coefficients by itself. And actually they were also functions of the independent variable the only reason you cannot explicitly see this in the formulas is because the independent variable takes on the values 0 and 1 (see formula reply #4 where x enters explicitly ... now insert x=0 and x=1 to get formulas of my reply #6).
schwartzaw (06-18-2015)
Tweet |