function predict but with a warning message object not found

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.

Its description.

Here is my code.

noms_variables <- c("status_account","duration","history","purpose",
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'))

selection <- step(fit.logit, direction = "backward")


mod1 <- update(selection, ~. - purpose)

anova(selection, mod1, test="Chisq")

mod2 <- update(mod1, ~. - nb_credits)

anova(mod1, mod2, test="Chisq")

mod3 <- update(mod2, ~. - employment)

anova(mod2, mod3, test="Chisq")

mod4 <- update(mod3, ~. - age)

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"


Maybe this link could be helpful.

anova(selection, mod1,  test = "Rao")   
anova(selection, mod1, test = "LRT")   
anova(selection, mod1, test = "Chisq") 

Hope it helps.


1 Like

Thank you, I solved this problem. But I have another problem.

I use function 'predict' to predict the probability that a client's class is 0, but I got a warning message "Error in eval(predvars, data, env) : object 'status_account' not found" like this

Could you please tell me how to fix it? Thank you.

I update my code about the model.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.