80.7k views
3 votes
Which of the following commands is a correct way to create a logistic regression model in R?

A) linear.model(data = my_data, method = "logistic")
B) logistic_regression(my_data, dependent_var ~ predictor_var)
C) glm(formula = response ~ predictor, family = binomial, data = my_data)
D) regression_logistic(data = my_data, Y ~ X)

1 Answer

4 votes

Final answer:

The correct command for creating a logistic regression model in R is glm(formula = response ~ predictor, family = binomial, data = my_data). This uses the glm function with the family set to binomial for logistic regression.

Step-by-step explanation:

The correct command to create a logistic regression model in R is:

C) glm(formula = response ~ predictor, family = binomial, data = my_data)

This is the standard syntax for creating a logistic regression model in R using the Generalized Linear Models (glm) function. The family argument specifies the model type, which in the case of logistic regression is binomial, because the dependent variable is binary (having two possible outcomes).

User Abdurrahman
by
8.1k points