Hi guys, I'm trying to do a logistic regression. But I ran into a problem, when I use predict, I got a warning message that "object not found". And I don't understand why. Can anyone please help me solve this problem? Thank you very much.
Here is the data set.
https://drive.google.com/file/d/1iHxy3lbAh8AkmBaIr6hwi8tbtRxVvmtD/view?usp=sharing
Its description.
https://archive.ics.uci.edu/ml/datasets/statlog+(german+credit+data)
Here is my code.
noms_variables <- c("status_account","duration","history","purpose",
"amount","savings","employment","installement_rate",
"status_personnal","other_debtors","residence_since",
"property","age","other_installment","housing",
"nb_credits","job","liable","telephone","foreign","class")
credit0 <- read.table("GermanCredit.txt", col.names = noms_variables)
credit0$class <- as.factor(credit0$class-1)
credit <- subset(credit0, select=-c(foreign))
fit.logit <- glm(class~., data = credit, family = binomial(link = 'logit'))
summary(fit.logit)
selection <- step(fit.logit, direction = "backward")
summary(selection)
mod1 <- update(selection, ~. - purpose)
summary(mod1)
anova(selection, mod1, test="Chisq")
mod2 <- update(mod1, ~. - nb_credits)
summary(mod2)
anova(mod1, mod2, test="Chisq")
mod3 <- update(mod2, ~. - employment)
summary(mod3)
anova(mod2, mod3, test="Chisq")
mod4 <- update(mod3, ~. - age)
summary(mod4)
anova(mod3, mod4, test="Chisq")
newdata <- data.frame(class = 0)
predict(mod4, type = "response", newdata)
Warning message I got.
"Error in eval(predvars, data, env) : object 'status_account' not found"