0

I am trying to run a logit regression and I tried two approaches:

m.logit <- glm(p4 ~ scale(log(gdp,orthodox,swb)),
               data = happiness,
               family = binomial("logit"))
summary(m.logit)

Throws: Error in summary(m.logit) : object 'm.logit' not found

While

m1.logit <- glm(p4 ~ gdp + orthodox + swb, family = binomial(link = "logit"), data = happiness)

Throws: Error in eval(family$initialize) : y values must be 0 <= y <= 1

I kind of understood the errors (in the former case m.logit is not found, and in the latter, I need to transform the variables I think...) but don't know how to solve it...

Any help?

Gautam
  • 1,754
  • 1
  • 14
  • 22
sosawah
  • 1
  • 1
  • 3
    Hi sosawah. Please add a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). That way you can help others to help you! – dario Feb 09 '20 at 15:20
  • Apparently your column ```p4``` contains some values different from 0 or 1 which means you can't use a logit. If you have a categorical variable with more choices than 0 or 1, you might want to use [```mlogit```](https://cran.r-project.org/web/packages/mlogit/mlogit.pdf) instead. But I agree with @dario, it would be easier to help you with a reproducible example – bretauv Feb 09 '20 at 20:06

0 Answers0