Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, …) : NA/NaN/Inf in ‘y’, tried every possible way

The column went_on_backorder is a factor. Linear regression requires a numeric response variable.

To use logistic regression, use glm in base R or a package such as vgam. Here’s a brief example:

pd_train1 <- data.frame('went_on_backorder' = c('No','Yes','Yes'), 'lead_time' = 1:3)
model <- glm(went_on_backorder ~ ., data = pd_train1, family = 'binomial')

And you can predict your classes:

predict(model, newdata = data.frame('lead_time' = c(0,1,2.5,3.5)), type = "response")

Leave a Comment

tech