I devised this toy example
library(sigmoid) N <- 10000 age <- runif(N, min=20, max=90) e <- rnorm(N, 0, 5) hi <- logistic(-100+2*age+e) hid <- ifelse(hi>=0.5, T, F) hid <- as.factor(hid) df <- data.frame(age=age, hid=hid) lr <- glm(hid~age, data=df, family=binomial(link="logit")) s <- summary(lr) print(s)
hid contains 4304 FALSE and 5696 TRUE.
I would have expected to get the correct coefficients out of the logistic regression.
Instead I am getting -39.46 for the intercept and 0.79 for the slope. Both with p-values $\approx$ 0.
What am I doing wrong?