Hi all! In this section of predictive analysis, we will revisit logistic regression.

Download Fraud1.csv here

fraud <- read.csv("Fraud1.csv")
str(fraud)
## 'data.frame':    5175 obs. of  33 variables:
##  $ Month               : num  7 7 7 11 11 11 11 11 12 12 ...
##  $ WeekOfMonth         : num  1 3 4 2 2 3 4 5 1 1 ...
##  $ DayOfWeek           : num  6 7 6 4 5 2 4 1 5 1 ...
##  $ Make                : num  7 7 7 7 18 3 1 10 7 18 ...
##  $ AccidentArea        : num  2 1 2 2 2 2 1 2 1 1 ...
##  $ DayOfWeekClaimed    : num  2 3 3 5 2 3 2 3 5 2 ...
##  $ MonthClaimed        : num  9 1 8 1 1 1 1 12 12 5 ...
##  $ WeekOfMonthClaimed  : num  4 4 2 3 1 2 2 1 3 3 ...
##  $ Sex                 : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ MaritalStatus       : num  1 2 2 1 2 2 2 1 1 2 ...
##  $ Age                 : num  0 21 50 34 38 31 56 68 0 39 ...
##  $ Fault               : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ PolicyType          : num  1 5 2 5 2 7 7 1 1 1 ...
##  $ VehicleCategory     : num  1 2 1 2 1 3 3 1 1 1 ...
##  $ VehiclePrice        : num  6 6 1 6 1 6 6 1 6 2 ...
##  $ FraudFound          : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ PolicyNumber        : num  29 53 54 95 97 101 114 119 120 148 ...
##  $ RepNumber           : num  9 4 13 7 7 2 10 9 7 1 ...
##  $ Deductible          : num  400 400 400 400 400 400 400 400 400 400 ...
##  $ DriverRating        : num  1 4 1 3 2 1 2 3 3 3 ...
##  $ Days.Policy.Accident: num  5 5 5 5 5 5 5 5 5 5 ...
##  $ Days.Policy.Claim   : num  5 5 5 5 5 5 5 5 5 5 ...
##  $ PastNumberOfClaims  : num  0 0 0 0 1 3 0 2 0 0 ...
##  $ AgeOfVehicle        : num  1 4 8 7 7 7 8 5 1 8 ...
##  $ AgeOfPolicyHolder   : num  1 4 7 5 6 5 8 9 1 6 ...
##  $ PoliceReportFiled   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ WitnessPresent      : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ AgentType           : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ NumberOfSuppliments : num  0 2 2 2 0 3 0 0 0 3 ...
##  $ AddressChange.Claim : num  0 0 0 0 0 0 0 0 0 1 ...
##  $ NumberOfCars        : num  1 1 1 1 1 1 1 1 1 2 ...
##  $ Year                : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ BasePolicy          : num  1 2 2 2 2 1 1 1 1 1 ...
table(fraud$FraudFound)
## 
##    0    1 
## 4252  923
fraud$PolicyNumber <- NULL
fit <- glm(FraudFound ~ ., family = "binomial", data = fraud)
summary(fit)
## 
## Call:
## glm(formula = FraudFound ~ ., family = "binomial", data = fraud)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.5295  -0.7575  -0.2523  -0.1849   3.4550  
## 
## Coefficients:
##                        Estimate Std. Error z value Pr(>|z|)    
## (Intercept)           0.6798679  1.8734010   0.363 0.716675    
## Month                -0.0186249  0.0190395  -0.978 0.327964    
## WeekOfMonth          -0.0355307  0.0322003  -1.103 0.269842    
## DayOfWeek             0.0092370  0.0202374   0.456 0.648078    
## Make                 -0.0080926  0.0078994  -1.024 0.305620    
## AccidentArea         -0.1350649  0.1173466  -1.151 0.249736    
## DayOfWeekClaimed      0.0181823  0.0278706   0.652 0.514156    
## MonthClaimed         -0.0158506  0.0193188  -0.820 0.411946    
## WeekOfMonthClaimed    0.0303371  0.0333776   0.909 0.363400    
## Sex                   0.2048348  0.1247042   1.643 0.100473    
## MaritalStatus         0.0734411  0.0952873   0.771 0.440865    
## Age                  -0.0105968  0.0130398  -0.813 0.416416    
## Fault                 2.6445394  0.1744383  15.160  < 2e-16 ***
## PolicyType            0.6570563  0.0795770   8.257  < 2e-16 ***
## VehicleCategory      -2.0707754  0.2142786  -9.664  < 2e-16 ***
## VehiclePrice          0.0468513  0.0258990   1.809 0.070451 .  
## RepNumber            -0.0146515  0.0087868  -1.667 0.095428 .  
## Deductible            0.0018522  0.0008554   2.165 0.030369 *  
## DriverRating          0.0290115  0.0359580   0.807 0.419773    
## Days.Policy.Accident -0.2070811  0.1283182  -1.614 0.106569    
## Days.Policy.Claim    -0.1621159  0.3838761  -0.422 0.672796    
## PastNumberOfClaims   -0.0040028  0.0428002  -0.094 0.925489    
## AgeOfVehicle         -0.0648867  0.0436543  -1.486 0.137180    
## AgeOfPolicyHolder     0.0576097  0.1351392   0.426 0.669890    
## PoliceReportFiled    -0.5822621  0.2915118  -1.997 0.045783 *  
## WitnessPresent       -0.0646361  0.6987097  -0.093 0.926295    
## AgentType             0.8104724  0.5377146   1.507 0.131746    
## NumberOfSuppliments  -0.0425643  0.0341325  -1.247 0.212385    
## AddressChange.Claim   0.1756352  0.0479342   3.664 0.000248 ***
## NumberOfCars         -0.1408564  0.1181647  -1.192 0.233248    
## Year                 -0.0927106  0.0510623  -1.816 0.069426 .  
## BasePolicy           -1.1778804  0.0781402 -15.074  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 4853  on 5174  degrees of freedom
## Residual deviance: 3835  on 5143  degrees of freedom
## AIC: 3899
## 
## Number of Fisher Scoring iterations: 6
backwards <- step(fit)
## Start:  AIC=3899.05
## FraudFound ~ Month + WeekOfMonth + DayOfWeek + Make + AccidentArea + 
##     DayOfWeekClaimed + MonthClaimed + WeekOfMonthClaimed + Sex + 
##     MaritalStatus + Age + Fault + PolicyType + VehicleCategory + 
##     VehiclePrice + RepNumber + Deductible + DriverRating + Days.Policy.Accident + 
##     Days.Policy.Claim + PastNumberOfClaims + AgeOfVehicle + AgeOfPolicyHolder + 
##     PoliceReportFiled + WitnessPresent + AgentType + NumberOfSuppliments + 
##     AddressChange.Claim + NumberOfCars + Year + BasePolicy
## 
##                        Df Deviance    AIC
## - WitnessPresent        1   3835.1 3897.1
## - PastNumberOfClaims    1   3835.1 3897.1
## - Days.Policy.Claim     1   3835.2 3897.2
## - AgeOfPolicyHolder     1   3835.2 3897.2
## - DayOfWeek             1   3835.3 3897.3
## - DayOfWeekClaimed      1   3835.5 3897.5
## - MaritalStatus         1   3835.6 3897.6
## - DriverRating          1   3835.7 3897.7
## - Age                   1   3835.7 3897.7
## - MonthClaimed          1   3835.7 3897.7
## - WeekOfMonthClaimed    1   3835.9 3897.9
## - Month                 1   3836.0 3898.0
## - Make                  1   3836.1 3898.1
## - WeekOfMonth           1   3836.3 3898.3
## - AccidentArea          1   3836.4 3898.4
## - NumberOfCars          1   3836.5 3898.5
## - NumberOfSuppliments   1   3836.6 3898.6
## <none>                      3835.0 3899.0
## - AgeOfVehicle          1   3837.2 3899.2
## - Days.Policy.Accident  1   3837.6 3899.6
## - Sex                   1   3837.8 3899.8
## - AgentType             1   3837.8 3899.8
## - RepNumber             1   3837.8 3899.8
## - VehiclePrice          1   3838.3 3900.3
## - Year                  1   3838.4 3900.4
## - PoliceReportFiled     1   3839.5 3901.5
## - Deductible            1   3839.5 3901.5
## - AddressChange.Claim   1   3848.3 3910.3
## - PolicyType            1   3910.7 3972.7
## - VehicleCategory       1   3947.1 4009.1
## - BasePolicy            1   4102.7 4164.7
## - Fault                 1   4280.9 4342.9
## 
## Step:  AIC=3897.06
## FraudFound ~ Month + WeekOfMonth + DayOfWeek + Make + AccidentArea + 
##     DayOfWeekClaimed + MonthClaimed + WeekOfMonthClaimed + Sex + 
##     MaritalStatus + Age + Fault + PolicyType + VehicleCategory + 
##     VehiclePrice + RepNumber + Deductible + DriverRating + Days.Policy.Accident + 
##     Days.Policy.Claim + PastNumberOfClaims + AgeOfVehicle + AgeOfPolicyHolder + 
##     PoliceReportFiled + AgentType + NumberOfSuppliments + AddressChange.Claim + 
##     NumberOfCars + Year + BasePolicy
## 
##                        Df Deviance    AIC
## - PastNumberOfClaims    1   3835.1 3895.1
## - Days.Policy.Claim     1   3835.2 3895.2
## - AgeOfPolicyHolder     1   3835.2 3895.2
## - DayOfWeek             1   3835.3 3895.3
## - DayOfWeekClaimed      1   3835.5 3895.5
## - MaritalStatus         1   3835.6 3895.6
## - DriverRating          1   3835.7 3895.7
## - Age                   1   3835.7 3895.7
## - MonthClaimed          1   3835.7 3895.7
## - WeekOfMonthClaimed    1   3835.9 3895.9
## - Month                 1   3836.0 3896.0
## - Make                  1   3836.1 3896.1
## - WeekOfMonth           1   3836.3 3896.3
## - AccidentArea          1   3836.4 3896.4
## - NumberOfCars          1   3836.5 3896.5
## - NumberOfSuppliments   1   3836.6 3896.6
## <none>                      3835.1 3897.1
## - AgeOfVehicle          1   3837.2 3897.2
## - Days.Policy.Accident  1   3837.6 3897.6
## - Sex                   1   3837.8 3897.8
## - AgentType             1   3837.8 3897.8
## - RepNumber             1   3837.8 3897.8
## - VehiclePrice          1   3838.3 3898.3
## - Year                  1   3838.4 3898.4
## - Deductible            1   3839.6 3899.6
## - PoliceReportFiled     1   3839.7 3899.7
## - AddressChange.Claim   1   3848.3 3908.3
## - PolicyType            1   3910.8 3970.8
## - VehicleCategory       1   3947.2 4007.2
## - BasePolicy            1   4102.7 4162.7
## - Fault                 1   4281.3 4341.3
## 
## Step:  AIC=3895.07
## FraudFound ~ Month + WeekOfMonth + DayOfWeek + Make + AccidentArea + 
##     DayOfWeekClaimed + MonthClaimed + WeekOfMonthClaimed + Sex + 
##     MaritalStatus + Age + Fault + PolicyType + VehicleCategory + 
##     VehiclePrice + RepNumber + Deductible + DriverRating + Days.Policy.Accident + 
##     Days.Policy.Claim + AgeOfVehicle + AgeOfPolicyHolder + PoliceReportFiled + 
##     AgentType + NumberOfSuppliments + AddressChange.Claim + NumberOfCars + 
##     Year + BasePolicy
## 
##                        Df Deviance    AIC
## - AgeOfPolicyHolder     1   3835.2 3893.2
## - Days.Policy.Claim     1   3835.2 3893.2
## - DayOfWeek             1   3835.3 3893.3
## - DayOfWeekClaimed      1   3835.5 3893.5
## - MaritalStatus         1   3835.7 3893.7
## - DriverRating          1   3835.7 3893.7
## - Age                   1   3835.7 3893.7
## - MonthClaimed          1   3835.7 3893.7
## - WeekOfMonthClaimed    1   3835.9 3893.9
## - Month                 1   3836.0 3894.0
## - Make                  1   3836.1 3894.1
## - WeekOfMonth           1   3836.3 3894.3
## - AccidentArea          1   3836.4 3894.4
## - NumberOfCars          1   3836.5 3894.5
## - NumberOfSuppliments   1   3836.7 3894.7
## <none>                      3835.1 3895.1
## - AgeOfVehicle          1   3837.3 3895.3
## - Days.Policy.Accident  1   3837.6 3895.6
## - Sex                   1   3837.8 3895.8
## - AgentType             1   3837.8 3895.8
## - RepNumber             1   3837.8 3895.8
## - VehiclePrice          1   3838.3 3896.3
## - Year                  1   3838.4 3896.4
## - Deductible            1   3839.6 3897.6
## - PoliceReportFiled     1   3839.7 3897.7
## - AddressChange.Claim   1   3848.3 3906.3
## - PolicyType            1   3911.6 3969.6
## - VehicleCategory       1   3948.8 4006.8
## - BasePolicy            1   4117.9 4175.9
## - Fault                 1   4281.5 4339.5
## 
## Step:  AIC=3893.24
## FraudFound ~ Month + WeekOfMonth + DayOfWeek + Make + AccidentArea + 
##     DayOfWeekClaimed + MonthClaimed + WeekOfMonthClaimed + Sex + 
##     MaritalStatus + Age + Fault + PolicyType + VehicleCategory + 
##     VehiclePrice + RepNumber + Deductible + DriverRating + Days.Policy.Accident + 
##     Days.Policy.Claim + AgeOfVehicle + PoliceReportFiled + AgentType + 
##     NumberOfSuppliments + AddressChange.Claim + NumberOfCars + 
##     Year + BasePolicy
## 
##                        Df Deviance    AIC
## - Days.Policy.Claim     1   3835.4 3891.4
## - DayOfWeek             1   3835.4 3891.4
## - DayOfWeekClaimed      1   3835.7 3891.7
## - DriverRating          1   3835.9 3891.9
## - MonthClaimed          1   3835.9 3891.9
## - MaritalStatus         1   3835.9 3891.9
## - WeekOfMonthClaimed    1   3836.1 3892.1
## - Month                 1   3836.2 3892.2
## - Make                  1   3836.3 3892.3
## - WeekOfMonth           1   3836.5 3892.5
## - AccidentArea          1   3836.6 3892.6
## - NumberOfCars          1   3836.7 3892.7
## - Age                   1   3836.8 3892.8
## - NumberOfSuppliments   1   3836.9 3892.9
## <none>                      3835.2 3893.2
## - AgeOfVehicle          1   3837.3 3893.3
## - Days.Policy.Accident  1   3837.8 3893.8
## - Sex                   1   3837.9 3893.9
## - RepNumber             1   3838.0 3894.0
## - AgentType             1   3838.0 3894.0
## - VehiclePrice          1   3838.4 3894.4
## - Year                  1   3838.5 3894.5
## - Deductible            1   3839.7 3895.7
## - PoliceReportFiled     1   3839.8 3895.8
## - AddressChange.Claim   1   3848.5 3904.5
## - PolicyType            1   3912.1 3968.1
## - VehicleCategory       1   3949.0 4005.0
## - BasePolicy            1   4118.3 4174.3
## - Fault                 1   4281.7 4337.7
## 
## Step:  AIC=3891.42
## FraudFound ~ Month + WeekOfMonth + DayOfWeek + Make + AccidentArea + 
##     DayOfWeekClaimed + MonthClaimed + WeekOfMonthClaimed + Sex + 
##     MaritalStatus + Age + Fault + PolicyType + VehicleCategory + 
##     VehiclePrice + RepNumber + Deductible + DriverRating + Days.Policy.Accident + 
##     AgeOfVehicle + PoliceReportFiled + AgentType + NumberOfSuppliments + 
##     AddressChange.Claim + NumberOfCars + Year + BasePolicy
## 
##                        Df Deviance    AIC
## - DayOfWeek             1   3835.6 3889.6
## - DayOfWeekClaimed      1   3835.8 3889.8
## - MonthClaimed          1   3836.1 3890.1
## - DriverRating          1   3836.1 3890.1
## - MaritalStatus         1   3836.1 3890.1
## - WeekOfMonthClaimed    1   3836.2 3890.2
## - Month                 1   3836.4 3890.4
## - Make                  1   3836.5 3890.5
## - WeekOfMonth           1   3836.6 3890.6
## - AccidentArea          1   3836.8 3890.8
## - NumberOfCars          1   3836.8 3890.8
## - Age                   1   3837.0 3891.0
## - NumberOfSuppliments   1   3837.1 3891.1
## <none>                      3835.4 3891.4
## - AgeOfVehicle          1   3837.5 3891.5
## - Sex                   1   3838.1 3892.1
## - RepNumber             1   3838.2 3892.2
## - AgentType             1   3838.2 3892.2
## - VehiclePrice          1   3838.5 3892.5
## - Year                  1   3838.7 3892.7
## - Days.Policy.Accident  1   3839.8 3893.8
## - Deductible            1   3839.9 3893.9
## - PoliceReportFiled     1   3840.0 3894.0
## - AddressChange.Claim   1   3848.6 3902.6
## - PolicyType            1   3912.3 3966.3
## - VehicleCategory       1   3949.2 4003.2
## - BasePolicy            1   4118.3 4172.3
## - Fault                 1   4281.7 4335.7
## 
## Step:  AIC=3889.61
## FraudFound ~ Month + WeekOfMonth + Make + AccidentArea + DayOfWeekClaimed + 
##     MonthClaimed + WeekOfMonthClaimed + Sex + MaritalStatus + 
##     Age + Fault + PolicyType + VehicleCategory + VehiclePrice + 
##     RepNumber + Deductible + DriverRating + Days.Policy.Accident + 
##     AgeOfVehicle + PoliceReportFiled + AgentType + NumberOfSuppliments + 
##     AddressChange.Claim + NumberOfCars + Year + BasePolicy
## 
##                        Df Deviance    AIC
## - DayOfWeekClaimed      1   3836.0 3888.0
## - MonthClaimed          1   3836.3 3888.3
## - DriverRating          1   3836.3 3888.3
## - MaritalStatus         1   3836.3 3888.3
## - WeekOfMonthClaimed    1   3836.4 3888.4
## - Month                 1   3836.6 3888.6
## - Make                  1   3836.7 3888.7
## - WeekOfMonth           1   3836.9 3888.9
## - AccidentArea          1   3837.0 3889.0
## - NumberOfCars          1   3837.1 3889.1
## - NumberOfSuppliments   1   3837.2 3889.2
## - Age                   1   3837.2 3889.2
## <none>                      3835.6 3889.6
## - AgeOfVehicle          1   3837.7 3889.7
## - Sex                   1   3838.3 3890.3
## - RepNumber             1   3838.4 3890.4
## - AgentType             1   3838.4 3890.4
## - VehiclePrice          1   3838.7 3890.7
## - Year                  1   3838.8 3890.8
## - Days.Policy.Accident  1   3840.0 3892.0
## - Deductible            1   3840.1 3892.1
## - PoliceReportFiled     1   3840.2 3892.2
## - AddressChange.Claim   1   3848.9 3900.9
## - PolicyType            1   3912.7 3964.7
## - VehicleCategory       1   3950.4 4002.4
## - BasePolicy            1   4118.7 4170.7
## - Fault                 1   4282.3 4334.3
## 
## Step:  AIC=3887.99
## FraudFound ~ Month + WeekOfMonth + Make + AccidentArea + MonthClaimed + 
##     WeekOfMonthClaimed + Sex + MaritalStatus + Age + Fault + 
##     PolicyType + VehicleCategory + VehiclePrice + RepNumber + 
##     Deductible + DriverRating + Days.Policy.Accident + AgeOfVehicle + 
##     PoliceReportFiled + AgentType + NumberOfSuppliments + AddressChange.Claim + 
##     NumberOfCars + Year + BasePolicy
## 
##                        Df Deviance    AIC
## - MonthClaimed          1   3836.6 3886.6
## - DriverRating          1   3836.7 3886.7
## - MaritalStatus         1   3836.7 3886.7
## - WeekOfMonthClaimed    1   3836.8 3886.8
## - Month                 1   3837.0 3887.0
## - Make                  1   3837.1 3887.1
## - WeekOfMonth           1   3837.3 3887.3
## - AccidentArea          1   3837.4 3887.4
## - NumberOfCars          1   3837.5 3887.5
## - Age                   1   3837.6 3887.6
## - NumberOfSuppliments   1   3837.6 3887.6
## <none>                      3836.0 3888.0
## - AgeOfVehicle          1   3838.0 3888.0
## - AgentType             1   3838.8 3888.8
## - Sex                   1   3838.8 3888.8
## - RepNumber             1   3838.8 3888.8
## - VehiclePrice          1   3839.1 3889.1
## - Year                  1   3839.2 3889.2
## - Days.Policy.Accident  1   3840.5 3890.5
## - Deductible            1   3840.5 3890.5
## - PoliceReportFiled     1   3840.6 3890.6
## - AddressChange.Claim   1   3849.3 3899.3
## - PolicyType            1   3913.2 3963.2
## - VehicleCategory       1   3950.8 4000.8
## - BasePolicy            1   4119.6 4169.6
## - Fault                 1   4283.0 4333.0
## 
## Step:  AIC=3886.6
## FraudFound ~ Month + WeekOfMonth + Make + AccidentArea + WeekOfMonthClaimed + 
##     Sex + MaritalStatus + Age + Fault + PolicyType + VehicleCategory + 
##     VehiclePrice + RepNumber + Deductible + DriverRating + Days.Policy.Accident + 
##     AgeOfVehicle + PoliceReportFiled + AgentType + NumberOfSuppliments + 
##     AddressChange.Claim + NumberOfCars + Year + BasePolicy
## 
##                        Df Deviance    AIC
## - DriverRating          1   3837.3 3885.3
## - MaritalStatus         1   3837.3 3885.3
## - WeekOfMonthClaimed    1   3837.4 3885.4
## - Make                  1   3837.6 3885.6
## - WeekOfMonth           1   3837.8 3885.8
## - AccidentArea          1   3837.9 3885.9
## - NumberOfCars          1   3838.1 3886.1
## - Age                   1   3838.3 3886.3
## - NumberOfSuppliments   1   3838.3 3886.3
## <none>                      3836.6 3886.6
## - AgeOfVehicle          1   3838.7 3886.7
## - Sex                   1   3839.4 3887.4
## - AgentType             1   3839.4 3887.4
## - RepNumber             1   3839.4 3887.4
## - VehiclePrice          1   3839.8 3887.8
## - Year                  1   3840.0 3888.0
## - Days.Policy.Accident  1   3841.0 3889.0
## - Deductible            1   3841.1 3889.1
## - PoliceReportFiled     1   3841.3 3889.3
## - Month                 1   3843.5 3891.5
## - AddressChange.Claim   1   3850.0 3898.0
## - PolicyType            1   3913.5 3961.5
## - VehicleCategory       1   3951.0 3999.0
## - BasePolicy            1   4121.5 4169.5
## - Fault                 1   4283.3 4331.3
## 
## Step:  AIC=3885.26
## FraudFound ~ Month + WeekOfMonth + Make + AccidentArea + WeekOfMonthClaimed + 
##     Sex + MaritalStatus + Age + Fault + PolicyType + VehicleCategory + 
##     VehiclePrice + RepNumber + Deductible + Days.Policy.Accident + 
##     AgeOfVehicle + PoliceReportFiled + AgentType + NumberOfSuppliments + 
##     AddressChange.Claim + NumberOfCars + Year + BasePolicy
## 
##                        Df Deviance    AIC
## - MaritalStatus         1   3838.0 3884.0
## - WeekOfMonthClaimed    1   3838.0 3884.0
## - Make                  1   3838.3 3884.3
## - WeekOfMonth           1   3838.6 3884.6
## - AccidentArea          1   3838.6 3884.6
## - NumberOfCars          1   3838.8 3884.8
## - NumberOfSuppliments   1   3838.9 3884.9
## - Age                   1   3838.9 3884.9
## <none>                      3837.3 3885.3
## - AgeOfVehicle          1   3839.4 3885.4
## - AgentType             1   3840.0 3886.0
## - RepNumber             1   3840.1 3886.1
## - Sex                   1   3840.1 3886.1
## - VehiclePrice          1   3840.4 3886.4
## - Year                  1   3840.7 3886.7
## - Days.Policy.Accident  1   3841.7 3887.7
## - Deductible            1   3841.7 3887.7
## - PoliceReportFiled     1   3841.9 3887.9
## - Month                 1   3844.1 3890.1
## - AddressChange.Claim   1   3850.6 3896.6
## - PolicyType            1   3914.1 3960.1
## - VehicleCategory       1   3951.6 3997.6
## - BasePolicy            1   4122.2 4168.2
## - Fault                 1   4284.0 4330.0
## 
## Step:  AIC=3883.98
## FraudFound ~ Month + WeekOfMonth + Make + AccidentArea + WeekOfMonthClaimed + 
##     Sex + Age + Fault + PolicyType + VehicleCategory + VehiclePrice + 
##     RepNumber + Deductible + Days.Policy.Accident + AgeOfVehicle + 
##     PoliceReportFiled + AgentType + NumberOfSuppliments + AddressChange.Claim + 
##     NumberOfCars + Year + BasePolicy
## 
##                        Df Deviance    AIC
## - WeekOfMonthClaimed    1   3838.8 3882.8
## - Make                  1   3839.0 3883.0
## - AccidentArea          1   3839.3 3883.3
## - WeekOfMonth           1   3839.3 3883.3
## - Age                   1   3839.3 3883.3
## - NumberOfCars          1   3839.5 3883.5
## - AgeOfVehicle          1   3839.7 3883.7
## - NumberOfSuppliments   1   3839.7 3883.7
## <none>                      3838.0 3884.0
## - AgentType             1   3840.6 3884.6
## - RepNumber             1   3840.8 3884.8
## - Sex                   1   3840.8 3884.8
## - VehiclePrice          1   3841.3 3885.3
## - Year                  1   3841.5 3885.5
## - Days.Policy.Accident  1   3842.4 3886.4
## - Deductible            1   3842.4 3886.4
## - PoliceReportFiled     1   3842.6 3886.6
## - Month                 1   3844.7 3888.7
## - AddressChange.Claim   1   3851.2 3895.2
## - PolicyType            1   3914.7 3958.7
## - VehicleCategory       1   3952.7 3996.7
## - BasePolicy            1   4122.6 4166.6
## - Fault                 1   4284.8 4328.8
## 
## Step:  AIC=3882.77
## FraudFound ~ Month + WeekOfMonth + Make + AccidentArea + Sex + 
##     Age + Fault + PolicyType + VehicleCategory + VehiclePrice + 
##     RepNumber + Deductible + Days.Policy.Accident + AgeOfVehicle + 
##     PoliceReportFiled + AgentType + NumberOfSuppliments + AddressChange.Claim + 
##     NumberOfCars + Year + BasePolicy
## 
##                        Df Deviance    AIC
## - WeekOfMonth           1   3839.7 3881.7
## - Make                  1   3839.9 3881.9
## - AccidentArea          1   3840.0 3882.0
## - Age                   1   3840.1 3882.1
## - NumberOfCars          1   3840.2 3882.2
## - NumberOfSuppliments   1   3840.5 3882.5
## - AgeOfVehicle          1   3840.5 3882.5
## <none>                      3838.8 3882.8
## - AgentType             1   3841.4 3883.4
## - RepNumber             1   3841.5 3883.5
## - Sex                   1   3841.6 3883.6
## - VehiclePrice          1   3842.1 3884.1
## - Year                  1   3842.2 3884.2
## - Days.Policy.Accident  1   3843.0 3885.0
## - Deductible            1   3843.2 3885.2
## - PoliceReportFiled     1   3843.4 3885.4
## - Month                 1   3845.4 3887.4
## - AddressChange.Claim   1   3851.9 3893.9
## - PolicyType            1   3915.5 3957.5
## - VehicleCategory       1   3953.4 3995.4
## - BasePolicy            1   4123.1 4165.1
## - Fault                 1   4284.9 4326.9
## 
## Step:  AIC=3881.71
## FraudFound ~ Month + Make + AccidentArea + Sex + Age + Fault + 
##     PolicyType + VehicleCategory + VehiclePrice + RepNumber + 
##     Deductible + Days.Policy.Accident + AgeOfVehicle + PoliceReportFiled + 
##     AgentType + NumberOfSuppliments + AddressChange.Claim + NumberOfCars + 
##     Year + BasePolicy
## 
##                        Df Deviance    AIC
## - Make                  1   3840.7 3880.7
## - AccidentArea          1   3841.0 3881.0
## - Age                   1   3841.0 3881.0
## - NumberOfCars          1   3841.1 3881.1
## - AgeOfVehicle          1   3841.4 3881.4
## - NumberOfSuppliments   1   3841.5 3881.5
## <none>                      3839.7 3881.7
## - AgentType             1   3842.3 3882.3
## - RepNumber             1   3842.5 3882.5
## - Sex                   1   3842.6 3882.6
## - Year                  1   3843.1 3883.1
## - VehiclePrice          1   3843.1 3883.1
## - Days.Policy.Accident  1   3843.8 3883.8
## - PoliceReportFiled     1   3844.4 3884.4
## - Deductible            1   3844.4 3884.4
## - Month                 1   3846.4 3886.4
## - AddressChange.Claim   1   3852.8 3892.8
## - PolicyType            1   3916.5 3956.5
## - VehicleCategory       1   3954.6 3994.6
## - BasePolicy            1   4123.5 4163.5
## - Fault                 1   4287.0 4327.0
## 
## Step:  AIC=3880.75
## FraudFound ~ Month + AccidentArea + Sex + Age + Fault + PolicyType + 
##     VehicleCategory + VehiclePrice + RepNumber + Deductible + 
##     Days.Policy.Accident + AgeOfVehicle + PoliceReportFiled + 
##     AgentType + NumberOfSuppliments + AddressChange.Claim + NumberOfCars + 
##     Year + BasePolicy
## 
##                        Df Deviance    AIC
## - AccidentArea          1   3842.0 3880.0
## - Age                   1   3842.1 3880.1
## - NumberOfCars          1   3842.3 3880.3
## - AgeOfVehicle          1   3842.4 3880.4
## - NumberOfSuppliments   1   3842.6 3880.6
## <none>                      3840.7 3880.7
## - AgentType             1   3843.4 3881.4
## - RepNumber             1   3843.6 3881.6
## - Sex                   1   3843.7 3881.7
## - Year                  1   3844.1 3882.1
## - Days.Policy.Accident  1   3844.8 3882.8
## - VehiclePrice          1   3845.2 3883.2
## - PoliceReportFiled     1   3845.4 3883.4
## - Deductible            1   3845.4 3883.4
## - Month                 1   3847.6 3885.6
## - AddressChange.Claim   1   3854.0 3892.0
## - PolicyType            1   3918.9 3956.9
## - VehicleCategory       1   3955.7 3993.7
## - BasePolicy            1   4125.5 4163.5
## - Fault                 1   4288.2 4326.2
## 
## Step:  AIC=3880.01
## FraudFound ~ Month + Sex + Age + Fault + PolicyType + VehicleCategory + 
##     VehiclePrice + RepNumber + Deductible + Days.Policy.Accident + 
##     AgeOfVehicle + PoliceReportFiled + AgentType + NumberOfSuppliments + 
##     AddressChange.Claim + NumberOfCars + Year + BasePolicy
## 
##                        Df Deviance    AIC
## - Age                   1   3843.3 3879.3
## - NumberOfCars          1   3843.5 3879.5
## - AgeOfVehicle          1   3843.8 3879.8
## - NumberOfSuppliments   1   3843.8 3879.8
## <none>                      3842.0 3880.0
## - AgentType             1   3844.7 3880.7
## - RepNumber             1   3844.8 3880.8
## - Sex                   1   3845.0 3881.0
## - Year                  1   3845.5 3881.5
## - Days.Policy.Accident  1   3846.0 3882.0
## - VehiclePrice          1   3846.4 3882.4
## - Deductible            1   3846.6 3882.6
## - PoliceReportFiled     1   3846.8 3882.8
## - Month                 1   3848.8 3884.8
## - AddressChange.Claim   1   3855.4 3891.4
## - PolicyType            1   3921.0 3957.0
## - VehicleCategory       1   3958.1 3994.1
## - BasePolicy            1   4127.6 4163.6
## - Fault                 1   4291.2 4327.2
## 
## Step:  AIC=3879.34
## FraudFound ~ Month + Sex + Fault + PolicyType + VehicleCategory + 
##     VehiclePrice + RepNumber + Deductible + Days.Policy.Accident + 
##     AgeOfVehicle + PoliceReportFiled + AgentType + NumberOfSuppliments + 
##     AddressChange.Claim + NumberOfCars + Year + BasePolicy
## 
##                        Df Deviance    AIC
## - NumberOfCars          1   3844.9 3878.9
## - NumberOfSuppliments   1   3845.2 3879.2
## <none>                      3843.3 3879.3
## - AgentType             1   3846.1 3880.1
## - RepNumber             1   3846.1 3880.1
## - Sex                   1   3846.4 3880.4
## - Year                  1   3847.0 3881.0
## - Days.Policy.Accident  1   3847.4 3881.4
## - VehiclePrice          1   3847.6 3881.6
## - Deductible            1   3847.9 3881.9
## - PoliceReportFiled     1   3848.1 3882.1
## - Month                 1   3850.1 3884.1
## - AgeOfVehicle          1   3851.8 3885.8
## - AddressChange.Claim   1   3856.8 3890.8
## - PolicyType            1   3923.1 3957.1
## - VehicleCategory       1   3960.7 3994.7
## - BasePolicy            1   4127.7 4161.7
## - Fault                 1   4292.6 4326.6
## 
## Step:  AIC=3878.89
## FraudFound ~ Month + Sex + Fault + PolicyType + VehicleCategory + 
##     VehiclePrice + RepNumber + Deductible + Days.Policy.Accident + 
##     AgeOfVehicle + PoliceReportFiled + AgentType + NumberOfSuppliments + 
##     AddressChange.Claim + Year + BasePolicy
## 
##                        Df Deviance    AIC
## - NumberOfSuppliments   1   3846.7 3878.7
## <none>                      3844.9 3878.9
## - RepNumber             1   3847.5 3879.5
## - AgentType             1   3847.7 3879.7
## - Sex                   1   3847.9 3879.9
## - Year                  1   3848.6 3880.6
## - Days.Policy.Accident  1   3848.8 3880.8
## - VehiclePrice          1   3849.2 3881.2
## - PoliceReportFiled     1   3849.6 3881.6
## - Deductible            1   3849.8 3881.8
## - Month                 1   3851.6 3883.6
## - AgeOfVehicle          1   3853.7 3885.7
## - AddressChange.Claim   1   3857.0 3889.0
## - PolicyType            1   3924.5 3956.5
## - VehicleCategory       1   3962.2 3994.2
## - BasePolicy            1   4128.6 4160.6
## - Fault                 1   4292.6 4324.6
## 
## Step:  AIC=3878.74
## FraudFound ~ Month + Sex + Fault + PolicyType + VehicleCategory + 
##     VehiclePrice + RepNumber + Deductible + Days.Policy.Accident + 
##     AgeOfVehicle + PoliceReportFiled + AgentType + AddressChange.Claim + 
##     Year + BasePolicy
## 
##                        Df Deviance    AIC
## <none>                      3846.7 3878.7
## - RepNumber             1   3849.4 3879.4
## - AgentType             1   3849.7 3879.7
## - Sex                   1   3849.9 3879.9
## - Year                  1   3850.7 3880.7
## - VehiclePrice          1   3851.0 3881.0
## - Days.Policy.Accident  1   3851.1 3881.1
## - PoliceReportFiled     1   3851.6 3881.6
## - Deductible            1   3851.8 3881.8
## - Month                 1   3853.5 3883.5
## - AgeOfVehicle          1   3857.1 3887.1
## - AddressChange.Claim   1   3858.9 3888.9
## - PolicyType            1   3927.2 3957.2
## - VehicleCategory       1   3964.3 3994.3
## - BasePolicy            1   4133.7 4163.7
## - Fault                 1   4294.9 4324.9
summary(backwards)
## 
## Call:
## glm(formula = FraudFound ~ Month + Sex + Fault + PolicyType + 
##     VehicleCategory + VehiclePrice + RepNumber + Deductible + 
##     Days.Policy.Accident + AgeOfVehicle + PoliceReportFiled + 
##     AgentType + AddressChange.Claim + Year + BasePolicy, family = "binomial", 
##     data = fraud)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.5684  -0.7649  -0.2526  -0.1891   3.3457  
## 
## Coefficients:
##                        Estimate Std. Error z value Pr(>|z|)    
## (Intercept)          -0.2714784  0.8896975  -0.305 0.760263    
## Month                -0.0303647  0.0117194  -2.591 0.009570 ** 
## Sex                   0.2174556  0.1239603   1.754 0.079390 .  
## Fault                 2.6372820  0.1739285  15.163  < 2e-16 ***
## PolicyType            0.6700298  0.0789213   8.490  < 2e-16 ***
## VehicleCategory      -2.0958253  0.2125361  -9.861  < 2e-16 ***
## VehiclePrice          0.0518040  0.0250283   2.070 0.038469 *  
## RepNumber            -0.0143179  0.0087470  -1.637 0.101652    
## Deductible            0.0019536  0.0008462   2.309 0.020958 *  
## Days.Policy.Accident -0.2329156  0.1101513  -2.115 0.034472 *  
## AgeOfVehicle         -0.0901743  0.0279337  -3.228 0.001246 ** 
## PoliceReportFiled    -0.5951474  0.2854399  -2.085 0.037068 *  
## AgentType             0.8264800  0.5360805   1.542 0.123144    
## AddressChange.Claim   0.1478784  0.0415144   3.562 0.000368 ***
## Year                 -0.1003819  0.0507061  -1.980 0.047739 *  
## BasePolicy           -1.1798653  0.0761750 -15.489  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 4853.0  on 5174  degrees of freedom
## Residual deviance: 3846.7  on 5159  degrees of freedom
## AIC: 3878.7
## 
## Number of Fisher Scoring iterations: 6
str(backwards)
## List of 31
##  $ coefficients     : Named num [1:16] -0.2715 -0.0304 0.2175 2.6373 0.67 ...
##   ..- attr(*, "names")= chr [1:16] "(Intercept)" "Month" "Sex" "Fault" ...
##  $ residuals        : Named num [1:5175] 1.74 2.64 4.18 3.53 4.01 ...
##   ..- attr(*, "names")= chr [1:5175] "1" "2" "3" "4" ...
##  $ fitted.values    : Named num [1:5175] 0.574 0.379 0.239 0.283 0.249 ...
##   ..- attr(*, "names")= chr [1:5175] "1" "2" "3" "4" ...
##  $ effects          : Named num [1:5175] 25.28 3.01 -2.7 -13.86 -3.49 ...
##   ..- attr(*, "names")= chr [1:5175] "(Intercept)" "Month" "Sex" "Fault" ...
##  $ R                : num [1:16, 1:16] -25 0 0 0 0 ...
##   ..- attr(*, "dimnames")=List of 2
##   .. ..$ : chr [1:16] "(Intercept)" "Month" "Sex" "Fault" ...
##   .. ..$ : chr [1:16] "(Intercept)" "Month" "Sex" "Fault" ...
##  $ rank             : int 16
##  $ qr               :List of 5
##   ..$ qr   : num [1:5175, 1:16] -24.9606 0.0194 0.0171 0.018 0.0173 ...
##   .. ..- attr(*, "dimnames")=List of 2
##   .. .. ..$ : chr [1:5175] "1" "2" "3" "4" ...
##   .. .. ..$ : chr [1:16] "(Intercept)" "Month" "Sex" "Fault" ...
##   ..$ rank : int 16
##   ..$ qraux: num [1:16] 1.02 1 1.01 1 1 ...
##   ..$ pivot: int [1:16] 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ tol  : num 1e-11
##   ..- attr(*, "class")= chr "qr"
##  $ family           :List of 12
##   ..$ family    : chr "binomial"
##   ..$ link      : chr "logit"
##   ..$ linkfun   :function (mu)  
##   ..$ linkinv   :function (eta)  
##   ..$ variance  :function (mu)  
##   ..$ dev.resids:function (y, mu, wt)  
##   ..$ aic       :function (y, n, mu, wt, dev)  
##   ..$ mu.eta    :function (eta)  
##   ..$ initialize:  expression({     if (NCOL(y) == 1) {         if (is.factor(y))              y <- y != levels(y)[1L]         n <- rep.int(1, nobs)         y[weights == 0] <- 0         if (any(y < 0 | y > 1))              stop("y values must be 0 <= y <= 1")         mustart <- (weights * y + 0.5)/(weights + 1)         m <- weights * y         if (any(abs(m - round(m)) > 0.001))              warning("non-integer #successes in a binomial glm!")     }     else if (NCOL(y) == 2) {         if (any(abs(y - round(y)) > 0.001))              warning("non-integer counts in a binomial glm!")         n <- y[, 1] + y[, 2]         y <- ifelse(n == 0, 0, y[, 1]/n)         weights <- weights * n         mustart <- (n * y + 0.5)/(n + 1)     }     else stop("for the 'binomial' family, y must be a vector of 0 and 1's\nor a 2 column matrix where col 1 is no. successes and col 2 is no. failures") })
##   ..$ validmu   :function (mu)  
##   ..$ valideta  :function (eta)  
##   ..$ simulate  :function (object, nsim)  
##   ..- attr(*, "class")= chr "family"
##  $ linear.predictors: Named num [1:5175] 0.3 -0.494 -1.157 -0.929 -1.103 ...
##   ..- attr(*, "names")= chr [1:5175] "1" "2" "3" "4" ...
##  $ deviance         : num 3847
##  $ aic              : num 3879
##  $ null.deviance    : num 4853
##  $ iter             : int 6
##  $ weights          : Named num [1:5175] 0.244 0.235 0.182 0.203 0.187 ...
##   ..- attr(*, "names")= chr [1:5175] "1" "2" "3" "4" ...
##  $ prior.weights    : Named num [1:5175] 1 1 1 1 1 1 1 1 1 1 ...
##   ..- attr(*, "names")= chr [1:5175] "1" "2" "3" "4" ...
##  $ df.residual      : int 5159
##  $ df.null          : int 5174
##  $ y                : Named num [1:5175] 1 1 1 1 1 1 1 1 1 1 ...
##   ..- attr(*, "names")= chr [1:5175] "1" "2" "3" "4" ...
##  $ converged        : logi TRUE
##  $ boundary         : logi FALSE
##  $ model            :'data.frame':   5175 obs. of  16 variables:
##   ..$ FraudFound          : num [1:5175] 1 1 1 1 1 1 1 1 1 1 ...
##   ..$ Month               : num [1:5175] 7 7 7 11 11 11 11 11 12 12 ...
##   ..$ Sex                 : num [1:5175] 1 1 1 1 1 1 1 1 1 1 ...
##   ..$ Fault               : num [1:5175] 1 1 1 1 1 1 1 1 1 1 ...
##   ..$ PolicyType          : num [1:5175] 1 5 2 5 2 7 7 1 1 1 ...
##   ..$ VehicleCategory     : num [1:5175] 1 2 1 2 1 3 3 1 1 1 ...
##   ..$ VehiclePrice        : num [1:5175] 6 6 1 6 1 6 6 1 6 2 ...
##   ..$ RepNumber           : num [1:5175] 9 4 13 7 7 2 10 9 7 1 ...
##   ..$ Deductible          : num [1:5175] 400 400 400 400 400 400 400 400 400 400 ...
##   ..$ Days.Policy.Accident: num [1:5175] 5 5 5 5 5 5 5 5 5 5 ...
##   ..$ AgeOfVehicle        : num [1:5175] 1 4 8 7 7 7 8 5 1 8 ...
##   ..$ PoliceReportFiled   : num [1:5175] 0 0 0 0 0 0 0 0 0 0 ...
##   ..$ AgentType           : num [1:5175] 1 1 1 1 1 1 1 1 1 1 ...
##   ..$ AddressChange.Claim : num [1:5175] 0 0 0 0 0 0 0 0 0 1 ...
##   ..$ Year                : num [1:5175] 0 0 0 0 0 0 0 0 0 0 ...
##   ..$ BasePolicy          : num [1:5175] 1 2 2 2 2 1 1 1 1 1 ...
##   ..- attr(*, "terms")=Classes 'terms', 'formula'  language FraudFound ~ Month + Sex + Fault + PolicyType + VehicleCategory +      VehiclePrice + RepNumber + Deductible + Days.Policy.Accident +  ...
##   .. .. ..- attr(*, "variables")= language list(FraudFound, Month, Sex, Fault, PolicyType, VehicleCategory, VehiclePrice,      RepNumber, Deductible, Days.Policy.Accident, AgeOfVehicle, PoliceReportFiled,  ...
##   .. .. ..- attr(*, "factors")= int [1:16, 1:15] 0 1 0 0 0 0 0 0 0 0 ...
##   .. .. .. ..- attr(*, "dimnames")=List of 2
##   .. .. .. .. ..$ : chr [1:16] "FraudFound" "Month" "Sex" "Fault" ...
##   .. .. .. .. ..$ : chr [1:15] "Month" "Sex" "Fault" "PolicyType" ...
##   .. .. ..- attr(*, "term.labels")= chr [1:15] "Month" "Sex" "Fault" "PolicyType" ...
##   .. .. ..- attr(*, "order")= int [1:15] 1 1 1 1 1 1 1 1 1 1 ...
##   .. .. ..- attr(*, "intercept")= int 1
##   .. .. ..- attr(*, "response")= int 1
##   .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
##   .. .. ..- attr(*, "predvars")= language list(FraudFound, Month, Sex, Fault, PolicyType, VehicleCategory, VehiclePrice,      RepNumber, Deductible, Days.Policy.Accident, AgeOfVehicle, PoliceReportFiled,  ...
##   .. .. ..- attr(*, "dataClasses")= Named chr [1:16] "numeric" "numeric" "numeric" "numeric" ...
##   .. .. .. ..- attr(*, "names")= chr [1:16] "FraudFound" "Month" "Sex" "Fault" ...
##  $ call             : language glm(formula = FraudFound ~ Month + Sex + Fault + PolicyType + VehicleCategory +      VehiclePrice + RepNumber + Deductible + Days.Policy.Accident +  ...
##  $ formula          :Class 'formula'  language FraudFound ~ Month + Sex + Fault + PolicyType + VehicleCategory +      VehiclePrice + RepNumber + Deductible + Days.Policy.Accident +  ...
##   .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
##  $ terms            :Classes 'terms', 'formula'  language FraudFound ~ Month + Sex + Fault + PolicyType + VehicleCategory +      VehiclePrice + RepNumber + Deductible + Days.Policy.Accident +  ...
##   .. ..- attr(*, "variables")= language list(FraudFound, Month, Sex, Fault, PolicyType, VehicleCategory, VehiclePrice,      RepNumber, Deductible, Days.Policy.Accident, AgeOfVehicle, PoliceReportFiled,  ...
##   .. ..- attr(*, "factors")= int [1:16, 1:15] 0 1 0 0 0 0 0 0 0 0 ...
##   .. .. ..- attr(*, "dimnames")=List of 2
##   .. .. .. ..$ : chr [1:16] "FraudFound" "Month" "Sex" "Fault" ...
##   .. .. .. ..$ : chr [1:15] "Month" "Sex" "Fault" "PolicyType" ...
##   .. ..- attr(*, "term.labels")= chr [1:15] "Month" "Sex" "Fault" "PolicyType" ...
##   .. ..- attr(*, "order")= int [1:15] 1 1 1 1 1 1 1 1 1 1 ...
##   .. ..- attr(*, "intercept")= int 1
##   .. ..- attr(*, "response")= int 1
##   .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
##   .. ..- attr(*, "predvars")= language list(FraudFound, Month, Sex, Fault, PolicyType, VehicleCategory, VehiclePrice,      RepNumber, Deductible, Days.Policy.Accident, AgeOfVehicle, PoliceReportFiled,  ...
##   .. ..- attr(*, "dataClasses")= Named chr [1:16] "numeric" "numeric" "numeric" "numeric" ...
##   .. .. ..- attr(*, "names")= chr [1:16] "FraudFound" "Month" "Sex" "Fault" ...
##  $ data             :'data.frame':   5175 obs. of  32 variables:
##   ..$ Month               : num [1:5175] 7 7 7 11 11 11 11 11 12 12 ...
##   ..$ WeekOfMonth         : num [1:5175] 1 3 4 2 2 3 4 5 1 1 ...
##   ..$ DayOfWeek           : num [1:5175] 6 7 6 4 5 2 4 1 5 1 ...
##   ..$ Make                : num [1:5175] 7 7 7 7 18 3 1 10 7 18 ...
##   ..$ AccidentArea        : num [1:5175] 2 1 2 2 2 2 1 2 1 1 ...
##   ..$ DayOfWeekClaimed    : num [1:5175] 2 3 3 5 2 3 2 3 5 2 ...
##   ..$ MonthClaimed        : num [1:5175] 9 1 8 1 1 1 1 12 12 5 ...
##   ..$ WeekOfMonthClaimed  : num [1:5175] 4 4 2 3 1 2 2 1 3 3 ...
##   ..$ Sex                 : num [1:5175] 1 1 1 1 1 1 1 1 1 1 ...
##   ..$ MaritalStatus       : num [1:5175] 1 2 2 1 2 2 2 1 1 2 ...
##   ..$ Age                 : num [1:5175] 0 21 50 34 38 31 56 68 0 39 ...
##   ..$ Fault               : num [1:5175] 1 1 1 1 1 1 1 1 1 1 ...
##   ..$ PolicyType          : num [1:5175] 1 5 2 5 2 7 7 1 1 1 ...
##   ..$ VehicleCategory     : num [1:5175] 1 2 1 2 1 3 3 1 1 1 ...
##   ..$ VehiclePrice        : num [1:5175] 6 6 1 6 1 6 6 1 6 2 ...
##   ..$ FraudFound          : num [1:5175] 1 1 1 1 1 1 1 1 1 1 ...
##   ..$ RepNumber           : num [1:5175] 9 4 13 7 7 2 10 9 7 1 ...
##   ..$ Deductible          : num [1:5175] 400 400 400 400 400 400 400 400 400 400 ...
##   ..$ DriverRating        : num [1:5175] 1 4 1 3 2 1 2 3 3 3 ...
##   ..$ Days.Policy.Accident: num [1:5175] 5 5 5 5 5 5 5 5 5 5 ...
##   ..$ Days.Policy.Claim   : num [1:5175] 5 5 5 5 5 5 5 5 5 5 ...
##   ..$ PastNumberOfClaims  : num [1:5175] 0 0 0 0 1 3 0 2 0 0 ...
##   ..$ AgeOfVehicle        : num [1:5175] 1 4 8 7 7 7 8 5 1 8 ...
##   ..$ AgeOfPolicyHolder   : num [1:5175] 1 4 7 5 6 5 8 9 1 6 ...
##   ..$ PoliceReportFiled   : num [1:5175] 0 0 0 0 0 0 0 0 0 0 ...
##   ..$ WitnessPresent      : num [1:5175] 0 0 0 0 0 0 0 0 0 0 ...
##   ..$ AgentType           : num [1:5175] 1 1 1 1 1 1 1 1 1 1 ...
##   ..$ NumberOfSuppliments : num [1:5175] 0 2 2 2 0 3 0 0 0 3 ...
##   ..$ AddressChange.Claim : num [1:5175] 0 0 0 0 0 0 0 0 0 1 ...
##   ..$ NumberOfCars        : num [1:5175] 1 1 1 1 1 1 1 1 1 2 ...
##   ..$ Year                : num [1:5175] 0 0 0 0 0 0 0 0 0 0 ...
##   ..$ BasePolicy          : num [1:5175] 1 2 2 2 2 1 1 1 1 1 ...
##  $ offset           : NULL
##  $ control          :List of 3
##   ..$ epsilon: num 1e-08
##   ..$ maxit  : num 25
##   ..$ trace  : logi FALSE
##  $ method           : chr "glm.fit"
##  $ contrasts        : NULL
##  $ xlevels          : Named list()
##  $ anova            :'data.frame':   17 obs. of  6 variables:
##   ..$ Step      :Class 'AsIs'  chr [1:17] "" "- WitnessPresent" "- PastNumberOfClaims" "- AgeOfPolicyHolder" ...
##   ..$ Df        : num [1:17] NA 1 1 1 1 1 1 1 1 1 ...
##   ..$ Deviance  : num [1:17] NA 0.00864 0.00893 0.17809 0.1731 ...
##   ..$ Resid. Df : num [1:17] 5143 5144 5145 5146 5147 ...
##   ..$ Resid. Dev: num [1:17] 3835 3835 3835 3835 3835 ...
##   ..$ AIC       : num [1:17] 3899 3897 3895 3893 3891 ...
##   ..- attr(*, "heading")= chr [1:15] "Stepwise Model Path \nAnalysis of Deviance Table" "\nInitial Model:" "FraudFound ~ Month + WeekOfMonth + DayOfWeek + Make + AccidentArea + " "    DayOfWeekClaimed + MonthClaimed + WeekOfMonthClaimed + Sex + " ...
##  - attr(*, "class")= chr [1:2] "glm" "lm"
# backwards$fit is the probability
fraud$prob <- backwards$fit
fraud$pred <- ifelse(fraud$prob > 0.18, 1, 0)
t <- table(fraud$FraudFound, fraud$pred)
t <- data.frame(Predicted.No = t[,1], Predicted.Yes = t[,2], row.names = c("True.No","True.Yes"))
t
##          Predicted.No Predicted.Yes
## True.No          2529          1723
## True.Yes           83           840

Return to contents page