+ Reply to Thread
Results 1 to 10 of 10

Thread: Interpreting coefficients from GLM output

  1. #1
    Points: 4,378, Level: 42
    Level completed: 14%, Points required for next Level: 172

    Posts
    36
    Thanks
    4
    Thanked 1 Time in 1 Post

    Interpreting coefficients from GLM output




    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.

    Code: 
    Obs	Prop	Disease
    1	B	1
    2	A	0
    3	B	1
    .
    .
    .
    499	B	1
    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.

    You get a table that looks like this from my made up data:

    Code: 
    Row Labels	0	1	Grand Total
    A	192	52	244
    B	148	107	255
    Grand Total	340	159	499
    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.

    When I run the GLM, this is the result I get:

    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 
    >
    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.

    So, my question, what am I thinking about wrong here that causes me misinterpret the coefficient?

    Thanks!

  2. #2
    Omega Contributor
    Points: 38,432, Level: 100
    Level completed: 0%, Points required for next Level: 0
    hlsmith's Avatar
    Location
    Not Ames, IA
    Posts
    7,006
    Thanks
    398
    Thanked 1,186 Times in 1,147 Posts

    Re: Interpreting coefficients from GLM output

    What happens when you do the Odds Ratio calculation by hand?? Is it equal to 2?
    Stop cowardice, ban guns!

  3. #3
    TS Contributor
    Points: 12,501, Level: 73
    Level completed: 13%, Points required for next Level: 349

    Posts
    951
    Thanks
    0
    Thanked 103 Times in 100 Posts

    Re: Interpreting coefficients from GLM output

    Quote Originally Posted by schwartzaw View Post
    glm(formula = Disease ~ Prop, family = "binomial", data = l)
    What happens when you try a different family= ?
    All things are known because we want to believe in them.

  4. #4
    TS Contributor
    Points: 7,081, Level: 55
    Level completed: 66%, Points required for next Level: 69

    Location
    Copenhagen , Denmark
    Posts
    515
    Thanks
    71
    Thanked 123 Times in 116 Posts

    Re: Interpreting coefficients from GLM output

    Pr(Y=1) = \frac{\exp(\beta_0 + \beta_1 x)}{1+\exp(\beta_0 + \beta_1 x)}


    Code: 
    b1=-1.3063   # intercept
    b2=0.9819	 # coefficent of dummy x taking value=1 if B else 0
    
    x=1 
    pB=exp(b1+b2*x)/(1+exp(b1+b2*x))
    x=0
    pA=exp(b1+b2*x)/(1+exp(b1+b2*x)) # which is = exp(b1)/(1+exp(b1))
    
    pB/pA
    1.97

  5. #5
    Omega Contributor
    Points: 38,432, Level: 100
    Level completed: 0%, Points required for next Level: 0
    hlsmith's Avatar
    Location
    Not Ames, IA
    Posts
    7,006
    Thanks
    398
    Thanked 1,186 Times in 1,147 Posts

    Re: Interpreting coefficients from GLM output

    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!

  6. #6
    TS Contributor
    Points: 7,081, Level: 55
    Level completed: 66%, Points required for next Level: 69

    Location
    Copenhagen , Denmark
    Posts
    515
    Thanks
    71
    Thanked 123 Times in 116 Posts

    Re: Interpreting coefficients from GLM output

    Quote Originally Posted by hlsmith View Post
    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.

    What are you trying to calculate? And how are you doing it? ...


    I would do it like this

    Code: 
    Row Labels	0	1	Grand Total
    A                192    52    	244
    B	          148    107	255
    Grand Tota      340    159  	499
    Centering the columns so the table is more readable (hopefully )...

    Pr(Y=1|B)=107/255 = \frac{\exp(\beta_0 + \beta_1)}{1+\exp(\beta_0 + \beta_1)} = 42%
    Pr(Y=1|A)=52/244 = \frac{\exp(\beta_0 )}{1+\exp( \beta_0)} = 21%

    Pr(Y=1| B)/Pr(Y=1| A) = 2

  7. The Following User Says Thank You to JesperHP For This Useful Post:

    schwartzaw (03-09-2015)

  8. #7
    Omega Contributor
    Points: 38,432, Level: 100
    Level completed: 0%, Points required for next Level: 0
    hlsmith's Avatar
    Location
    Not Ames, IA
    Posts
    7,006
    Thanks
    398
    Thanked 1,186 Times in 1,147 Posts

    Re: Interpreting coefficients from GLM output

    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!

  9. #8
    Omega Contributor
    Points: 38,432, Level: 100
    Level completed: 0%, Points required for next Level: 0
    hlsmith's Avatar
    Location
    Not Ames, IA
    Posts
    7,006
    Thanks
    398
    Thanked 1,186 Times in 1,147 Posts

    Re: Interpreting coefficients from GLM output

    Side note JesperHP's method gets you the probability or ratio of probability.
    Stop cowardice, ban guns!

  10. The Following User Says Thank You to hlsmith For This Useful Post:

    schwartzaw (03-09-2015)

  11. #9
    Points: 4,378, Level: 42
    Level completed: 14%, Points required for next Level: 172

    Posts
    36
    Thanks
    4
    Thanked 1 Time in 1 Post

    Re: Interpreting coefficients from GLM output

    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?

  12. #10
    TS Contributor
    Points: 7,081, Level: 55
    Level completed: 66%, Points required for next Level: 69

    Location
    Copenhagen , Denmark
    Posts
    515
    Thanks
    71
    Thanked 123 Times in 116 Posts

    Re: Interpreting coefficients from GLM output


    Quote Originally Posted by schwartzaw View Post
    Is that not what the coefficient means?
    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).

  13. The Following User Says Thank You to JesperHP For This Useful Post:

    schwartzaw (06-18-2015)

+ Reply to Thread

           




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts






Advertise on Talk Stats