0

I need to know the coefficient of every level of a glm.

Call:  glm(formula = Rep ~ ph_cat1, family = binomial(), data = db)

Coefficients:
(Intercept)     ph_cat12     ph_cat13  
      3.296       -3.381       -4.277  

Degrees of Freedom: 356 Total (i.e. Null);  354 Residual
  (27 osservazioni eliminate a causa di valori mancanti)
Null Deviance:      494.9 
Residual Deviance: 459.5    AIC: 465.5
> coef(full.model[-1])
NULL
> round(coef(full.model))
(Intercept)    ph_cat12    ph_cat13 
          3          -3          -4 

I've tried with +0 and +1

> full.model <- glm(Rep ~ ph_cat1 + 0  , data = db,family=binomial())
> full.model

Call:  glm(formula = Rep ~ ph_cat1 + 0, family = binomial(), 
   data = db)

Coefficients:
ph_cat11  ph_cat12  ph_cat13  
3.29584  -0.08474  -0.98083  

Degrees of Freedom: 357 Total (i.e. Null);  354 Residual
 (27 osservazioni eliminate a causa di valori mancanti)
Null Deviance:      494.9 
Residual Deviance: 459.5    AIC: 465.5
> full.model <- glm(Rep ~ ph_cat1 + 1  , data = db,family=binomial())
> full.model 

Call:  glm(formula = Rep ~ ph_cat1 + 1, family = binomial(), 
   data = db)

Coefficients:
(Intercept)     ph_cat12     ph_cat13  
     3.296       -3.381       -4.277  

Degrees of Freedom: 356 Total (i.e. Null);  354 Residual
 (27 osservazioni eliminate a causa di valori mancanti)
Null Deviance:      494.9 
Residual Deviance: 459.5    AIC: 465.5

I don't understand which one is the correct way to have the correct coefficient for every level.

3
  • 1
    For your one predictor model using treatment contrasts, the coefficient for the reference level is just “(Intercept)”. Since your profile says you’re a refugee from SAS, getting used to the treatment contrasts will be a challenge because SAS’s default contrasts are quite different. I’m a retired MD with solid skills in survival analysis Commented Feb 6, 2024 at 1:07
  • So for ph_cat11 my coefficient is 3.30? Thank you @IRTFM! Commented Feb 6, 2024 at 10:23
  • And each the other coefficients get added to it to form a level specific linear predictor. Commented Feb 6, 2024 at 13:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.