Logistic regression is a popular statistical model used to analyze data that has binary outcomes (i.e., two possible values such as 0/1, yes/no). It is commonly used in various fields such as healthcare, marketing, and finance.
Here is an example of how to run a logistic regression in R using the built-in dataset called mtcars
:
174 chars9 lines
In this example, we fit a logistic regression model to predict the vs
variable (engine type, V-shaped or straight) using the mpg
(miles per gallon), hp
(horsepower), and wt
(weight) variables from the mtcars
dataset. We specify the family
argument as binomial
since logistic regression is a type of binomial regression.
The summary()
function can be used to obtain a summary of the model parameters, including the coefficients and their standard errors, the deviance of the model, and goodness-of-fit measures such as the AIC and BIC.
gistlibby LogSnag