2
$\begingroup$

I am currently trying to fit a logistic regression model in R with separated data to analyse the problems occuring in such a case. Indeed for the following model warning messages occured, however in the model summary the standard errors and coefficients do not indicate any major issues in my opinion, and the number of fisher scorings is also not above 25, but rather low (= 2). Does anyone of you have ideas, why this could be the case? I have already checked that the data is indeed separated.

Code:
lr_master_ECTS_sem <- glm(glm(cod_master_SJ_bin ~ am_ECTS_total + semester, data = data, family = binomial(link = "logit"))
)

Output:
Call:
glm(formula = glm(cod_master_SJ_bin ~ am_ECTS_total + semester, 
    data = data, family = binomial(link = "logit")))

Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
(Intercept)   -0.5920092  0.0982783  -6.024 2.31e-07 ***
am_ECTS_total  0.0036223  0.0007227   5.012 7.74e-06 ***
semester       0.0442304  0.0123937   3.569 0.000826 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for gaussian family taken to be 0.06791891)

    Null deviance: 8.6275  on 50  degrees of freedom
Residual deviance: 3.2601  on 48  degrees of freedom
AIC: 12.478

Number of Fisher Scoring iterations: 2


Warning messages:
1: glm.fit: Algorithmus konvergierte nicht (did not converge)
2: glm.fit: Angepasste Wahrscheinlichkeiten mit numerischem Wert 0 oder 1 aufgetreten (probabilities with values of 0 or 1)
3: glm.fit: Algorithmus konvergierte nicht 
4: glm.fit: Angepasste Wahrscheinlichkeiten mit numerischem Wert 0 oder 1 aufgetreten 

UPDATE:

 ### standardized
> # Standardize the regressors using scale()
> data_standardized <- data
> data_standardized$am_ECTS_total <- scale(data$am_ECTS_total)
> data_standardized$semester <- scale(data$semester)
> 
> # Fit the logistic regression model with standardized regressors
> lr_master_ECTS_sem_standardized <- glm(cod_master_SJ_bin ~ am_ECTS_total + semester, data = data_standardized, family = binomial(link = "logit"))
Warning messages:
1: glm.fit: Algorithmus konvergierte nicht 
2: glm.fit: Angepasste Wahrscheinlichkeiten mit numerischem Wert 0 oder 1 aufgetreten 
> 
> # Summary of the model with standardized regressors
> summary(lr_master_ECTS_sem_standardized)

Call:
glm(formula = cod_master_SJ_bin ~ am_ECTS_total + semester, family = binomial(link = "logit"), 
    data = data_standardized)

Coefficients:
              Estimate Std. Error z value Pr(>|z|)
(Intercept)    -104.07   48318.32  -0.002    0.998
am_ECTS_total    82.96   62815.32   0.001    0.999
semester         97.21   68864.96   0.001    0.999

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 5.3182e+01  on 50  degrees of freedom
Residual deviance: 8.8010e-09  on 48  degrees of freedom
AIC: 6

Number of Fisher Scoring iterations: 25

Standardizing did indeed reveal the problematic model structure.

$\endgroup$
7
  • 1
    $\begingroup$ Could you provide some information on the scale of your predictors (i.e., mean and SD) and number of 1s in the outcome? If you could provide the data that would be even better. This is an absolutely tiny sample for logistic regression, and you might be better served to use Firth logistic regression, which is designed for small samples like yours. $\endgroup$
    – Noah
    Commented May 2 at 16:56
  • $\begingroup$ Thank you! It is my goal to use firth correction but I firstly want to illustrate what the problem in this model. n = 51 with 11 "ones" in the outcome. I cn currently not provide summary statistics of the regressors. But semester describes in which semester a subject studies and ECTS how many ECTS points in total subject has collected. With 180 ECTS someone has finished the bachelor and probably is already a master student. $\endgroup$
    – Max
    Commented May 2 at 18:51
  • $\begingroup$ Your model assumes there is a linear relationship between semester and the logit of the outcome, which is a bit of an odd model. But also ECTS variable has such an extreme scale that what looks like a normal coefficient may actually be extreme. Try standardizing it to see if the coefficient estimates blow up as you would expect with perfect separation. $\endgroup$
    – Noah
    Commented May 2 at 19:01
  • $\begingroup$ Also, I notice a bug in your code. It looks like you call glm() twice, because the output mentions a gaussian family when you requested binomial. Please correct your code and try running again. It is always a good idea to include the code you ran when asking for help, not just its output. $\endgroup$
    – Noah
    Commented May 2 at 19:02
  • $\begingroup$ Thank you once again for your help. I have just added the lm statement, I did not do anything else with the data, it´s a dataset that I have imported. I will try to standardize my regressors now and will then provide an update. i notice the gaussian problem in the output, however I did specify the family as binomial, so i am not sure what the mistake could be. $\endgroup$
    – Max
    Commented May 2 at 20:56

1 Answer 1

1
$\begingroup$

Your model output is not fine unfortunately. Judging by the fact that, after standardizing the predictors, the intercept is taken to be -100 on the log odds scale, you just don't have enough events to fit a logistic with 2 covariates. I already see you have just 50 observations, so I would guess maybe the number of events is 10 or fewer, and the size of the effect is large. I would guess therefore, that the covariates are strongly stratifying, and all negative and positive cases lie below and above some combination of covariate values, respectively. This is separation. As a result the odds ratio tends to explode off into infinity, and the model results can't be trusted. Without standardizing, the fitter terminates early and gives an unreliable estimate of inference which suggests statistical significance, with standardizing the opposite is true although the log odds ratios are much larger. Normally standardizing covariates would not affect the overall inference on their values (putting the issue of interactions aside), but the fact that these are different portray the issue of modeling singularity.

$\endgroup$
4
  • $\begingroup$ It's worth noting that the first model wasn't a logistic regression at all; due to a coding error, it was a linear regression. So it is irrelevant here. We never saw the logistic regression model without standardizing. $\endgroup$
    – Noah
    Commented May 2 at 22:04
  • $\begingroup$ I honestly still don´t see the difference between the first and the second model, code, except for the standardized regressors. Could you explain more in detail what´s wrong in the Code? Thank you both for your input! I am aware of the events per variable problem as well as the issue with separation. My goal is to highlight these issues and my problem in the first model was that it did not converge (as stated in the warnings) but did not look odd to me regarding coefficients etc.. $\endgroup$
    – Max
    Commented May 2 at 22:37
  • $\begingroup$ Nevermind, now I see it $\endgroup$
    – Max
    Commented May 2 at 22:39
  • $\begingroup$ Thank you both Adam and Noah, it was really a stupid mistake to write glm twice. Way to long discussion for such a silly mistake. Huge thanks to both of you, I was very confused but can now continoue writting my thesis. $\endgroup$
    – Max
    Commented May 2 at 22:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.