- Data loading
fitnessLog <- read.table("C:/Users/keunm/Desktop/R_Prac_Data/Ellie_SourceCode/Rdata/Data/fitnessAppLog.csv", sep = ",", header = TRUE)
names(fitnessLog)[5] <- paste("Pay")
head(fitnessLog)
## Incomes GymVisits State Hours Pay
## 1 100 4 TX 9.3 Yes
## 2 50 3 CA 4.8 No
## 3 100 4 TX 8.9 Yes
## 4 100 2 NY 6.5 Yes
## 5 50 2 MD 4.2 No
## 6 80 2 CA 6.2 No
logitAnalysis <- glm(Pay ~ Hours, data = fitnessLog, family = binomial(link = "logit"))
- Let’s check data quality
par(mfrow = c(2,2))
plot(logitAnalysis)

- Logit Summary : relation between Pay ~ Fitness hours
par(mfrow = c(1,1))
#plot(fitnessLog$Incomes, fitnessLog$Pay)
summary(logitAnalysis)
##
## Call:
## glm(formula = Pay ~ Hours, family = binomial(link = "logit"),
## data = fitnessLog)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.7575 -0.5390 -0.3945 0.5452 3.1279
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -10.4147 1.9555 -5.326 1.00e-07 ***
## Hours 1.3167 0.2595 5.075 3.88e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 118.59 on 99 degrees of freedom
## Residual deviance: 72.54 on 98 degrees of freedom
## AIC: 76.54
##
## Number of Fisher Scoring iterations: 5
- Logit Summary2 : relation between Pay ~ Incomes + Gym visits
logitAnalysis2 <- glm(Pay ~ Incomes + GymVisits, data = fitnessLog, family = binomial(link = "logit"))
summary(logitAnalysis2)
##
## Call:
## glm(formula = Pay ~ Incomes + GymVisits, family = binomial(link = "logit"),
## data = fitnessLog)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.7266 -0.6008 -0.3987 0.3109 3.1981
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -11.45136 2.33997 -4.894 9.89e-07 ***
## Incomes 0.08719 0.02214 3.939 8.19e-05 ***
## GymVisits 0.99202 0.30036 3.303 0.000957 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 118.591 on 99 degrees of freedom
## Residual deviance: 75.515 on 97 degrees of freedom
## AIC: 81.515
##
## Number of Fisher Scoring iterations: 6