Teoria

lm() es la funcion de R para ajustar modelos lineales.
Es el modelo estadistico mas basico que existe y mas facil de interpretar.
Para interpretarlo se usa la medida R^2, que significa que tan cerca estan los datos de la linea de regresion ajustada.(Va de 0 a 1, donde 1 es que el modelo explica toda la variabilidad).

Modelo Predictivo

Importar base de datos

# file.choose()
base_de_datos <- read.csv("/Users/constantinomilletxacur/Desktop/Concentracion/Modulo 2/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

Generar regresion (modelo lineal)

regresion <- lm(TotalIncurredCost ~ IsDenied + Transaction_Time + Procesing_Time + ClaimantAge_at_DOI + Gender + ClaimantType + InjuryNature + BodyPartRegion + BodyPart + AverageWeeklyWage1, data=base_de_datos)
summary(regresion)
## 
## Call:
## lm(formula = TotalIncurredCost ~ IsDenied + Transaction_Time + 
##     Procesing_Time + ClaimantAge_at_DOI + Gender + ClaimantType + 
##     InjuryNature + BodyPartRegion + BodyPart + AverageWeeklyWage1, 
##     data = base_de_datos)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -218634   -4921    -124    2933 1359517 
## 
## Coefficients: (6 not defined because of singularities)
##                                                                           Estimate
## (Intercept)                                                             -8.297e+03
## IsDenied                                                                -7.719e+03
## Transaction_Time                                                         3.790e+00
## Procesing_Time                                                           2.684e+01
## ClaimantAge_at_DOI                                                       7.796e+01
## GenderMale                                                               3.464e+02
## GenderNot Available                                                      1.910e+04
## ClaimantTypeMedical Only                                                -2.145e+04
## ClaimantTypeReport Only                                                 -2.034e+04
## InjuryNatureAll Other Specific Injuries, Noc                             1.247e+04
## InjuryNatureAmputation                                                   2.060e+04
## InjuryNatureAngina Pectoris                                             -4.732e+03
## InjuryNatureAsbestosis                                                   1.893e+04
## InjuryNatureAsphyxiation                                                 1.144e+04
## InjuryNatureBlack Lung                                                   1.452e+04
## InjuryNatureBurn                                                         1.907e+04
## InjuryNatureCancer                                                       4.086e+04
## InjuryNatureCarpal Tunnel Syndrome                                       1.087e+04
## InjuryNatureConcussion                                                   2.125e+04
## InjuryNatureContagious Disease                                           1.097e+04
## InjuryNatureContusion                                                    1.459e+04
## InjuryNatureCrushing                                                     2.006e+04
## InjuryNatureDermatitis                                                   1.495e+04
## InjuryNatureDislocation                                                  1.439e+04
## InjuryNatureDust Disease, NOC                                            1.660e+04
## InjuryNatureElectric Shock                                               1.222e+04
## InjuryNatureForeign Body                                                 1.327e+04
## InjuryNatureFracture                                                     1.770e+04
## InjuryNatureFreezing                                                     1.055e+04
## InjuryNatureHearing Loss Or Impairment                                   5.991e+03
## InjuryNatureHeat Prostration                                             1.337e+04
## InjuryNatureHernia                                                       1.025e+04
## InjuryNatureInfection                                                    1.262e+04
## InjuryNatureInflammation                                                 1.614e+04
## InjuryNatureLaceration                                                   1.538e+04
## InjuryNatureLoss of Hearing                                              1.026e+04
## InjuryNatureMental Disorder                                              4.663e+03
## InjuryNatureMental Stress                                                9.083e+03
## InjuryNatureMultiple Injuries Including Both Physical and Psychological  2.436e+04
## InjuryNatureMultiple Physical Injuries Only                              1.603e+04
## InjuryNatureMyocardial Infarction                                        1.784e+04
## InjuryNatureNo Physical Injury                                           1.397e+04
## InjuryNatureNon-Standard Code                                            1.260e+04
## InjuryNatureNot Available                                                2.020e+04
## InjuryNaturePoisoning?Chemical (Other Than Metals)                       1.168e+04
## InjuryNaturePoisoning?General (NOT OD or Cumulative Injury)              1.499e+04
## InjuryNaturePuncture                                                     1.554e+04
## InjuryNatureRadiation                                                    1.634e+04
## InjuryNatureRespiratory Disorders                                        1.504e+04
## InjuryNatureRupture                                                      1.978e+04
## InjuryNatureSeverance                                                    4.431e+04
## InjuryNatureSprain                                                       1.603e+04
## InjuryNatureStrain                                                       1.420e+04
## InjuryNatureSyncope                                                      1.878e+04
## InjuryNatureVascular                                                    -5.688e+03
## InjuryNatureVDT-Related Disease                                         -6.460e+03
## InjuryNatureVision Loss                                                  1.726e+04
## BodyPartRegionLower Extremities                                          5.941e+03
## BodyPartRegionMultiple Body Parts                                        1.366e+05
## BodyPartRegionNeck                                                       7.045e+04
## BodyPartRegionNon-Standard Code                                         -7.611e+03
## BodyPartRegionTrunk                                                      3.842e+03
## BodyPartRegionUpper Extremities                                          4.280e+03
## BodyPartAnkle                                                           -2.347e+03
## BodyPartArtificial Appliance                                            -1.340e+05
## BodyPartBody Systems and Multiple Body Systems                          -1.328e+05
## BodyPartBrain                                                            7.677e+04
## BodyPartButtocks                                                         1.310e+03
## BodyPartChest                                                            1.935e+03
## BodyPartDisc-Trunk                                                       7.338e+03
## BodyPartEar(S)                                                           4.185e+03
## BodyPartElbow                                                            1.559e+03
## BodyPartEyes                                                             5.604e+03
## BodyPartFacial Bones                                                     4.260e+03
## BodyPartFinger(S)                                                       -1.706e+03
## BodyPartFoot                                                            -2.774e+03
## BodyPartGreat Toe                                                       -2.750e+03
## BodyPartHand                                                            -5.760e+02
## BodyPartHeart                                                            9.103e+03
## BodyPartHip                                                              1.086e+03
## BodyPartInsufficient Info to Properly Identify?Unclassified             -1.318e+05
## BodyPartInternal Organs                                                 -7.432e+03
## BodyPartKnee                                                             7.782e+02
## BodyPartLarynx                                                          -8.151e+04
## BodyPartLower Arm                                                        4.965e+02
## BodyPartLower Back Area                                                  3.649e+03
## BodyPartLower Leg                                                       -1.822e+03
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk)              4.508e+03
## BodyPartLungs                                                            1.540e+03
## BodyPartMouth                                                            4.116e+03
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts)     -1.301e+05
## BodyPartMultiple Head Injury                                             6.054e+03
## BodyPartMultiple Lower Extremities                                       3.767e+03
## BodyPartMultiple Neck Injury                                            -6.422e+04
## BodyPartMultiple Trunk                                                  -2.386e+03
## BodyPartMultiple Upper Extremities                                       7.155e+01
## BodyPartNo Physical Injury                                              -1.319e+05
## BodyPartNon-Standard Code                                                       NA
## BodyPartNose                                                             4.563e+03
## BodyPartPelvis                                                           4.726e+03
## BodyPartSacrum And Coccyx                                               -1.220e+03
## BodyPartShoulder(S)                                                      3.910e+03
## BodyPartSkull                                                            3.982e+03
## BodyPartSoft Tissue-Head                                                -4.966e+03
## BodyPartSoft Tissue-Neck                                                -6.540e+04
## BodyPartSpinal Cord-Trunk                                                6.031e+03
## BodyPartTeeth                                                                   NA
## BodyPartThumb                                                           -7.054e+02
## BodyPartToes                                                            -2.594e+03
## BodyPartTrachea                                                         -7.360e+04
## BodyPartUpper Arm                                                       -5.681e+02
## BodyPartUpper Back Area                                                  1.986e+03
## BodyPartUpper Leg                                                               NA
## BodyPartVertebrae                                                               NA
## BodyPartWhole Body                                                              NA
## BodyPartWrist                                                                   NA
## AverageWeeklyWage1                                                       4.747e+00
##                                                                         Std. Error
## (Intercept)                                                              2.535e+04
## IsDenied                                                                 7.199e+02
## Transaction_Time                                                         1.631e-01
## Procesing_Time                                                           7.794e-01
## ClaimantAge_at_DOI                                                       1.284e+01
## GenderMale                                                               2.937e+02
## GenderNot Available                                                      2.818e+03
## ClaimantTypeMedical Only                                                 3.762e+02
## ClaimantTypeReport Only                                                  8.225e+02
## InjuryNatureAll Other Specific Injuries, Noc                             2.522e+04
## InjuryNatureAmputation                                                   2.694e+04
## InjuryNatureAngina Pectoris                                              3.133e+04
## InjuryNatureAsbestosis                                                   2.576e+04
## InjuryNatureAsphyxiation                                                 3.567e+04
## InjuryNatureBlack Lung                                                   3.567e+04
## InjuryNatureBurn                                                         2.524e+04
## InjuryNatureCancer                                                       2.818e+04
## InjuryNatureCarpal Tunnel Syndrome                                       2.527e+04
## InjuryNatureConcussion                                                   2.534e+04
## InjuryNatureContagious Disease                                           2.537e+04
## InjuryNatureContusion                                                    2.521e+04
## InjuryNatureCrushing                                                     2.530e+04
## InjuryNatureDermatitis                                                   2.523e+04
## InjuryNatureDislocation                                                  2.529e+04
## InjuryNatureDust Disease, NOC                                            2.917e+04
## InjuryNatureElectric Shock                                               2.554e+04
## InjuryNatureForeign Body                                                 2.523e+04
## InjuryNatureFracture                                                     2.522e+04
## InjuryNatureFreezing                                                     2.909e+04
## InjuryNatureHearing Loss Or Impairment                                   2.600e+04
## InjuryNatureHeat Prostration                                             2.547e+04
## InjuryNatureHernia                                                       2.543e+04
## InjuryNatureInfection                                                    2.533e+04
## InjuryNatureInflammation                                                 2.525e+04
## InjuryNatureLaceration                                                   2.521e+04
## InjuryNatureLoss of Hearing                                              2.613e+04
## InjuryNatureMental Disorder                                              2.774e+04
## InjuryNatureMental Stress                                                2.543e+04
## InjuryNatureMultiple Injuries Including Both Physical and Psychological  2.603e+04
## InjuryNatureMultiple Physical Injuries Only                              2.523e+04
## InjuryNatureMyocardial Infarction                                        2.725e+04
## InjuryNatureNo Physical Injury                                           2.519e+04
## InjuryNatureNon-Standard Code                                            2.541e+04
## InjuryNatureNot Available                                                3.561e+04
## InjuryNaturePoisoning?Chemical (Other Than Metals)                       2.541e+04
## InjuryNaturePoisoning?General (NOT OD or Cumulative Injury)              2.597e+04
## InjuryNaturePuncture                                                     2.522e+04
## InjuryNatureRadiation                                                    2.609e+04
## InjuryNatureRespiratory Disorders                                        2.527e+04
## InjuryNatureRupture                                                      2.556e+04
## InjuryNatureSeverance                                                    2.624e+04
## InjuryNatureSprain                                                       2.521e+04
## InjuryNatureStrain                                                       2.521e+04
## InjuryNatureSyncope                                                      2.545e+04
## InjuryNatureVascular                                                     3.560e+04
## InjuryNatureVDT-Related Disease                                          3.561e+04
## InjuryNatureVision Loss                                                  2.624e+04
## BodyPartRegionLower Extremities                                          3.099e+03
## BodyPartRegionMultiple Body Parts                                        1.476e+04
## BodyPartRegionNeck                                                       1.286e+04
## BodyPartRegionNon-Standard Code                                          4.346e+03
## BodyPartRegionTrunk                                                      3.057e+03
## BodyPartRegionUpper Extremities                                          2.752e+03
## BodyPartAnkle                                                            1.770e+03
## BodyPartArtificial Appliance                                             1.837e+04
## BodyPartBody Systems and Multiple Body Systems                           1.471e+04
## BodyPartBrain                                                            1.536e+04
## BodyPartButtocks                                                         2.965e+03
## BodyPartChest                                                            1.861e+03
## BodyPartDisc-Trunk                                                       2.326e+03
## BodyPartEar(S)                                                           3.859e+03
## BodyPartElbow                                                            1.336e+03
## BodyPartEyes                                                             2.810e+03
## BodyPartFacial Bones                                                     3.104e+03
## BodyPartFinger(S)                                                        9.262e+02
## BodyPartFoot                                                             1.802e+03
## BodyPartGreat Toe                                                        3.405e+03
## BodyPartHand                                                             9.348e+02
## BodyPartHeart                                                            1.110e+04
## BodyPartHip                                                              2.142e+03
## BodyPartInsufficient Info to Properly Identify?Unclassified              1.460e+04
## BodyPartInternal Organs                                                  4.093e+03
## BodyPartKnee                                                             1.665e+03
## BodyPartLarynx                                                           2.811e+04
## BodyPartLower Arm                                                        1.174e+03
## BodyPartLower Back Area                                                  1.571e+03
## BodyPartLower Leg                                                        1.861e+03
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk)              1.881e+03
## BodyPartLungs                                                            2.868e+03
## BodyPartMouth                                                            3.320e+03
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts)      1.452e+04
## BodyPartMultiple Head Injury                                             2.782e+03
## BodyPartMultiple Lower Extremities                                       2.073e+03
## BodyPartMultiple Neck Injury                                             1.263e+04
## BodyPartMultiple Trunk                                                   3.752e+03
## BodyPartMultiple Upper Extremities                                       1.351e+03
## BodyPartNo Physical Injury                                               1.465e+04
## BodyPartNon-Standard Code                                                       NA
## BodyPartNose                                                             3.333e+03
## BodyPartPelvis                                                           3.582e+03
## BodyPartSacrum And Coccyx                                                5.156e+03
## BodyPartShoulder(S)                                                      9.792e+02
## BodyPartSkull                                                            5.215e+03
## BodyPartSoft Tissue-Head                                                 2.537e+04
## BodyPartSoft Tissue-Neck                                                 1.269e+04
## BodyPartSpinal Cord-Trunk                                                4.695e+03
## BodyPartTeeth                                                                   NA
## BodyPartThumb                                                            1.198e+03
## BodyPartToes                                                             2.460e+03
## BodyPartTrachea                                                          1.584e+04
## BodyPartUpper Arm                                                        1.418e+03
## BodyPartUpper Back Area                                                  2.188e+03
## BodyPartUpper Leg                                                               NA
## BodyPartVertebrae                                                               NA
## BodyPartWhole Body                                                              NA
## BodyPartWrist                                                                   NA
## AverageWeeklyWage1                                                       6.648e-01
##                                                                         t value
## (Intercept)                                                              -0.327
## IsDenied                                                                -10.723
## Transaction_Time                                                         23.241
## Procesing_Time                                                           34.437
## ClaimantAge_at_DOI                                                        6.069
## GenderMale                                                                1.179
## GenderNot Available                                                       6.779
## ClaimantTypeMedical Only                                                -57.011
## ClaimantTypeReport Only                                                 -24.731
## InjuryNatureAll Other Specific Injuries, Noc                              0.495
## InjuryNatureAmputation                                                    0.765
## InjuryNatureAngina Pectoris                                              -0.151
## InjuryNatureAsbestosis                                                    0.735
## InjuryNatureAsphyxiation                                                  0.321
## InjuryNatureBlack Lung                                                    0.407
## InjuryNatureBurn                                                          0.755
## InjuryNatureCancer                                                        1.450
## InjuryNatureCarpal Tunnel Syndrome                                        0.430
## InjuryNatureConcussion                                                    0.839
## InjuryNatureContagious Disease                                            0.432
## InjuryNatureContusion                                                     0.579
## InjuryNatureCrushing                                                      0.793
## InjuryNatureDermatitis                                                    0.593
## InjuryNatureDislocation                                                   0.569
## InjuryNatureDust Disease, NOC                                             0.569
## InjuryNatureElectric Shock                                                0.478
## InjuryNatureForeign Body                                                  0.526
## InjuryNatureFracture                                                      0.702
## InjuryNatureFreezing                                                      0.363
## InjuryNatureHearing Loss Or Impairment                                    0.230
## InjuryNatureHeat Prostration                                              0.525
## InjuryNatureHernia                                                        0.403
## InjuryNatureInfection                                                     0.498
## InjuryNatureInflammation                                                  0.639
## InjuryNatureLaceration                                                    0.610
## InjuryNatureLoss of Hearing                                               0.393
## InjuryNatureMental Disorder                                               0.168
## InjuryNatureMental Stress                                                 0.357
## InjuryNatureMultiple Injuries Including Both Physical and Psychological   0.936
## InjuryNatureMultiple Physical Injuries Only                               0.635
## InjuryNatureMyocardial Infarction                                         0.655
## InjuryNatureNo Physical Injury                                            0.555
## InjuryNatureNon-Standard Code                                             0.496
## InjuryNatureNot Available                                                 0.567
## InjuryNaturePoisoning?Chemical (Other Than Metals)                        0.460
## InjuryNaturePoisoning?General (NOT OD or Cumulative Injury)               0.577
## InjuryNaturePuncture                                                      0.616
## InjuryNatureRadiation                                                     0.626
## InjuryNatureRespiratory Disorders                                         0.595
## InjuryNatureRupture                                                       0.774
## InjuryNatureSeverance                                                     1.688
## InjuryNatureSprain                                                        0.636
## InjuryNatureStrain                                                        0.563
## InjuryNatureSyncope                                                       0.738
## InjuryNatureVascular                                                     -0.160
## InjuryNatureVDT-Related Disease                                          -0.181
## InjuryNatureVision Loss                                                   0.658
## BodyPartRegionLower Extremities                                           1.917
## BodyPartRegionMultiple Body Parts                                         9.259
## BodyPartRegionNeck                                                        5.479
## BodyPartRegionNon-Standard Code                                          -1.751
## BodyPartRegionTrunk                                                       1.257
## BodyPartRegionUpper Extremities                                           1.555
## BodyPartAnkle                                                            -1.326
## BodyPartArtificial Appliance                                             -7.298
## BodyPartBody Systems and Multiple Body Systems                           -9.029
## BodyPartBrain                                                             4.999
## BodyPartButtocks                                                          0.442
## BodyPartChest                                                             1.040
## BodyPartDisc-Trunk                                                        3.155
## BodyPartEar(S)                                                            1.085
## BodyPartElbow                                                             1.166
## BodyPartEyes                                                              1.995
## BodyPartFacial Bones                                                      1.372
## BodyPartFinger(S)                                                        -1.842
## BodyPartFoot                                                             -1.540
## BodyPartGreat Toe                                                        -0.808
## BodyPartHand                                                             -0.616
## BodyPartHeart                                                             0.820
## BodyPartHip                                                               0.507
## BodyPartInsufficient Info to Properly Identify?Unclassified              -9.024
## BodyPartInternal Organs                                                  -1.816
## BodyPartKnee                                                              0.468
## BodyPartLarynx                                                           -2.900
## BodyPartLower Arm                                                         0.423
## BodyPartLower Back Area                                                   2.323
## BodyPartLower Leg                                                        -0.979
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk)               2.397
## BodyPartLungs                                                             0.537
## BodyPartMouth                                                             1.240
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts)      -8.962
## BodyPartMultiple Head Injury                                              2.176
## BodyPartMultiple Lower Extremities                                        1.818
## BodyPartMultiple Neck Injury                                             -5.084
## BodyPartMultiple Trunk                                                   -0.636
## BodyPartMultiple Upper Extremities                                        0.053
## BodyPartNo Physical Injury                                               -9.008
## BodyPartNon-Standard Code                                                    NA
## BodyPartNose                                                              1.369
## BodyPartPelvis                                                            1.319
## BodyPartSacrum And Coccyx                                                -0.237
## BodyPartShoulder(S)                                                       3.993
## BodyPartSkull                                                             0.764
## BodyPartSoft Tissue-Head                                                 -0.196
## BodyPartSoft Tissue-Neck                                                 -5.154
## BodyPartSpinal Cord-Trunk                                                 1.285
## BodyPartTeeth                                                                NA
## BodyPartThumb                                                            -0.589
## BodyPartToes                                                             -1.054
## BodyPartTrachea                                                          -4.647
## BodyPartUpper Arm                                                        -0.400
## BodyPartUpper Back Area                                                   0.908
## BodyPartUpper Leg                                                            NA
## BodyPartVertebrae                                                            NA
## BodyPartWhole Body                                                           NA
## BodyPartWrist                                                                NA
## AverageWeeklyWage1                                                        7.142
##                                                                         Pr(>|t|)
## (Intercept)                                                              0.74347
## IsDenied                                                                 < 2e-16
## Transaction_Time                                                         < 2e-16
## Procesing_Time                                                           < 2e-16
## ClaimantAge_at_DOI                                                      1.30e-09
## GenderMale                                                               0.23833
## GenderNot Available                                                     1.23e-11
## ClaimantTypeMedical Only                                                 < 2e-16
## ClaimantTypeReport Only                                                  < 2e-16
## InjuryNatureAll Other Specific Injuries, Noc                             0.62092
## InjuryNatureAmputation                                                   0.44447
## InjuryNatureAngina Pectoris                                              0.87995
## InjuryNatureAsbestosis                                                   0.46247
## InjuryNatureAsphyxiation                                                 0.74850
## InjuryNatureBlack Lung                                                   0.68385
## InjuryNatureBurn                                                         0.45004
## InjuryNatureCancer                                                       0.14709
## InjuryNatureCarpal Tunnel Syndrome                                       0.66718
## InjuryNatureConcussion                                                   0.40163
## InjuryNatureContagious Disease                                           0.66544
## InjuryNatureContusion                                                    0.56277
## InjuryNatureCrushing                                                     0.42772
## InjuryNatureDermatitis                                                   0.55351
## InjuryNatureDislocation                                                  0.56926
## InjuryNatureDust Disease, NOC                                            0.56929
## InjuryNatureElectric Shock                                               0.63246
## InjuryNatureForeign Body                                                 0.59882
## InjuryNatureFracture                                                     0.48279
## InjuryNatureFreezing                                                     0.71675
## InjuryNatureHearing Loss Or Impairment                                   0.81779
## InjuryNatureHeat Prostration                                             0.59969
## InjuryNatureHernia                                                       0.68692
## InjuryNatureInfection                                                    0.61831
## InjuryNatureInflammation                                                 0.52261
## InjuryNatureLaceration                                                   0.54194
## InjuryNatureLoss of Hearing                                              0.69462
## InjuryNatureMental Disorder                                              0.86649
## InjuryNatureMental Stress                                                0.72095
## InjuryNatureMultiple Injuries Including Both Physical and Psychological  0.34935
## InjuryNatureMultiple Physical Injuries Only                              0.52521
## InjuryNatureMyocardial Infarction                                        0.51254
## InjuryNatureNo Physical Injury                                           0.57920
## InjuryNatureNon-Standard Code                                            0.62017
## InjuryNatureNot Available                                                0.57045
## InjuryNaturePoisoning?Chemical (Other Than Metals)                       0.64576
## InjuryNaturePoisoning?General (NOT OD or Cumulative Injury)              0.56380
## InjuryNaturePuncture                                                     0.53781
## InjuryNatureRadiation                                                    0.53122
## InjuryNatureRespiratory Disorders                                        0.55171
## InjuryNatureRupture                                                      0.43919
## InjuryNatureSeverance                                                    0.09137
## InjuryNatureSprain                                                       0.52498
## InjuryNatureStrain                                                       0.57338
## InjuryNatureSyncope                                                      0.46060
## InjuryNatureVascular                                                     0.87306
## InjuryNatureVDT-Related Disease                                          0.85607
## InjuryNatureVision Loss                                                  0.51072
## BodyPartRegionLower Extremities                                          0.05521
## BodyPartRegionMultiple Body Parts                                        < 2e-16
## BodyPartRegionNeck                                                      4.32e-08
## BodyPartRegionNon-Standard Code                                          0.07990
## BodyPartRegionTrunk                                                      0.20881
## BodyPartRegionUpper Extremities                                          0.11998
## BodyPartAnkle                                                            0.18479
## BodyPartArtificial Appliance                                            2.98e-13
## BodyPartBody Systems and Multiple Body Systems                           < 2e-16
## BodyPartBrain                                                           5.80e-07
## BodyPartButtocks                                                         0.65857
## BodyPartChest                                                            0.29850
## BodyPartDisc-Trunk                                                       0.00161
## BodyPartEar(S)                                                           0.27810
## BodyPartElbow                                                            0.24351
## BodyPartEyes                                                             0.04608
## BodyPartFacial Bones                                                     0.17005
## BodyPartFinger(S)                                                        0.06546
## BodyPartFoot                                                             0.12365
## BodyPartGreat Toe                                                        0.41920
## BodyPartHand                                                             0.53779
## BodyPartHeart                                                            0.41210
## BodyPartHip                                                              0.61203
## BodyPartInsufficient Info to Properly Identify?Unclassified              < 2e-16
## BodyPartInternal Organs                                                  0.06940
## BodyPartKnee                                                             0.64014
## BodyPartLarynx                                                           0.00374
## BodyPartLower Arm                                                        0.67244
## BodyPartLower Back Area                                                  0.02020
## BodyPartLower Leg                                                        0.32750
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk)              0.01653
## BodyPartLungs                                                            0.59146
## BodyPartMouth                                                            0.21513
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts)      < 2e-16
## BodyPartMultiple Head Injury                                             0.02956
## BodyPartMultiple Lower Extremities                                       0.06913
## BodyPartMultiple Neck Injury                                            3.72e-07
## BodyPartMultiple Trunk                                                   0.52480
## BodyPartMultiple Upper Extremities                                       0.95777
## BodyPartNo Physical Injury                                               < 2e-16
## BodyPartNon-Standard Code                                                     NA
## BodyPartNose                                                             0.17095
## BodyPartPelvis                                                           0.18702
## BodyPartSacrum And Coccyx                                                0.81288
## BodyPartShoulder(S)                                                     6.55e-05
## BodyPartSkull                                                            0.44510
## BodyPartSoft Tissue-Head                                                 0.84478
## BodyPartSoft Tissue-Neck                                                2.57e-07
## BodyPartSpinal Cord-Trunk                                                0.19893
## BodyPartTeeth                                                                 NA
## BodyPartThumb                                                            0.55583
## BodyPartToes                                                             0.29171
## BodyPartTrachea                                                         3.38e-06
## BodyPartUpper Arm                                                        0.68880
## BodyPartUpper Back Area                                                  0.36399
## BodyPartUpper Leg                                                             NA
## BodyPartVertebrae                                                             NA
## BodyPartWhole Body                                                            NA
## BodyPartWrist                                                                 NA
## AverageWeeklyWage1                                                      9.43e-13
##                                                                            
## (Intercept)                                                                
## IsDenied                                                                ***
## Transaction_Time                                                        ***
## Procesing_Time                                                          ***
## ClaimantAge_at_DOI                                                      ***
## GenderMale                                                                 
## GenderNot Available                                                     ***
## ClaimantTypeMedical Only                                                ***
## ClaimantTypeReport Only                                                 ***
## InjuryNatureAll Other Specific Injuries, Noc                               
## InjuryNatureAmputation                                                     
## InjuryNatureAngina Pectoris                                                
## InjuryNatureAsbestosis                                                     
## InjuryNatureAsphyxiation                                                   
## InjuryNatureBlack Lung                                                     
## InjuryNatureBurn                                                           
## InjuryNatureCancer                                                         
## InjuryNatureCarpal Tunnel Syndrome                                         
## InjuryNatureConcussion                                                     
## InjuryNatureContagious Disease                                             
## InjuryNatureContusion                                                      
## InjuryNatureCrushing                                                       
## InjuryNatureDermatitis                                                     
## InjuryNatureDislocation                                                    
## InjuryNatureDust Disease, NOC                                              
## InjuryNatureElectric Shock                                                 
## InjuryNatureForeign Body                                                   
## InjuryNatureFracture                                                       
## InjuryNatureFreezing                                                       
## InjuryNatureHearing Loss Or Impairment                                     
## InjuryNatureHeat Prostration                                               
## InjuryNatureHernia                                                         
## InjuryNatureInfection                                                      
## InjuryNatureInflammation                                                   
## InjuryNatureLaceration                                                     
## InjuryNatureLoss of Hearing                                                
## InjuryNatureMental Disorder                                                
## InjuryNatureMental Stress                                                  
## InjuryNatureMultiple Injuries Including Both Physical and Psychological    
## InjuryNatureMultiple Physical Injuries Only                                
## InjuryNatureMyocardial Infarction                                          
## InjuryNatureNo Physical Injury                                             
## InjuryNatureNon-Standard Code                                              
## InjuryNatureNot Available                                                  
## InjuryNaturePoisoning?Chemical (Other Than Metals)                         
## InjuryNaturePoisoning?General (NOT OD or Cumulative Injury)                
## InjuryNaturePuncture                                                       
## InjuryNatureRadiation                                                      
## InjuryNatureRespiratory Disorders                                          
## InjuryNatureRupture                                                        
## InjuryNatureSeverance                                                   .  
## InjuryNatureSprain                                                         
## InjuryNatureStrain                                                         
## InjuryNatureSyncope                                                        
## InjuryNatureVascular                                                       
## InjuryNatureVDT-Related Disease                                            
## InjuryNatureVision Loss                                                    
## BodyPartRegionLower Extremities                                         .  
## BodyPartRegionMultiple Body Parts                                       ***
## BodyPartRegionNeck                                                      ***
## BodyPartRegionNon-Standard Code                                         .  
## BodyPartRegionTrunk                                                        
## BodyPartRegionUpper Extremities                                            
## BodyPartAnkle                                                              
## BodyPartArtificial Appliance                                            ***
## BodyPartBody Systems and Multiple Body Systems                          ***
## BodyPartBrain                                                           ***
## 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-Head                                                   
## BodyPartSoft Tissue-Neck                                                ***
## BodyPartSpinal Cord-Trunk                                                  
## BodyPartTeeth                                                              
## BodyPartThumb                                                              
## BodyPartToes                                                               
## BodyPartTrachea                                                         ***
## BodyPartUpper Arm                                                          
## BodyPartUpper Back Area                                                    
## BodyPartUpper Leg                                                          
## BodyPartVertebrae                                                          
## BodyPartWhole Body                                                         
## BodyPartWrist                                                              
## AverageWeeklyWage1                                                      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 25130 on 30894 degrees of freedom
##   (614 observations deleted due to missingness)
## Multiple R-squared:  0.1901, Adjusted R-squared:  0.1872 
## F-statistic: 65.91 on 110 and 30894 DF,  p-value: < 2.2e-16

Evaluar, y en caso necesario, ajustar la regresion

regresion <- lm(TotalIncurredCost ~ IsDenied + Transaction_Time + Procesing_Time  + AverageWeeklyWage1, data=base_de_datos)
summary(regresion)
## 
## Call:
## lm(formula = TotalIncurredCost ~ IsDenied + Transaction_Time + 
##     Procesing_Time + AverageWeeklyWage1, data = base_de_datos)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -262109   -5938   -2872    -415 1383647 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        -5724.0878   447.5092 -12.791  < 2e-16 ***
## IsDenied           -4051.5826   739.9419  -5.476  4.4e-08 ***
## Transaction_Time       3.8910     0.1578  24.651  < 2e-16 ***
## Procesing_Time        30.8933     0.8217  37.595  < 2e-16 ***
## AverageWeeklyWage1    11.5081     0.6943  16.576  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 26850 on 31000 degrees of freedom
##   (614 observations deleted due to missingness)
## Multiple R-squared:  0.07184,    Adjusted R-squared:  0.07172 
## F-statistic: 599.9 on 4 and 31000 DF,  p-value: < 2.2e-16

Construir un modelo de prediccion

datos_nuevos <- data.frame("IsDenied"=1, "Transaction_Time"=2075, "Procesing_Time"=104,  "AverageWeeklyWage1"=491.965)
predict(regresion,datos_nuevos)
##        1 
## 7172.621

Conclusion

El modelo de regresion lineal explica el 39% del comportamiento de las rentas de bicicletas. Este modelo se puede mejorar agregando otras variables que impacten al negocio.

LS0tCnRpdGxlOiAiUmVncmVzaW9uIExpbmVhbCBTZWd1cm9zIgphdXRob3I6ICJDb25zdGFudGlubyBNaWxsZXQgWGFjdXIiCmRhdGU6ICIyMDI0LTA4LTE5IgpvdXRwdXQ6CiAgaHRtbF9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