I'm getting puzzled by a binary logistic regression in R with (obviously) a dichotomous outcome variable (coded 0 and 1) and a dichotomous predictor variable (coded 0 and 1). A contingency table suggests the outcome is a very good predictor, but it's not coming out as significant in my logistic regression. I found the same effect with a dummy problem, so I wonder if somebody can help me spot the problem here when I use a 'perfect' predictor?
outcome <- c(0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1)
predictor <- outcome
model <- glm(outcome ~ predictor, family = binomial)
summary(model)
Call:
glm(formula = outcome ~ predictor, family = binomial)
Deviance Residuals:
Min 1Q Median 3Q
Max
-0.000006547293 -0.000006547293 -0.000006547293 0.000006547293 0.000006547293
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -24.56607 53484.89343 -0.00046 0.99963
predictor 49.13214 79330.94390 0.00062 0.99951
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 15.15820324648649020 on 10 degrees of freedom
Residual deviance: 0.00000000047153748 on 9 degrees of freedom
AIC: 4
Number of Fisher Scoring iterations: 23
My question is why "predictor" comes out with p = .999 rather than something very small, given that it should perfectly predict the outcome here. Thanks in advance.
Edit: The output is the same if I change the main command to outcome ~ as.factor(predictor)