#Tire Rating

#Project Objective

#To determine the tires rating with 4 different categories

###Step 1: install and load

#install.packages("readxl")
#install.packages("Hmisc")
#install.packages("pscl")
#install.packages("pROC")


library(readxl)
library(Hmisc)
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
## 
##     format.pval, units
library(pscl)
## 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.
library(pROC)
## Type 'citation("pROC")' for a citation.
## 
## Attaching package: 'pROC'
## The following objects are masked from 'package:stats':
## 
##     cov, smooth, var

###Step 2: Import and Clean

#tire_data<- read_excel(file.choose())
#tire_data

#ti_data<- subset(tire_data, select = -c(Tire))

###Step 3: Summarize the data

#head(ti_data)
#summary(ti_data)

###Step 4: Feature selection

#corr<- rcorr(as.matrix(ti_data))
#corr

###Step 5: Build the Logistical regression model

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

###Step 6: Overall Model Significance

#Null
#null_model<- glm(Purchase ~ 1, data = ti_data, family = binomial)
#Liklyhood test
#anova(null_model, model, test = "Chisq")

###R-squared

#pR2(model)

###Area under the curve

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

###Predicting with New Infromation

#new_data1 <- data.frame(Wet = 7.0, Noise = 7.0, Buy_Again = 1)
#new_data2 <- data.frame(Wet = 8.0, Noise = 8.0, Buy_Again = 1)


#prob1<- predict(model,newdata = new_data1, type = "response")
#prob1 * 100
#prob2<- predict(model,newdata = new_data2, type = "response")
#prob2 * 100