0

After loading and partitioning my data successfully I am trying to get the following code to run

*logit.reg <- glm(Financial.Condition ~ ., data = train.df, family = "binomial")
options(scipen = 999)
summary(logit.reg)*

but I am getting the following error message:

*> logit.reg <- glm(Financial.Condition ~ ., data = train.df, family = "binomial")
Error in model.matrix.default(mt, mf, contrasts) : 
  variable 1 has no levels
> options(scipen = 999)
> summary(logit.reg)
Error in summary(logit.reg) : object 'logit.reg' not found*

What is the proper way to write the logit.reg function?

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. What does `class(train.df$Financial.Condition)` return? What other variables are in your data set? And note that you are using `glm`; `logit.reg` isn't an R thing, that just seems to be the variable name you chose to store your model. You could have used any other valid variable name you like. – MrFlick Apr 17 '21 at 05:22
  • 1
    Look at your subset for `train.df` It seems that in your 'train.df' subset there are no rows. As MrFlick pointed out please provide a minimal reprdocible example. – TarJae Apr 17 '21 at 06:35

0 Answers0