Homework 11 Written Doc

docx

School

Kansas State University *

*We aren’t endorsed by this school

Course

351

Subject

Industrial Engineering

Date

Jan 9, 2024

Type

docx

Pages

2

Uploaded by DoctorKoupreyMaster4297

Report
Homework 11 1. Logistic Regression a. Fit a logistic regression predicting the probability that a person purchased Under Armour gear in the last 3 years from their Age, their Age Squared, and the StephFave dummy variable. Give the logistic regression equation. What R code did you use to run your model? P(Purchase) = [e^( -2.3916584+ 0.3298781(Age) -0.0057980(AgeSquared) + 1.6872251(FaveSteph))]/[1 + e^( -2.3916584+ 0.3298781(Age) -0.0057980(AgeSquared) + 1.6872251(FaveSteph))] AgeSquared = (UnderArmour$Age)^2 UnderArmour$AgeSquared = AgeSquared lr = glm(Purchase ~ Age + AgeSquared + FaveSteph, data = UnderArmour, family = binomial(link = "logit")) summary(lr) b. Using the logistic regression, predict the probability that a 45 year old whose favorite basketball player is Stephen Curry made an Under Armour purchase. Also, predict the probability that a 65 year old whose favorite basketball player is Joel Embiid made an Under Armour purchase. i. 0.916761 or 91.6761% j. 0.004294434 or 0.4294434% numerator = exp(-2.3916584 + 0.3298781*(45) - 0.0057980*(45^2) + 1.6872251*(1)) denominator = 1 + numerator numerator/denominator numerator = exp(-2.3916584 + 0.3298781*(65) - 0.0057980*(65^2) + 1.6872251*(0)) denominator = 1 + numerator numerator/denominator c. Compute the prediction accuracy of your logistic regression model. Give the R code used to compute your prediction accuracy. 82.8% > preds = ifelse(lr$fitted.values > 0.5, 1, 0) > mean(preds == UnderArmour$Purchase) d. At the α = 0.05 significant level, for the logistic regression model, are people whose favorite basketball player is Stephen Curry significantly more likely to purchase Under Armour gear? Explain.
Yes, people whose favorite basketball player that is Stephen Curry are more likely to purchase Under Armour gear because the p-value is less than the significant level. (p-value = 2.140654e-11) 1-pnorm(6.594) 2. Linear Probability Model a. Fit a linear probability model predicting the probability that a person purchased Under Armour gear in the last 3 years from their Age, their Age Squared, and the StephFave dummy variable. Give the equation of the linear probability model. What R code did you use to run your model? P(Purchase) = -9.639e-03 + 6.213e-02(Age) - 1.054e-03(AgeSquared) + 1.894e- 01(FaveSteph) lpm = lm(Purchase ~ Age + AgeSquared + FaveSteph, data = UnderArmour) summary(lpm) b. Using the linear probability model, predict the probability that a 45 year old whose favorite basketball player is Stephen Curry made an Under Armour purchase. Also, predict the probability that a 65 year old whose favorite basketball player is Joel Embiid made an Under Armour purchase. 0.8407124 or 84.07124% -0.4252961 or 0% c. Compute the prediction accuracy of your linear probability model. Give the R code used to compute your prediction accuracy. 82.5% preds2 = ifelse(lpm$fitted.values > 0.5, 1, 0) mean(preds2 == UnderArmour$Purchase) 3. From your analysis, which model would you prefer when predicting the purchase of Under Armour gear? Why? I would prefer to use the Logistic Regression model when predicting the purchase of Under Armour because it will always give me a probability between 0-1, so there isn’t a negative percentage or an over 100% percentage.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help