I want to do a logistic regression simulation using R
I use this code
set.seed(666) age = rnorm(60) blood_pressure = rnorm(60) race = sample(c(rep(1,30),rep(0,30))) inactivity = sample(c(rep(1,30),rep(0,30))) weight = rnorm(60) z=1+1*age+blood_pressure*2+3*weight+3*inactivity+0*race pr=exp(z)/(1+exp(z)) y=rbinom(60,1,pr) df = data.frame(y=y,age,blood_pressure,inactivity,weight,race) glm(y~age+blood_pressure+inactivity+weight+race,data=df,family=binomial(link='logit'),control = list(maxit = 50))
I got very strange result from it.
Coefficients: (Intercept) age blood_pressure inactivity weight race -39.75 46.64 106.65 143.52 229.75 100.87
And it says the model doesn't converge.
Does someone know what's wrong and how to fix it?