Modelo Predictivo

Importar base de datos

# file.choose()
base_de_datos <- read.csv("seguros.csv")

Entender la base de datos

resumen <- summary(base_de_datos)
resumen
##     ClaimID           TotalPaid       TotalReserves     TotalRecovery      
##  Min.   :  777632   Min.   :      0   Min.   :      0   Min.   :     0.00  
##  1st Qu.:  800748   1st Qu.:     83   1st Qu.:      0   1st Qu.:     0.00  
##  Median :  812128   Median :    271   Median :      0   Median :     0.00  
##  Mean   : 1864676   Mean   :  10404   Mean   :   3368   Mean   :    66.05  
##  3rd Qu.:  824726   3rd Qu.:   1122   3rd Qu.:      0   3rd Qu.:     0.00  
##  Max.   :62203364   Max.   :4527291   Max.   :1529053   Max.   :100000.00  
##                                                                            
##  IndemnityPaid      OtherPaid       TotalIncurredCost ClaimStatus       
##  Min.   :     0   Min.   :      0   Min.   : -10400   Length:31619      
##  1st Qu.:     0   1st Qu.:     80   1st Qu.:     80   Class :character  
##  Median :     0   Median :    265   Median :    266   Mode  :character  
##  Mean   :  4977   Mean   :   5427   Mean   :  13706                     
##  3rd Qu.:     0   3rd Qu.:   1023   3rd Qu.:   1098                     
##  Max.   :640732   Max.   :4129915   Max.   :4734750                     
##                                                                         
##  IncidentDate       IncidentDescription ReturnToWorkDate   ClaimantOpenedDate
##  Length:31619       Length:31619        Length:31619       Length:31619      
##  Class :character   Class :character    Class :character   Class :character  
##  Mode  :character   Mode  :character    Mode  :character   Mode  :character  
##                                                                              
##                                                                              
##                                                                              
##                                                                              
##  ClaimantClosedDate EmployerNotificationDate ReceivedDate      
##  Length:31619       Length:31619             Length:31619      
##  Class :character   Class :character         Class :character  
##  Mode  :character   Mode  :character         Mode  :character  
##                                                                
##                                                                
##                                                                
##                                                                
##     IsDenied       Transaction_Time Procesing_Time     ClaimantAge_at_DOI
##  Min.   :0.00000   Min.   :    0    Min.   :    0.00   Min.   :14.0      
##  1st Qu.:0.00000   1st Qu.:  211    1st Qu.:    4.00   1st Qu.:33.0      
##  Median :0.00000   Median :  780    Median :   10.00   Median :42.0      
##  Mean   :0.04463   Mean   : 1004    Mean   :   62.99   Mean   :41.6      
##  3rd Qu.:0.00000   3rd Qu.: 1440    3rd Qu.:   24.00   3rd Qu.:50.0      
##  Max.   :1.00000   Max.   :16428    Max.   :11558.00   Max.   :94.0      
##                    NA's   :614                                           
##     Gender          ClaimantType       InjuryNature       BodyPartRegion    
##  Length:31619       Length:31619       Length:31619       Length:31619      
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##    BodyPart         AverageWeeklyWage1    ClaimID1        BillReviewALE    
##  Length:31619       Min.   : 100.0     Min.   :  777632   Min.   : -448.0  
##  Class :character   1st Qu.: 492.0     1st Qu.:  800748   1st Qu.:   16.0  
##  Mode  :character   Median : 492.0     Median :  812128   Median :   24.0  
##                     Mean   : 536.5     Mean   : 1864676   Mean   :  188.7  
##                     3rd Qu.: 492.0     3rd Qu.:  824726   3rd Qu.:   64.1  
##                     Max.   :8613.5     Max.   :62203364   Max.   :46055.3  
##                                                           NA's   :14912    
##     Hospital         PhysicianOutpatient       Rx          
##  Min.   : -12570.4   Min.   :   -549.5   Min.   :  -160.7  
##  1st Qu.:    210.5   1st Qu.:    105.8   1st Qu.:    22.9  
##  Median :    613.9   Median :    218.0   Median :    61.5  
##  Mean   :   5113.2   Mean   :   1813.2   Mean   :  1695.2  
##  3rd Qu.:   2349.1   3rd Qu.:    680.6   3rd Qu.:   189.0  
##  Max.   :2759604.0   Max.   :1219766.6   Max.   :631635.5  
##  NA's   :19655       NA's   :2329        NA's   :20730
plot(base_de_datos$ClaimantAge_at_DOI, base_de_datos$TotalIncurredCost, main="Influencia de la edad sobre el costo total incurrido",xlab="Edad", ylab="Costo ($)")

Generar regresion (modelo lineal)

regresion <- lm(TotalIncurredCost ~ ClaimStatus + IsDenied + Procesing_Time + ClaimantAge_at_DOI + Gender + BillReviewALE + Hospital + PhysicianOutpatient + ClaimantType
+ InjuryNature + BodyPartRegion + BodyPart, data= base_de_datos)

summary(regresion)
## 
## Call:
## lm(formula = TotalIncurredCost ~ ClaimStatus + IsDenied + Procesing_Time + 
##     ClaimantAge_at_DOI + Gender + BillReviewALE + Hospital + 
##     PhysicianOutpatient + ClaimantType + InjuryNature + BodyPartRegion + 
##     BodyPart, data = base_de_datos)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -478598   -3785     240    3006 1323680 
## 
## Coefficients: (6 not defined because of singularities)
##                                                                           Estimate
## (Intercept)                                                              1.206e+04
## ClaimStatusO                                                             4.551e+05
## ClaimStatusR                                                             2.890e+05
## IsDenied                                                                -9.657e+03
## Procesing_Time                                                           3.554e+01
## ClaimantAge_at_DOI                                                       4.598e+01
## GenderMale                                                               1.705e+03
## GenderNot Available                                                      1.307e+03
## BillReviewALE                                                            8.909e-02
## Hospital                                                                -2.256e-03
## PhysicianOutpatient                                                     -1.115e-02
## ClaimantTypeMedical Only                                                -2.506e+04
## ClaimantTypeReport Only                                                 -2.482e+04
## InjuryNatureAmputation                                                   3.738e+04
## InjuryNatureAngina Pectoris                                             -2.053e+04
## InjuryNatureAsbestosis                                                   2.142e+04
## InjuryNatureBurn                                                         2.229e+04
## InjuryNatureCancer                                                       1.061e+04
## InjuryNatureCarpal Tunnel Syndrome                                       1.914e+03
## InjuryNatureConcussion                                                   1.558e+04
## InjuryNatureContagious Disease                                           1.884e+04
## InjuryNatureContusion                                                    4.520e+03
## InjuryNatureCrushing                                                     2.985e+03
## InjuryNatureDermatitis                                                   6.426e+02
## InjuryNatureDislocation                                                 -1.766e+04
## InjuryNatureDust Disease, NOC                                            9.757e+03
## InjuryNatureElectric Shock                                               5.428e+02
## InjuryNatureForeign Body                                                 8.402e+03
## InjuryNatureFracture                                                     4.845e+03
## InjuryNatureHearing Loss Or Impairment                                  -1.268e+03
## InjuryNatureHeat Prostration                                             7.346e+03
## InjuryNatureHernia                                                       6.208e+02
## InjuryNatureInfection                                                    7.923e+03
## InjuryNatureInflammation                                                 9.167e+03
## InjuryNatureLaceration                                                   4.688e+03
## InjuryNatureLoss of Hearing                                             -1.659e+04
## InjuryNatureMental Stress                                               -3.895e+03
## InjuryNatureMultiple Injuries Including Both Physical and Psychological -1.553e+01
## InjuryNatureMultiple Physical Injuries Only                              1.341e+04
## InjuryNatureMyocardial Infarction                                       -1.526e+04
## InjuryNatureNo Physical Injury                                           4.734e+03
## InjuryNatureNon-Standard Code                                           -1.101e+03
## InjuryNaturePoisoning?Chemical (Other Than Metals)                       1.327e+04
## InjuryNaturePuncture                                                     3.297e+03
## InjuryNatureRadiation                                                    6.947e+01
## InjuryNatureRespiratory Disorders                                        8.279e+03
## InjuryNatureRupture                                                     -1.919e+04
## InjuryNatureSeverance                                                    1.444e+04
## InjuryNatureSprain                                                       2.244e+03
## InjuryNatureStrain                                                       1.856e+03
## InjuryNatureSyncope                                                      9.080e+03
## InjuryNatureVision Loss                                                  1.050e+04
## BodyPartRegionLower Extremities                                          6.661e+03
## BodyPartRegionMultiple Body Parts                                        2.316e+03
## BodyPartRegionNeck                                                      -1.518e+03
## BodyPartRegionNon-Standard Code                                          2.388e+02
## BodyPartRegionTrunk                                                      4.718e+03
## BodyPartRegionUpper Extremities                                          4.665e+03
## BodyPartAnkle                                                           -1.055e+03
## BodyPartArtificial Appliance                                             6.652e+02
## BodyPartBody Systems and Multiple Body Systems                          -1.856e+04
## BodyPartButtocks                                                         2.986e+03
## BodyPartChest                                                           -5.219e+02
## BodyPartDisc-Trunk                                                       5.764e+02
## BodyPartEar(S)                                                           4.941e+03
## BodyPartElbow                                                            3.845e+03
## BodyPartEyes                                                            -6.889e+02
## BodyPartFacial Bones                                                     4.016e+03
## BodyPartFinger(S)                                                       -1.443e+03
## BodyPartFoot                                                            -3.527e+03
## BodyPartGreat Toe                                                       -6.245e+03
## BodyPartHand                                                            -2.433e+03
## BodyPartHeart                                                            3.816e+03
## BodyPartHip                                                              7.205e+03
## BodyPartInsufficient Info to Properly Identify?Unclassified              6.231e+03
## BodyPartInternal Organs                                                  1.024e+04
## BodyPartKnee                                                             2.694e+02
## BodyPartLarynx                                                          -1.248e+04
## BodyPartLower Arm                                                       -7.106e+02
## BodyPartLower Back Area                                                  4.736e+03
## BodyPartLower Leg                                                       -1.616e+03
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk)              6.981e+03
## BodyPartLungs                                                           -5.875e+03
## BodyPartMouth                                                            3.608e+03
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts)      4.297e+03
## BodyPartMultiple Head Injury                                             4.546e+03
## BodyPartMultiple Lower Extremities                                       2.510e+04
## BodyPartMultiple Neck Injury                                             7.364e+03
## BodyPartMultiple Trunk                                                   1.300e+03
## BodyPartMultiple Upper Extremities                                       3.435e+03
## BodyPartNo Physical Injury                                                      NA
## BodyPartNon-Standard Code                                                       NA
## BodyPartNose                                                             1.180e+04
## BodyPartPelvis                                                          -2.627e+03
## BodyPartSacrum And Coccyx                                               -5.537e+03
## BodyPartShoulder(S)                                                      4.110e+03
## BodyPartSkull                                                           -2.530e+03
## BodyPartSoft Tissue-Neck                                                -2.146e+03
## BodyPartSpinal Cord-Trunk                                                2.422e+04
## BodyPartTeeth                                                                   NA
## BodyPartThumb                                                           -6.651e+02
## BodyPartToes                                                            -3.973e+03
## BodyPartTrachea                                                                 NA
## BodyPartUpper Arm                                                        2.105e+04
## BodyPartUpper Back Area                                                  2.625e+03
## BodyPartUpper Leg                                                               NA
## BodyPartWrist                                                                   NA
##                                                                         Std. Error
## (Intercept)                                                              1.512e+04
## ClaimStatusO                                                             9.395e+03
## ClaimStatusR                                                             8.201e+03
## IsDenied                                                                 3.269e+03
## Procesing_Time                                                           4.061e+00
## ClaimantAge_at_DOI                                                       5.223e+01
## GenderMale                                                               1.198e+03
## GenderNot Available                                                      9.282e+03
## BillReviewALE                                                            6.051e-01
## Hospital                                                                 2.000e-02
## PhysicianOutpatient                                                      5.648e-02
## ClaimantTypeMedical Only                                                 1.583e+03
## ClaimantTypeReport Only                                                  3.788e+03
## InjuryNatureAmputation                                                   4.784e+04
## InjuryNatureAngina Pectoris                                              4.790e+04
## InjuryNatureAsbestosis                                                   3.448e+04
## InjuryNatureBurn                                                         6.383e+03
## InjuryNatureCancer                                                       4.858e+04
## InjuryNatureCarpal Tunnel Syndrome                                       7.958e+03
## InjuryNatureConcussion                                                   1.434e+04
## InjuryNatureContagious Disease                                           1.441e+04
## InjuryNatureContusion                                                    3.398e+03
## InjuryNatureCrushing                                                     1.077e+04
## InjuryNatureDermatitis                                                   5.656e+03
## InjuryNatureDislocation                                                  1.072e+04
## InjuryNatureDust Disease, NOC                                            4.858e+04
## InjuryNatureElectric Shock                                               1.718e+04
## InjuryNatureForeign Body                                                 5.137e+03
## InjuryNatureFracture                                                     5.085e+03
## InjuryNatureHearing Loss Or Impairment                                   2.457e+04
## InjuryNatureHeat Prostration                                             1.856e+04
## InjuryNatureHernia                                                       1.635e+04
## InjuryNatureInfection                                                    1.131e+04
## InjuryNatureInflammation                                                 7.022e+03
## InjuryNatureLaceration                                                   3.963e+03
## InjuryNatureLoss of Hearing                                              3.014e+04
## InjuryNatureMental Stress                                                1.402e+04
## InjuryNatureMultiple Injuries Including Both Physical and Psychological  2.409e+04
## InjuryNatureMultiple Physical Injuries Only                              6.003e+03
## InjuryNatureMyocardial Infarction                                        5.849e+04
## InjuryNatureNo Physical Injury                                           7.801e+03
## InjuryNatureNon-Standard Code                                            2.419e+04
## InjuryNaturePoisoning?Chemical (Other Than Metals)                       1.734e+04
## InjuryNaturePuncture                                                     4.349e+03
## InjuryNatureRadiation                                                    4.773e+04
## InjuryNatureRespiratory Disorders                                        8.693e+03
## InjuryNatureRupture                                                      2.893e+04
## InjuryNatureSeverance                                                    3.621e+04
## InjuryNatureSprain                                                       4.298e+03
## InjuryNatureStrain                                                       3.530e+03
## InjuryNatureSyncope                                                      1.487e+04
## InjuryNatureVision Loss                                                  4.778e+04
## BodyPartRegionLower Extremities                                          1.613e+04
## BodyPartRegionMultiple Body Parts                                        1.642e+04
## BodyPartRegionNeck                                                       2.947e+04
## BodyPartRegionNon-Standard Code                                          2.937e+04
## BodyPartRegionTrunk                                                      1.595e+04
## BodyPartRegionUpper Extremities                                          1.478e+04
## BodyPartAnkle                                                            7.729e+03
## BodyPartArtificial Appliance                                             3.494e+04
## BodyPartBody Systems and Multiple Body Systems                           1.116e+04
## BodyPartButtocks                                                         1.180e+04
## BodyPartChest                                                            7.992e+03
## BodyPartDisc-Trunk                                                       1.176e+04
## BodyPartEar(S)                                                           1.878e+04
## BodyPartElbow                                                            5.200e+03
## BodyPartEyes                                                             1.492e+04
## BodyPartFacial Bones                                                     1.565e+04
## BodyPartFinger(S)                                                        3.769e+03
## BodyPartFoot                                                             7.879e+03
## BodyPartGreat Toe                                                        1.455e+04
## BodyPartHand                                                             3.802e+03
## BodyPartHeart                                                            4.807e+04
## BodyPartHip                                                              9.454e+03
## BodyPartInsufficient Info to Properly Identify?Unclassified              9.310e+03
## BodyPartInternal Organs                                                  1.980e+04
## BodyPartKnee                                                             7.313e+03
## BodyPartLarynx                                                           5.407e+04
## BodyPartLower Arm                                                        4.941e+03
## BodyPartLower Back Area                                                  6.877e+03
## BodyPartLower Leg                                                        8.003e+03
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk)              7.972e+03
## BodyPartLungs                                                            1.152e+04
## BodyPartMouth                                                            1.611e+04
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts)      7.838e+03
## BodyPartMultiple Head Injury                                             1.488e+04
## BodyPartMultiple Lower Extremities                                       9.573e+03
## BodyPartMultiple Neck Injury                                             2.598e+04
## BodyPartMultiple Trunk                                                   1.583e+04
## BodyPartMultiple Upper Extremities                                       5.825e+03
## BodyPartNo Physical Injury                                                      NA
## BodyPartNon-Standard Code                                                       NA
## BodyPartNose                                                             1.627e+04
## BodyPartPelvis                                                           1.351e+04
## BodyPartSacrum And Coccyx                                                2.229e+04
## BodyPartShoulder(S)                                                      3.946e+03
## BodyPartSkull                                                            2.594e+04
## BodyPartSoft Tissue-Neck                                                 2.656e+04
## BodyPartSpinal Cord-Trunk                                                2.576e+04
## BodyPartTeeth                                                                   NA
## BodyPartThumb                                                            4.815e+03
## BodyPartToes                                                             1.110e+04
## BodyPartTrachea                                                                 NA
## BodyPartUpper Arm                                                        6.270e+03
## BodyPartUpper Back Area                                                  9.489e+03
## BodyPartUpper Leg                                                               NA
## BodyPartWrist                                                                   NA
##                                                                         t value
## (Intercept)                                                               0.797
## ClaimStatusO                                                             48.444
## ClaimStatusR                                                             35.245
## IsDenied                                                                 -2.954
## Procesing_Time                                                            8.750
## ClaimantAge_at_DOI                                                        0.880
## GenderMale                                                                1.423
## GenderNot Available                                                       0.141
## BillReviewALE                                                             0.147
## Hospital                                                                 -0.113
## PhysicianOutpatient                                                      -0.197
## ClaimantTypeMedical Only                                                -15.833
## ClaimantTypeReport Only                                                  -6.552
## InjuryNatureAmputation                                                    0.781
## InjuryNatureAngina Pectoris                                              -0.429
## InjuryNatureAsbestosis                                                    0.621
## InjuryNatureBurn                                                          3.493
## InjuryNatureCancer                                                        0.218
## InjuryNatureCarpal Tunnel Syndrome                                        0.240
## InjuryNatureConcussion                                                    1.086
## InjuryNatureContagious Disease                                            1.308
## InjuryNatureContusion                                                     1.331
## InjuryNatureCrushing                                                      0.277
## InjuryNatureDermatitis                                                    0.114
## InjuryNatureDislocation                                                  -1.647
## InjuryNatureDust Disease, NOC                                             0.201
## InjuryNatureElectric Shock                                                0.032
## InjuryNatureForeign Body                                                  1.636
## InjuryNatureFracture                                                      0.953
## InjuryNatureHearing Loss Or Impairment                                   -0.052
## InjuryNatureHeat Prostration                                              0.396
## InjuryNatureHernia                                                        0.038
## InjuryNatureInfection                                                     0.701
## InjuryNatureInflammation                                                  1.306
## InjuryNatureLaceration                                                    1.183
## InjuryNatureLoss of Hearing                                              -0.550
## InjuryNatureMental Stress                                                -0.278
## InjuryNatureMultiple Injuries Including Both Physical and Psychological  -0.001
## InjuryNatureMultiple Physical Injuries Only                               2.235
## InjuryNatureMyocardial Infarction                                        -0.261
## InjuryNatureNo Physical Injury                                            0.607
## InjuryNatureNon-Standard Code                                            -0.045
## InjuryNaturePoisoning?Chemical (Other Than Metals)                        0.765
## InjuryNaturePuncture                                                      0.758
## InjuryNatureRadiation                                                     0.001
## InjuryNatureRespiratory Disorders                                         0.952
## InjuryNatureRupture                                                      -0.663
## InjuryNatureSeverance                                                     0.399
## InjuryNatureSprain                                                        0.522
## InjuryNatureStrain                                                        0.526
## InjuryNatureSyncope                                                       0.611
## InjuryNatureVision Loss                                                   0.220
## BodyPartRegionLower Extremities                                           0.413
## BodyPartRegionMultiple Body Parts                                         0.141
## BodyPartRegionNeck                                                       -0.052
## BodyPartRegionNon-Standard Code                                           0.008
## BodyPartRegionTrunk                                                       0.296
## BodyPartRegionUpper Extremities                                           0.316
## BodyPartAnkle                                                            -0.137
## BodyPartArtificial Appliance                                              0.019
## BodyPartBody Systems and Multiple Body Systems                           -1.663
## BodyPartButtocks                                                          0.253
## BodyPartChest                                                            -0.065
## BodyPartDisc-Trunk                                                        0.049
## BodyPartEar(S)                                                            0.263
## BodyPartElbow                                                             0.739
## BodyPartEyes                                                             -0.046
## BodyPartFacial Bones                                                      0.257
## BodyPartFinger(S)                                                        -0.383
## BodyPartFoot                                                             -0.448
## BodyPartGreat Toe                                                        -0.429
## BodyPartHand                                                             -0.640
## BodyPartHeart                                                             0.079
## BodyPartHip                                                               0.762
## BodyPartInsufficient Info to Properly Identify?Unclassified               0.669
## BodyPartInternal Organs                                                   0.517
## BodyPartKnee                                                              0.037
## BodyPartLarynx                                                           -0.231
## BodyPartLower Arm                                                        -0.144
## BodyPartLower Back Area                                                   0.689
## BodyPartLower Leg                                                        -0.202
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk)               0.876
## BodyPartLungs                                                            -0.510
## BodyPartMouth                                                             0.224
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts)       0.548
## BodyPartMultiple Head Injury                                              0.306
## BodyPartMultiple Lower Extremities                                        2.622
## BodyPartMultiple Neck Injury                                              0.284
## BodyPartMultiple Trunk                                                    0.082
## BodyPartMultiple Upper Extremities                                        0.590
## BodyPartNo Physical Injury                                                   NA
## BodyPartNon-Standard Code                                                    NA
## BodyPartNose                                                              0.725
## BodyPartPelvis                                                           -0.194
## BodyPartSacrum And Coccyx                                                -0.248
## BodyPartShoulder(S)                                                       1.042
## BodyPartSkull                                                            -0.098
## BodyPartSoft Tissue-Neck                                                 -0.081
## BodyPartSpinal Cord-Trunk                                                 0.940
## BodyPartTeeth                                                                NA
## BodyPartThumb                                                            -0.138
## BodyPartToes                                                             -0.358
## BodyPartTrachea                                                              NA
## BodyPartUpper Arm                                                         3.356
## BodyPartUpper Back Area                                                   0.277
## BodyPartUpper Leg                                                            NA
## BodyPartWrist                                                                NA
##                                                                         Pr(>|t|)
## (Intercept)                                                             0.425304
## ClaimStatusO                                                             < 2e-16
## ClaimStatusR                                                             < 2e-16
## IsDenied                                                                0.003147
## Procesing_Time                                                           < 2e-16
## ClaimantAge_at_DOI                                                      0.378683
## GenderMale                                                              0.154763
## GenderNot Available                                                     0.888012
## BillReviewALE                                                           0.882960
## Hospital                                                                0.910198
## PhysicianOutpatient                                                     0.843532
## ClaimantTypeMedical Only                                                 < 2e-16
## ClaimantTypeReport Only                                                 6.09e-11
## InjuryNatureAmputation                                                  0.434619
## InjuryNatureAngina Pectoris                                             0.668238
## InjuryNatureAsbestosis                                                  0.534456
## InjuryNatureBurn                                                        0.000481
## InjuryNatureCancer                                                      0.827162
## InjuryNatureCarpal Tunnel Syndrome                                      0.809978
## InjuryNatureConcussion                                                  0.277441
## InjuryNatureContagious Disease                                          0.190847
## InjuryNatureContusion                                                   0.183393
## InjuryNatureCrushing                                                    0.781667
## InjuryNatureDermatitis                                                  0.909561
## InjuryNatureDislocation                                                 0.099575
## InjuryNatureDust Disease, NOC                                           0.840827
## InjuryNatureElectric Shock                                              0.974800
## InjuryNatureForeign Body                                                0.101923
## InjuryNatureFracture                                                    0.340802
## InjuryNatureHearing Loss Or Impairment                                  0.958852
## InjuryNatureHeat Prostration                                            0.692267
## InjuryNatureHernia                                                      0.969708
## InjuryNatureInfection                                                   0.483587
## InjuryNatureInflammation                                                0.191759
## InjuryNatureLaceration                                                  0.236844
## InjuryNatureLoss of Hearing                                             0.582003
## InjuryNatureMental Stress                                               0.781165
## InjuryNatureMultiple Injuries Including Both Physical and Psychological 0.999486
## InjuryNatureMultiple Physical Injuries Only                             0.025472
## InjuryNatureMyocardial Infarction                                       0.794128
## InjuryNatureNo Physical Injury                                          0.544036
## InjuryNatureNon-Standard Code                                           0.963720
## InjuryNaturePoisoning?Chemical (Other Than Metals)                      0.444204
## InjuryNaturePuncture                                                    0.448369
## InjuryNatureRadiation                                                   0.998839
## InjuryNatureRespiratory Disorders                                       0.340935
## InjuryNatureRupture                                                     0.507056
## InjuryNatureSeverance                                                   0.690054
## InjuryNatureSprain                                                      0.601648
## InjuryNatureStrain                                                      0.599149
## InjuryNatureSyncope                                                     0.541456
## InjuryNatureVision Loss                                                 0.826015
## BodyPartRegionLower Extremities                                         0.679552
## BodyPartRegionMultiple Body Parts                                       0.887814
## BodyPartRegionNeck                                                      0.958922
## BodyPartRegionNon-Standard Code                                         0.993512
## BodyPartRegionTrunk                                                     0.767424
## BodyPartRegionUpper Extremities                                         0.752213
## BodyPartAnkle                                                           0.891382
## BodyPartArtificial Appliance                                            0.984812
## BodyPartBody Systems and Multiple Body Systems                          0.096403
## BodyPartButtocks                                                        0.800265
## BodyPartChest                                                           0.947938
## BodyPartDisc-Trunk                                                      0.960925
## BodyPartEar(S)                                                          0.792491
## BodyPartElbow                                                           0.459754
## BodyPartEyes                                                            0.963175
## BodyPartFacial Bones                                                    0.797548
## BodyPartFinger(S)                                                       0.701766
## BodyPartFoot                                                            0.654481
## BodyPartGreat Toe                                                       0.667887
## BodyPartHand                                                            0.522353
## BodyPartHeart                                                           0.936732
## BodyPartHip                                                             0.446031
## BodyPartInsufficient Info to Properly Identify?Unclassified             0.503336
## BodyPartInternal Organs                                                 0.604998
## BodyPartKnee                                                            0.970618
## BodyPartLarynx                                                          0.817443
## BodyPartLower Arm                                                       0.885647
## BodyPartLower Back Area                                                 0.491090
## BodyPartLower Leg                                                       0.840027
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk)             0.381235
## BodyPartLungs                                                           0.609929
## BodyPartMouth                                                           0.822785
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts)     0.583537
## BodyPartMultiple Head Injury                                            0.759921
## BodyPartMultiple Lower Extremities                                      0.008758
## BodyPartMultiple Neck Injury                                            0.776801
## BodyPartMultiple Trunk                                                  0.934552
## BodyPartMultiple Upper Extremities                                      0.555469
## BodyPartNo Physical Injury                                                    NA
## BodyPartNon-Standard Code                                                     NA
## BodyPartNose                                                            0.468464
## BodyPartPelvis                                                          0.845817
## BodyPartSacrum And Coccyx                                               0.803834
## BodyPartShoulder(S)                                                     0.297669
## BodyPartSkull                                                           0.922307
## BodyPartSoft Tissue-Neck                                                0.935592
## BodyPartSpinal Cord-Trunk                                               0.347237
## BodyPartTeeth                                                                 NA
## BodyPartThumb                                                           0.890140
## BodyPartToes                                                            0.720498
## BodyPartTrachea                                                               NA
## BodyPartUpper Arm                                                       0.000795
## BodyPartUpper Back Area                                                 0.782039
## BodyPartUpper Leg                                                             NA
## BodyPartWrist                                                                 NA
##                                                                            
## (Intercept)                                                                
## ClaimStatusO                                                            ***
## ClaimStatusR                                                            ***
## IsDenied                                                                ** 
## Procesing_Time                                                          ***
## ClaimantAge_at_DOI                                                         
## GenderMale                                                                 
## GenderNot Available                                                        
## BillReviewALE                                                              
## Hospital                                                                   
## PhysicianOutpatient                                                        
## ClaimantTypeMedical Only                                                ***
## ClaimantTypeReport Only                                                 ***
## InjuryNatureAmputation                                                     
## InjuryNatureAngina Pectoris                                                
## InjuryNatureAsbestosis                                                     
## InjuryNatureBurn                                                        ***
## InjuryNatureCancer                                                         
## InjuryNatureCarpal Tunnel Syndrome                                         
## InjuryNatureConcussion                                                     
## InjuryNatureContagious Disease                                             
## InjuryNatureContusion                                                      
## InjuryNatureCrushing                                                       
## InjuryNatureDermatitis                                                     
## InjuryNatureDislocation                                                 .  
## InjuryNatureDust Disease, NOC                                              
## InjuryNatureElectric Shock                                                 
## InjuryNatureForeign Body                                                   
## InjuryNatureFracture                                                       
## InjuryNatureHearing Loss Or Impairment                                     
## InjuryNatureHeat Prostration                                               
## InjuryNatureHernia                                                         
## InjuryNatureInfection                                                      
## InjuryNatureInflammation                                                   
## InjuryNatureLaceration                                                     
## InjuryNatureLoss of Hearing                                                
## InjuryNatureMental Stress                                                  
## InjuryNatureMultiple Injuries Including Both Physical and Psychological    
## InjuryNatureMultiple Physical Injuries Only                             *  
## InjuryNatureMyocardial Infarction                                          
## InjuryNatureNo Physical Injury                                             
## InjuryNatureNon-Standard Code                                              
## InjuryNaturePoisoning?Chemical (Other Than Metals)                         
## InjuryNaturePuncture                                                       
## InjuryNatureRadiation                                                      
## InjuryNatureRespiratory Disorders                                          
## InjuryNatureRupture                                                        
## InjuryNatureSeverance                                                      
## InjuryNatureSprain                                                         
## InjuryNatureStrain                                                         
## InjuryNatureSyncope                                                        
## InjuryNatureVision Loss                                                    
## BodyPartRegionLower Extremities                                            
## BodyPartRegionMultiple Body Parts                                          
## BodyPartRegionNeck                                                         
## BodyPartRegionNon-Standard Code                                            
## BodyPartRegionTrunk                                                        
## BodyPartRegionUpper Extremities                                            
## BodyPartAnkle                                                              
## BodyPartArtificial Appliance                                               
## BodyPartBody Systems and Multiple Body Systems                          .  
## BodyPartButtocks                                                           
## BodyPartChest                                                              
## BodyPartDisc-Trunk                                                         
## BodyPartEar(S)                                                             
## BodyPartElbow                                                              
## BodyPartEyes                                                               
## BodyPartFacial Bones                                                       
## BodyPartFinger(S)                                                          
## BodyPartFoot                                                               
## BodyPartGreat Toe                                                          
## BodyPartHand                                                               
## BodyPartHeart                                                              
## BodyPartHip                                                                
## BodyPartInsufficient Info to Properly Identify?Unclassified                
## BodyPartInternal Organs                                                    
## BodyPartKnee                                                               
## BodyPartLarynx                                                             
## BodyPartLower Arm                                                          
## BodyPartLower Back Area                                                    
## BodyPartLower Leg                                                          
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk)                
## BodyPartLungs                                                              
## BodyPartMouth                                                              
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts)        
## BodyPartMultiple Head Injury                                               
## BodyPartMultiple Lower Extremities                                      ** 
## BodyPartMultiple Neck Injury                                               
## BodyPartMultiple Trunk                                                     
## BodyPartMultiple Upper Extremities                                         
## BodyPartNo Physical Injury                                                 
## BodyPartNon-Standard Code                                                  
## BodyPartNose                                                               
## BodyPartPelvis                                                             
## BodyPartSacrum And Coccyx                                                  
## BodyPartShoulder(S)                                                        
## BodyPartSkull                                                              
## BodyPartSoft Tissue-Neck                                                   
## BodyPartSpinal Cord-Trunk                                                  
## BodyPartTeeth                                                              
## BodyPartThumb                                                              
## BodyPartToes                                                               
## BodyPartTrachea                                                            
## BodyPartUpper Arm                                                       ***
## BodyPartUpper Back Area                                                    
## BodyPartUpper Leg                                                          
## BodyPartWrist                                                              
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 47560 on 6577 degrees of freedom
##   (24941 observations deleted due to missingness)
## Multiple R-squared:  0.5888, Adjusted R-squared:  0.5825 
## F-statistic: 94.17 on 100 and 6577 DF,  p-value: < 2.2e-16

Evaluar, y en caso necesario, ajustar la regresion

regresion <- lm(TotalIncurredCost ~ ClaimStatus + IsDenied + Procesing_Time + ClaimantAge_at_DOI + Gender + ClaimantType, data= base_de_datos)

summary(regresion)
## 
## Call:
## lm(formula = TotalIncurredCost ~ ClaimStatus + IsDenied + Procesing_Time + 
##     ClaimantAge_at_DOI + Gender + ClaimantType, data = base_de_datos)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -621727   -1712     185    1312 4372971 
## 
## Coefficients:
##                            Estimate Std. Error t value Pr(>|t|)    
## (Intercept)               19003.740   1500.567  12.664  < 2e-16 ***
## ClaimStatusO             413752.222   3486.939 118.658  < 2e-16 ***
## ClaimStatusR             292797.925   3924.071  74.616  < 2e-16 ***
## IsDenied                 -11083.896   1599.809  -6.928 4.34e-12 ***
## Procesing_Time               35.513      1.227  28.937  < 2e-16 ***
## ClaimantAge_at_DOI           76.337     29.012   2.631  0.00851 ** 
## GenderMale                  300.706    658.804   0.456  0.64807    
## GenderNot Available       30495.625   6106.824   4.994 5.95e-07 ***
## ClaimantTypeMedical Only -22879.560    815.968 -28.040  < 2e-16 ***
## ClaimantTypeReport Only  -23246.419   1816.307 -12.799  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 58330 on 31609 degrees of freedom
## Multiple R-squared:  0.5211, Adjusted R-squared:  0.5209 
## F-statistic:  3821 on 9 and 31609 DF,  p-value: < 2.2e-16

Construir un modelo de prediccion

datos_nuevos <- data.frame(ClaimStatus= "O", IsDenied = 0, Procesing_Time = 10, ClaimantAge_at_DOI = 50, Gender = "Male", ClaimantType = "Indemnity")

predict(regresion,datos_nuevos)
##        1 
## 437228.7

Conclusion

El modelo de regresión lineal logró explicar el 52% del comportamiento del Costo Total de Incurrencia utilizando solo 6 de las 29 variables explicativas. Este modelo puede mejorarse de varias formas, como:

Incorporar variables adicionales que afecten al negocio. Integrar datos de otras fuentes de información. Utilizar diferentes técnicas de validación del modelo. Simplificar las variables categóricas reduciendo el número de categorías (haciéndolas más generales).

LS0tDQp0aXRsZTogIlJlZ3Jlc2lvbiBMaW5lYWwgLSBTZWd1cm9zIg0KYXV0aG9yOiAiQTAwODMxOTM4IENlc2FyIFZlZ2EiDQpkYXRlOiAiMjAyNC0wOC0xOSINCm91dHB1dDogDQogIGh0bWxfZG9jdW1lbnQ6DQogICAgdG9jOiBUUlVFDQogICAgdG9jX2Zsb2F0OiBUUlVFD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