Importar base de datos

#file.choose()
bd <- read.csv("/Users/dannaperez/Desktop/R/bases de datos/seguros.csv")
resumen <- summary(bd)
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
total_costo <- bd$TotalIncurredCost 

Esta funcion permite contar las veces que el texto aparece igual en la base de datos

#install.packages("dplyr")
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
#count(bd, IncidentDescription, sort=TRUE)
#count(bd, ClaimantType, sort=TRUE)
#count(bd, InjuryNature, sort=TRUE)
#count(bd, BodyPart, sort=TRUE)
#count(bd, BodyPartRegion, sort=TRUE)
#count(bd, ClaimID, sort=TRUE)

Generar un modelo predictivo

regresion <- lm(total_costo ~ ClaimantAge_at_DOI + Gender + ClaimantType + InjuryNature + BodyPartRegion + BodyPart + AverageWeeklyWage1, data = bd)
summary (regresion)
## 
## Call:
## lm(formula = total_costo ~ ClaimantAge_at_DOI + Gender + ClaimantType + 
##     InjuryNature + BodyPartRegion + BodyPart + AverageWeeklyWage1, 
##     data = bd)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -477362  -12697    -550    5168 4673472 
## 
## Coefficients: (6 not defined because of singularities)
##                                                                           Estimate
## (Intercept)                                                             -2.378e+04
## ClaimantAge_at_DOI                                                       1.562e+02
## GenderMale                                                               1.284e+03
## GenderNot Available                                                      6.689e+04
## ClaimantTypeMedical Only                                                -5.558e+04
## ClaimantTypeReport Only                                                 -5.011e+04
## InjuryNatureAll Other Specific Injuries, Noc                             5.673e+04
## InjuryNatureAmputation                                                   3.981e+04
## InjuryNatureAngina Pectoris                                             -3.435e+03
## InjuryNatureAsbestosis                                                   6.414e+04
## InjuryNatureAsphyxiation                                                 6.103e+04
## InjuryNatureBlack Lung                                                   6.015e+04
## InjuryNatureBurn                                                         5.822e+04
## InjuryNatureCancer                                                       6.751e+04
## InjuryNatureCarpal Tunnel Syndrome                                       3.969e+04
## InjuryNatureConcussion                                                   8.513e+04
## InjuryNatureContagious Disease                                           7.377e+04
## InjuryNatureContusion                                                    5.310e+04
## InjuryNatureCrushing                                                     5.680e+04
## InjuryNatureDermatitis                                                   5.106e+04
## InjuryNatureDislocation                                                  3.829e+04
## InjuryNatureDust Disease, NOC                                            5.988e+04
## InjuryNatureElectric Shock                                               6.393e+04
## InjuryNatureForeign Body                                                 5.245e+04
## InjuryNatureFracture                                                     5.006e+04
## InjuryNatureFreezing                                                     4.739e+04
## InjuryNatureHearing Loss Or Impairment                                   4.654e+04
## InjuryNatureHeat Prostration                                             4.574e+04
## InjuryNatureHernia                                                       2.304e+04
## InjuryNatureInfection                                                    4.686e+04
## InjuryNatureInflammation                                                 6.115e+04
## InjuryNatureLaceration                                                   5.288e+04
## InjuryNatureLoss of Hearing                                              4.266e+04
## InjuryNatureMental Disorder                                             -3.827e+04
## InjuryNatureMental Stress                                                5.016e+04
## InjuryNatureMultiple Injuries Including Both Physical and Psychological  3.957e+04
## InjuryNatureMultiple Physical Injuries Only                              5.938e+04
## InjuryNatureMyocardial Infarction                                        3.203e+04
## InjuryNatureNo Physical Injury                                           4.793e+04
## InjuryNatureNon-Standard Code                                            3.735e+04
## InjuryNatureNot Available                                                5.287e+04
## InjuryNaturePoisoning?Chemical (Other Than Metals)                       5.778e+04
## InjuryNaturePoisoning?General (NOT OD or Cumulative Injury)              4.645e+04
## InjuryNaturePuncture                                                     5.340e+04
## InjuryNatureRadiation                                                    5.488e+04
## InjuryNatureRespiratory Disorders                                        5.089e+04
## InjuryNatureRupture                                                      6.257e+04
## InjuryNatureSeverance                                                    8.690e+04
## InjuryNatureSprain                                                       5.235e+04
## InjuryNatureStrain                                                       4.740e+04
## InjuryNatureSyncope                                                      4.655e+04
## InjuryNatureVascular                                                     2.162e+02
## InjuryNatureVDT-Related Disease                                          6.035e+02
## InjuryNatureVision Loss                                                  5.446e+04
## BodyPartRegionLower Extremities                                          1.748e+04
## BodyPartRegionMultiple Body Parts                                        2.913e+05
## BodyPartRegionNeck                                                       5.097e+04
## BodyPartRegionNon-Standard Code                                          5.759e+03
## BodyPartRegionTrunk                                                      8.666e+03
## BodyPartRegionUpper Extremities                                          1.304e+04
## BodyPartAnkle                                                           -6.760e+03
## BodyPartArtificial Appliance                                            -2.843e+05
## BodyPartBody Systems and Multiple Body Systems                          -2.765e+05
## BodyPartBrain                                                            4.126e+05
## BodyPartButtocks                                                         1.879e+04
## BodyPartChest                                                            3.892e+03
## BodyPartDisc-Trunk                                                       1.761e+04
## BodyPartEar(S)                                                           1.043e+04
## BodyPartElbow                                                           -1.760e+02
## BodyPartEyes                                                             1.369e+04
## BodyPartFacial Bones                                                     1.372e+04
## BodyPartFinger(S)                                                       -2.799e+03
## BodyPartFoot                                                            -8.480e+03
## BodyPartGreat Toe                                                       -8.733e+03
## BodyPartHand                                                            -2.864e+03
## BodyPartHeart                                                            6.144e+03
## BodyPartHip                                                              6.854e+03
## BodyPartInsufficient Info to Properly Identify?Unclassified             -2.826e+05
## BodyPartInternal Organs                                                  1.228e+04
## BodyPartKnee                                                            -1.194e+03
## BodyPartLarynx                                                          -8.529e+04
## BodyPartLower Arm                                                       -2.674e+03
## BodyPartLower Back Area                                                  2.532e+04
## BodyPartLower Leg                                                       -5.612e+01
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk)              1.772e+04
## BodyPartLungs                                                           -4.964e+02
## BodyPartMouth                                                            1.350e+04
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts)     -2.711e+05
## BodyPartMultiple Head Injury                                             1.652e+04
## BodyPartMultiple Lower Extremities                                       1.911e+03
## BodyPartMultiple Neck Injury                                            -3.185e+04
## BodyPartMultiple Trunk                                                   6.008e+03
## BodyPartMultiple Upper Extremities                                       4.154e+03
## BodyPartNo Physical Injury                                              -2.756e+05
## BodyPartNon-Standard Code                                                       NA
## BodyPartNose                                                             9.839e+03
## BodyPartPelvis                                                           7.507e+02
## BodyPartSacrum And Coccyx                                                1.936e+04
## BodyPartShoulder(S)                                                      6.654e+03
## BodyPartSkull                                                            4.699e+04
## BodyPartSoft Tissue-Head                                                -1.759e+04
## BodyPartSoft Tissue-Neck                                                -1.805e+04
## BodyPartSpinal Cord-Trunk                                                9.208e+04
## BodyPartTeeth                                                                   NA
## BodyPartThumb                                                           -2.801e+03
## BodyPartToes                                                            -8.322e+03
## BodyPartTrachea                                                         -5.600e+04
## BodyPartUpper Arm                                                        3.218e+03
## BodyPartUpper Back Area                                                  6.851e+03
## BodyPartUpper Leg                                                               NA
## BodyPartVertebrae                                                               NA
## BodyPartWhole Body                                                              NA
## BodyPartWrist                                                                   NA
## AverageWeeklyWage1                                                       8.033e+00
##                                                                         Std. Error
## (Intercept)                                                              8.063e+04
## ClaimantAge_at_DOI                                                       4.036e+01
## GenderMale                                                               9.244e+02
## GenderNot Available                                                      8.412e+03
## ClaimantTypeMedical Only                                                 1.152e+03
## ClaimantTypeReport Only                                                  2.596e+03
## InjuryNatureAll Other Specific Injuries, Noc                             8.019e+04
## InjuryNatureAmputation                                                   8.502e+04
## InjuryNatureAngina Pectoris                                              9.965e+04
## InjuryNatureAsbestosis                                                   8.190e+04
## InjuryNatureAsphyxiation                                                 1.134e+05
## InjuryNatureBlack Lung                                                   1.134e+05
## InjuryNatureBurn                                                         8.029e+04
## InjuryNatureCancer                                                       8.962e+04
## InjuryNatureCarpal Tunnel Syndrome                                       8.036e+04
## InjuryNatureConcussion                                                   8.056e+04
## InjuryNatureContagious Disease                                           8.067e+04
## InjuryNatureContusion                                                    8.018e+04
## InjuryNatureCrushing                                                     8.045e+04
## InjuryNatureDermatitis                                                   8.026e+04
## InjuryNatureDislocation                                                  8.043e+04
## InjuryNatureDust Disease, NOC                                            9.279e+04
## InjuryNatureElectric Shock                                               8.116e+04
## InjuryNatureForeign Body                                                 8.024e+04
## InjuryNatureFracture                                                     8.022e+04
## InjuryNatureFreezing                                                     9.252e+04
## InjuryNatureHearing Loss Or Impairment                                   8.260e+04
## InjuryNatureHeat Prostration                                             8.102e+04
## InjuryNatureHernia                                                       8.088e+04
## InjuryNatureInfection                                                    8.057e+04
## InjuryNatureInflammation                                                 8.029e+04
## InjuryNatureLaceration                                                   8.019e+04
## InjuryNatureLoss of Hearing                                              8.309e+04
## InjuryNatureMental Disorder                                              8.799e+04
## InjuryNatureMental Stress                                                8.077e+04
## InjuryNatureMultiple Injuries Including Both Physical and Psychological  8.279e+04
## InjuryNatureMultiple Physical Injuries Only                              8.025e+04
## InjuryNatureMyocardial Infarction                                        8.664e+04
## InjuryNatureNo Physical Injury                                           8.011e+04
## InjuryNatureNon-Standard Code                                            8.082e+04
## InjuryNatureNot Available                                                1.133e+05
## InjuryNaturePoisoning?Chemical (Other Than Metals)                       8.081e+04
## InjuryNaturePoisoning?General (NOT OD or Cumulative Injury)              8.261e+04
## InjuryNaturePuncture                                                     8.020e+04
## InjuryNatureRadiation                                                    8.297e+04
## InjuryNatureRespiratory Disorders                                        8.038e+04
## InjuryNatureRupture                                                      8.119e+04
## InjuryNatureSeverance                                                    8.321e+04
## InjuryNatureSprain                                                       8.019e+04
## InjuryNatureStrain                                                       8.018e+04
## InjuryNatureSyncope                                                      8.093e+04
## InjuryNatureVascular                                                     1.132e+05
## InjuryNatureVDT-Related Disease                                          1.133e+05
## InjuryNatureVision Loss                                                  8.347e+04
## BodyPartRegionLower Extremities                                          9.834e+03
## BodyPartRegionMultiple Body Parts                                        3.140e+04
## BodyPartRegionNeck                                                       4.088e+04
## BodyPartRegionNon-Standard Code                                          1.367e+04
## BodyPartRegionTrunk                                                      9.718e+03
## BodyPartRegionUpper Extremities                                          8.743e+03
## BodyPartAnkle                                                            5.588e+03
## BodyPartArtificial Appliance                                             4.685e+04
## BodyPartBody Systems and Multiple Body Systems                           3.117e+04
## BodyPartBrain                                                            3.768e+04
## BodyPartButtocks                                                         9.258e+03
## BodyPartChest                                                            5.913e+03
## BodyPartDisc-Trunk                                                       7.302e+03
## BodyPartEar(S)                                                           1.227e+04
## BodyPartElbow                                                            4.234e+03
## BodyPartEyes                                                             8.927e+03
## BodyPartFacial Bones                                                     9.857e+03
## BodyPartFinger(S)                                                        2.933e+03
## BodyPartFoot                                                             5.699e+03
## BodyPartGreat Toe                                                        1.081e+04
## BodyPartHand                                                             2.960e+03
## BodyPartHeart                                                            3.530e+04
## BodyPartHip                                                              6.760e+03
## BodyPartInsufficient Info to Properly Identify?Unclassified              3.066e+04
## BodyPartInternal Organs                                                  1.275e+04
## BodyPartKnee                                                             5.259e+03
## BodyPartLarynx                                                           8.940e+04
## BodyPartLower Arm                                                        3.719e+03
## BodyPartLower Back Area                                                  4.984e+03
## BodyPartLower Leg                                                        5.884e+03
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk)              5.937e+03
## BodyPartLungs                                                            9.118e+03
## BodyPartMouth                                                            1.054e+04
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts)      3.026e+04
## BodyPartMultiple Head Injury                                             8.836e+03
## BodyPartMultiple Lower Extremities                                       6.542e+03
## BodyPartMultiple Neck Injury                                             4.016e+04
## BodyPartMultiple Trunk                                                   1.184e+04
## BodyPartMultiple Upper Extremities                                       4.255e+03
## BodyPartNo Physical Injury                                               3.086e+04
## BodyPartNon-Standard Code                                                       NA
## BodyPartNose                                                             1.060e+04
## BodyPartPelvis                                                           1.139e+04
## BodyPartSacrum And Coccyx                                                1.612e+04
## BodyPartShoulder(S)                                                      3.078e+03
## BodyPartSkull                                                            1.638e+04
## BodyPartSoft Tissue-Head                                                 8.066e+04
## BodyPartSoft Tissue-Neck                                                 4.032e+04
## BodyPartSpinal Cord-Trunk                                                1.418e+04
## BodyPartTeeth                                                                   NA
## BodyPartThumb                                                            3.799e+03
## BodyPartToes                                                             7.792e+03
## BodyPartTrachea                                                          5.036e+04
## BodyPartUpper Arm                                                        4.484e+03
## BodyPartUpper Back Area                                                  6.937e+03
## BodyPartUpper Leg                                                               NA
## BodyPartVertebrae                                                               NA
## BodyPartWhole Body                                                              NA
## BodyPartWrist                                                                   NA
## AverageWeeklyWage1                                                       2.081e+00
##                                                                         t value
## (Intercept)                                                              -0.295
## ClaimantAge_at_DOI                                                        3.871
## GenderMale                                                                1.389
## GenderNot Available                                                       7.952
## ClaimantTypeMedical Only                                                -48.261
## ClaimantTypeReport Only                                                 -19.300
## InjuryNatureAll Other Specific Injuries, Noc                              0.707
## InjuryNatureAmputation                                                    0.468
## InjuryNatureAngina Pectoris                                              -0.034
## InjuryNatureAsbestosis                                                    0.783
## InjuryNatureAsphyxiation                                                  0.538
## InjuryNatureBlack Lung                                                    0.530
## InjuryNatureBurn                                                          0.725
## InjuryNatureCancer                                                        0.753
## InjuryNatureCarpal Tunnel Syndrome                                        0.494
## InjuryNatureConcussion                                                    1.057
## InjuryNatureContagious Disease                                            0.915
## InjuryNatureContusion                                                     0.662
## InjuryNatureCrushing                                                      0.706
## InjuryNatureDermatitis                                                    0.636
## InjuryNatureDislocation                                                   0.476
## InjuryNatureDust Disease, NOC                                             0.645
## InjuryNatureElectric Shock                                                0.788
## InjuryNatureForeign Body                                                  0.654
## InjuryNatureFracture                                                      0.624
## InjuryNatureFreezing                                                      0.512
## InjuryNatureHearing Loss Or Impairment                                    0.563
## InjuryNatureHeat Prostration                                              0.565
## InjuryNatureHernia                                                        0.285
## InjuryNatureInfection                                                     0.582
## InjuryNatureInflammation                                                  0.762
## InjuryNatureLaceration                                                    0.659
## InjuryNatureLoss of Hearing                                               0.513
## InjuryNatureMental Disorder                                              -0.435
## InjuryNatureMental Stress                                                 0.621
## InjuryNatureMultiple Injuries Including Both Physical and Psychological   0.478
## InjuryNatureMultiple Physical Injuries Only                               0.740
## InjuryNatureMyocardial Infarction                                         0.370
## InjuryNatureNo Physical Injury                                            0.598
## InjuryNatureNon-Standard Code                                             0.462
## InjuryNatureNot Available                                                 0.467
## InjuryNaturePoisoning?Chemical (Other Than Metals)                        0.715
## InjuryNaturePoisoning?General (NOT OD or Cumulative Injury)               0.562
## InjuryNaturePuncture                                                      0.666
## InjuryNatureRadiation                                                     0.661
## InjuryNatureRespiratory Disorders                                         0.633
## InjuryNatureRupture                                                       0.771
## InjuryNatureSeverance                                                     1.044
## InjuryNatureSprain                                                        0.653
## InjuryNatureStrain                                                        0.591
## InjuryNatureSyncope                                                       0.575
## InjuryNatureVascular                                                      0.002
## InjuryNatureVDT-Related Disease                                           0.005
## InjuryNatureVision Loss                                                   0.652
## BodyPartRegionLower Extremities                                           1.778
## BodyPartRegionMultiple Body Parts                                         9.277
## BodyPartRegionNeck                                                        1.247
## BodyPartRegionNon-Standard Code                                           0.421
## BodyPartRegionTrunk                                                       0.892
## BodyPartRegionUpper Extremities                                           1.491
## BodyPartAnkle                                                            -1.210
## BodyPartArtificial Appliance                                             -6.068
## BodyPartBody Systems and Multiple Body Systems                           -8.871
## BodyPartBrain                                                            10.951
## BodyPartButtocks                                                          2.030
## BodyPartChest                                                             0.658
## BodyPartDisc-Trunk                                                        2.412
## BodyPartEar(S)                                                            0.850
## BodyPartElbow                                                            -0.042
## BodyPartEyes                                                              1.534
## BodyPartFacial Bones                                                      1.392
## BodyPartFinger(S)                                                        -0.954
## BodyPartFoot                                                             -1.488
## BodyPartGreat Toe                                                        -0.808
## BodyPartHand                                                             -0.967
## BodyPartHeart                                                             0.174
## BodyPartHip                                                               1.014
## BodyPartInsufficient Info to Properly Identify?Unclassified              -9.218
## BodyPartInternal Organs                                                   0.964
## BodyPartKnee                                                             -0.227
## BodyPartLarynx                                                           -0.954
## BodyPartLower Arm                                                        -0.719
## BodyPartLower Back Area                                                   5.080
## BodyPartLower Leg                                                        -0.010
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk)               2.985
## BodyPartLungs                                                            -0.054
## BodyPartMouth                                                             1.281
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts)      -8.957
## BodyPartMultiple Head Injury                                              1.869
## BodyPartMultiple Lower Extremities                                        0.292
## BodyPartMultiple Neck Injury                                             -0.793
## BodyPartMultiple Trunk                                                    0.508
## BodyPartMultiple Upper Extremities                                        0.976
## BodyPartNo Physical Injury                                               -8.930
## BodyPartNon-Standard Code                                                    NA
## BodyPartNose                                                              0.929
## BodyPartPelvis                                                            0.066
## BodyPartSacrum And Coccyx                                                 1.201
## BodyPartShoulder(S)                                                       2.162
## BodyPartSkull                                                             2.868
## BodyPartSoft Tissue-Head                                                 -0.218
## BodyPartSoft Tissue-Neck                                                 -0.448
## BodyPartSpinal Cord-Trunk                                                 6.495
## BodyPartTeeth                                                                NA
## BodyPartThumb                                                            -0.737
## BodyPartToes                                                             -1.068
## BodyPartTrachea                                                          -1.112
## BodyPartUpper Arm                                                         0.718
## BodyPartUpper Back Area                                                   0.988
## BodyPartUpper Leg                                                            NA
## BodyPartVertebrae                                                            NA
## BodyPartWhole Body                                                           NA
## BodyPartWrist                                                                NA
## AverageWeeklyWage1                                                        3.860
##                                                                         Pr(>|t|)
## (Intercept)                                                             0.768018
## ClaimantAge_at_DOI                                                      0.000109
## GenderMale                                                              0.164980
## GenderNot Available                                                     1.90e-15
## ClaimantTypeMedical Only                                                 < 2e-16
## ClaimantTypeReport Only                                                  < 2e-16
## InjuryNatureAll Other Specific Injuries, Noc                            0.479316
## InjuryNatureAmputation                                                  0.639614
## InjuryNatureAngina Pectoris                                             0.972499
## InjuryNatureAsbestosis                                                  0.433548
## InjuryNatureAsphyxiation                                                0.590606
## InjuryNatureBlack Lung                                                  0.595936
## InjuryNatureBurn                                                        0.468425
## InjuryNatureCancer                                                      0.451230
## InjuryNatureCarpal Tunnel Syndrome                                      0.621353
## InjuryNatureConcussion                                                  0.290675
## InjuryNatureContagious Disease                                          0.360437
## InjuryNatureContusion                                                   0.507791
## InjuryNatureCrushing                                                    0.480165
## InjuryNatureDermatitis                                                  0.524685
## InjuryNatureDislocation                                                 0.634034
## InjuryNatureDust Disease, NOC                                           0.518712
## InjuryNatureElectric Shock                                              0.430906
## InjuryNatureForeign Body                                                0.513297
## InjuryNatureFracture                                                    0.532576
## InjuryNatureFreezing                                                    0.608538
## InjuryNatureHearing Loss Or Impairment                                  0.573195
## InjuryNatureHeat Prostration                                            0.572386
## InjuryNatureHernia                                                      0.775742
## InjuryNatureInfection                                                   0.560845
## InjuryNatureInflammation                                                0.446283
## InjuryNatureLaceration                                                  0.509641
## InjuryNatureLoss of Hearing                                             0.607631
## InjuryNatureMental Disorder                                             0.663656
## InjuryNatureMental Stress                                               0.534599
## InjuryNatureMultiple Injuries Including Both Physical and Psychological 0.632666
## InjuryNatureMultiple Physical Injuries Only                             0.459316
## InjuryNatureMyocardial Infarction                                       0.711606
## InjuryNatureNo Physical Injury                                          0.549606
## InjuryNatureNon-Standard Code                                           0.643982
## InjuryNatureNot Available                                               0.640612
## InjuryNaturePoisoning?Chemical (Other Than Metals)                      0.474557
## InjuryNaturePoisoning?General (NOT OD or Cumulative Injury)             0.573890
## InjuryNaturePuncture                                                    0.505543
## InjuryNatureRadiation                                                   0.508337
## InjuryNatureRespiratory Disorders                                       0.526623
## InjuryNatureRupture                                                     0.440943
## InjuryNatureSeverance                                                   0.296341
## InjuryNatureSprain                                                      0.513860
## InjuryNatureStrain                                                      0.554392
## InjuryNatureSyncope                                                     0.565167
## InjuryNatureVascular                                                    0.998477
## InjuryNatureVDT-Related Disease                                         0.995749
## InjuryNatureVision Loss                                                 0.514091
## BodyPartRegionLower Extremities                                         0.075477
## BodyPartRegionMultiple Body Parts                                        < 2e-16
## BodyPartRegionNeck                                                      0.212527
## BodyPartRegionNon-Standard Code                                         0.673656
## BodyPartRegionTrunk                                                     0.372556
## BodyPartRegionUpper Extremities                                         0.135999
## BodyPartAnkle                                                           0.226456
## BodyPartArtificial Appliance                                            1.31e-09
## BodyPartBody Systems and Multiple Body Systems                           < 2e-16
## BodyPartBrain                                                            < 2e-16
## BodyPartButtocks                                                        0.042366
## BodyPartChest                                                           0.510385
## BodyPartDisc-Trunk                                                      0.015884
## BodyPartEar(S)                                                          0.395371
## BodyPartElbow                                                           0.966846
## BodyPartEyes                                                            0.125140
## BodyPartFacial Bones                                                    0.164062
## BodyPartFinger(S)                                                       0.339968
## BodyPartFoot                                                            0.136747
## BodyPartGreat Toe                                                       0.419364
## BodyPartHand                                                            0.333304
## BodyPartHeart                                                           0.861813
## BodyPartHip                                                             0.310615
## BodyPartInsufficient Info to Properly Identify?Unclassified              < 2e-16
## BodyPartInternal Organs                                                 0.335180
## BodyPartKnee                                                            0.820407
## BodyPartLarynx                                                          0.340075
## BodyPartLower Arm                                                       0.472158
## BodyPartLower Back Area                                                 3.80e-07
## BodyPartLower Leg                                                       0.992390
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk)             0.002835
## BodyPartLungs                                                           0.956579
## BodyPartMouth                                                           0.200318
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts)      < 2e-16
## BodyPartMultiple Head Injury                                            0.061608
## BodyPartMultiple Lower Extremities                                      0.770137
## BodyPartMultiple Neck Injury                                            0.427779
## BodyPartMultiple Trunk                                                  0.611717
## BodyPartMultiple Upper Extremities                                      0.328914
## BodyPartNo Physical Injury                                               < 2e-16
## BodyPartNon-Standard Code                                                     NA
## BodyPartNose                                                            0.353155
## BodyPartPelvis                                                          0.947456
## BodyPartSacrum And Coccyx                                               0.229765
## BodyPartShoulder(S)                                                     0.030656
## BodyPartSkull                                                           0.004132
## BodyPartSoft Tissue-Head                                                0.827415
## BodyPartSoft Tissue-Neck                                                0.654345
## BodyPartSpinal Cord-Trunk                                               8.40e-11
## BodyPartTeeth                                                                 NA
## BodyPartThumb                                                           0.460854
## BodyPartToes                                                            0.285566
## BodyPartTrachea                                                         0.266149
## BodyPartUpper Arm                                                       0.472978
## BodyPartUpper Back Area                                                 0.323337
## BodyPartUpper Leg                                                             NA
## BodyPartVertebrae                                                             NA
## BodyPartWhole Body                                                            NA
## BodyPartWrist                                                                 NA
## AverageWeeklyWage1                                                      0.000114
##                                                                            
## (Intercept)                                                                
## 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: 79930 on 31511 degrees of freedom
## Multiple R-squared:  0.1034, Adjusted R-squared:  0.1004 
## F-statistic: 33.98 on 107 and 31511 DF,  p-value: < 2.2e-16

Evaluar y en caso necesario ajustar la regresion lineal

En este caso no tuvimos que ajustar

Elaborar el modelo predictivo

datos_nuevos <- data.frame(ClaimantAge_at_DOI = c(20,30,40,50,60,70,80,90), Gender = "Male", ClaimantType = "Medical Only", InjuryNature = "Amputation",  BodyPartRegion = "Multiple Body Parts", BodyPart = "Brain", AverageWeeklyWage1=537)
predict (regresion,datos_nuevos)
## Warning in predict.lm(regresion, datos_nuevos): prediction from a rank-deficient
## fit may be misleading
##        1        2        3        4        5        6        7        8 
## 673115.3 674677.3 676239.3 677801.3 679363.3 680925.3 682487.3 684049.4

Conclusion

El uso de un modelo predictivo sirve para poder observar los posibles eventos futuros que podrían pasar. En este caso all hospital le sirvió para poder saber que tipo de lesiones son las más costosas y así poder crear un plan para poder prevenirlas