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