The Tire Rack maintains an independent consumer survey to help drivers help each other by sharing their long-term tire experiences.
library(readxl)
library(pscl)
## Warning: package 'pscl' was built under R version 4.4.2
## Classes and Methods for R originally developed in the
## Political Science Computational Laboratory
## Department of Political Science
## Stanford University (2002-2015),
## by and under the direction of Simon Jackman.
## hurdle and zeroinfl functions by Achim Zeileis.
data <- read_excel("Class Exercise 15_TireRatings.xlsx")
model <- glm(Purchase ~ Wet + Noise, data = data, family = binomial)
summary(model)
##
## Call:
## glm(formula = Purchase ~ Wet + Noise, family = binomial, data = data)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -39.4982 12.4779 -3.165 0.00155 **
## Wet 3.3745 1.2641 2.670 0.00760 **
## Noise 1.8163 0.8312 2.185 0.02887 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 93.325 on 67 degrees of freedom
## Residual deviance: 27.530 on 65 degrees of freedom
## AIC: 33.53
##
## Number of Fisher Scoring iterations: 8
The estimated logistic regression equation has the following variables: b0 = -39.50; b1 = 3.37; b2 = 1.82. The variables are significant based on the z-test with alpha = 0.05.
pR2(model)
## fitting null model for pseudo-r2
## llh llhNull G2 McFadden r2ML r2CU
## -13.7649516 -46.6623284 65.7947536 0.7050093 0.6199946 0.8305269
The McFadden R-Squared is equal to 0.71.
coefficients <- coef(model)
intercept <- coefficients[1]
b1 <- coefficients[2]
b2 <- coefficients[3]
wet <- 8
noise <- 8
logit <- intercept + b1 * wet + b2 * noise
probability <- exp(logit) / (1 + exp(logit))
probability
## (Intercept)
## 0.8836964
The probability that a customer will probably or definitely purchase a particular tire again with a Wet performance rating of 8 and a Noise performance rating of 8 is equal to 88.37%
wet <- 7
noise <- 7
logit <- intercept + b1 * wet + b2 * noise
probability <- exp(logit) / (1 + exp(logit))
probability
## (Intercept)
## 0.04058753
The probability that a customer will probably or definitely purchase a particular tire again with a Wet performance rating of 7 and a Noise performance rating of 7 is equal to 4.06%