**Predicitng the decision to buy again based on the rating of the tire performance

**Poject Objective

To investigate the ratings of Wet and Noise performace of tires on the decision to buy again.

** Question 1&2 Develop the model & Assess predictor significance

Step1 install and load required libraries

#install.packages("readxl")
#install.packages("Hmisc")
#install.packages("pscl")
#if(!require(pROC)) install.packages("pROC")

library(readxl) 
library(Hmisc)
library(pscl)
library(pROC)

Step2 import and clecan data

tire_rt <- read_excel(file.choose())


tr_rt <- subset(tire_rt, select = -c(Tire))

Step3 summarize the data

head(tr_rt)
summary(tr_rt)

Step4 Correlation analysis

corr <- rcorr(as.matrix(tr_rt))
corr

Step5 Creating the model

model <- glm(Purchase ~ Wet + Noise, data = tr_rt, family = binomial)
summary(model)

Step6 prediction

new_data1 <- data.frame(Wet = 7.0, Noise = 7.0)
new_data2 <- data.frame(Wet = 8.0, Noise = 8.0)
prediction1 <- predict(model, newdata = new_data1, type = "response")
prediction1



prediction2 <- predict(model, newdata = new_data2, type = "response")
prediction2

Step7 Predictor significance

null_model <- glm(Purchase ~ 1, data = tr_rt, family = binomial)

anova(null_model, model, test = "Chisq")

pR2(model)

roc_curve <- roc(tr_rt$Purchase, fitted(model))
plot(roc_curve)
auc(roc_curve)