logistics regression

Fitting a logistic regression model using the predictors "balance"

The function "glm()" fits generalized linear models, a class of models that includes logistic regression as a special case

The function "glm()" is similar to that of "lm()", except that we have to pass on the argument "family=binomial" in order to fit a logistic regression model

mod_1=glm(default~balance,data=Default,family=binomial)
Error in eval(family$initialize) : y values must be 0 <= y <= 1

HOW CAN I CORRECT THE ERRROR IN THE ABOVE ?
family=binomaial not accepted.

binomial should be quoted so R will treat it as a character string and not as a name to be evaluated.

family = "binomial"

I tried that. Bit the same error message appeared.

Hmmm. Actually try binomial unquoted but with brackets as a function call.

family = binomial()

EDIT:
The following 3 examples all work , and give same result



(model_a <- glm(formula = vs ~ mpg, family = binomial, data = mtcars))
(model_b <- glm(formula = vs ~ mpg, family = "binomial", data = mtcars))
(model_c <- glm(formula = vs ~ mpg, family = binomial(), data = mtcars))

I think your post might have led me in the wrong direction by including two different errors and I focused on the first.
If you have an error about y value being the wrong type, it's probably because it's the wrong type for logistic regression, the Independent variable should have values between 0 and 1.

Please check and make sure the type of your response variable is binary. Binary Logistic Regression require logical data type (TRUE, FALSE) or binary (0, 1).

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.