159k views
1 vote
Fit a logistic regression predicting the probability that a person pur- chases Under Armour compression gear from their age. Give the logistic re- gression equation. What R code did you use to run your model?

1 Answer

5 votes

R code for fitting a logistic regression predicting the probability of purchasing Under Armour compression gear based on age:

model <- glm(Purchase ~ Age, data = your_data, family = binomial)

summary(model).

The logistic regression equation would be something like:

logit(P(Purchase))= β0+ β1 × Age.

Certainly! In R, you can use the glm function to fit a logistic regression model.

Assuming you have a dataset named your_data with a binary response variable Purchase (1 for purchase, 0 for no purchase) and a predictor variable Age, you can use the following code:

# Fitting logistic regression model

model <- glm(Purchase ~ Age, data = your_data, family = binomial)

# Displaying summary of the model

summary(model)

The logistic regression equation can be interpreted from the coefficients in the model summary.

The general form of the logistic regression equation is:

logit(P(Purchase))= β0+ β1 × Age.

Here, β0 is the intercept, β1 is the coefficient for the Age variable, and logit(P(Purchase)) is the log-odds of purchasing Under Armour compression gear.

​The output of the summary function will display the estimated coefficients and their significance levels. The coefficient for the Age variable(β 1) indicates the change in the log-odds of purchasing for a one-unit change in Age.

Make sure to replace your_data with the actual name of your dataset.

This code assumes a binary logistic regression where the response variable is binary (0 or 1).

User Kjell
by
7.0k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.

9.4m questions

12.2m answers

Categories