data= read_excel(file.choose())
data
library(readxl)
library(Hmisc)
library(pscl)
library(pROC)

head(data)
summary(data)

data = subset(data, select = -c(Tire))
data = subset(data, select = -c(Buy_Again))

corr= rcorr(as.matrix(data))
corr

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

null_model = glm(Purchase~1, data = data, family = binomial)
summary(null_model)


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

pR2(model)


roc_curve = roc(data$Purchase, fitted(model))
plot(roc_curve)
auc(roc_curve)

new_data1= data.frame(Wet=8,Noise=8)
new_data2= data.frame(Wet=7,Noise=7)
prob1=predict(model,newdata = new_data1, type= "response")
prob1
prob2=predict(model,newdata = new_data2, type= "response")
prob2