El proyecto proviene de una empresa de Carolina del Norte, EE. UU., que gestiona reclamaciones de compensación laboral para otros clientes (nombre y ubicación protegidos por confidencialidad. Esta empresa quiere que usted les asesore sobre cómo se pueden utilizar los análisis de datos para identificar los principales impulsores de los costos de las reclamaciones y el tiempo para procesar las reclamaciones. La empresa está interesada en utilizar el análisis de datos para ser eficiente y receptiva a los reclamantes. La esencia de la compensación laboral es la siguiente: Cuando un trabajador de una empresa participante se lesiona en el desempeño de su trabajo, Puede presentar un reclamo por los gastos médicos y la pérdida de salario relacionada con la lesión. Cuando se presenta un reclamo por primera vez, se crea un identificador de reclamo único y se registran los detalles de los reclamos. Los detalles del reclamo se actualizan como Los pagos se realizan para resolver el reclamo. Se pueden realizar pagos por diversas actividades relacionadas con un reclamo, como visita al médico, farmacia, etc.
bd3<- merge(claims, transactions, by= "ClaimID", all= TRUE)
bd3$TotalPaid <- as.numeric(bd3$TotalPaid)
bd3$TotalReserves <- as.numeric(bd3$TotalReserves)
bd3$TotalRecovery <- as.numeric(bd3$TotalRecovery)
bd3$IndemnityPaid <- as.numeric(bd3$IndemnityPaid)
bd3$OtherPaid <- as.numeric(bd3$OtherPaid)
bd3$AverageWeeklyWage <- as.numeric(bd3$AverageWeeklyWage)## Warning: NAs introduced by coercion
bd3$BillReviewALE <- as.numeric(bd3$BillReviewALE)
bd3$Hospital <- as.numeric(bd3$Hospital)
bd3$PhysicianOutpatient <- as.numeric(bd3$PhysicianOutpatient)
bd3$Rx <- as.numeric(bd3$Rx)
bd3$ClaimantAge_at_DOI <- as.numeric(bd3$ClaimantAge_at_DOI)## Warning: NAs introduced by coercion
bd3$IncidentDate <- as.Date(bd3$IncidentDate)
bd3$ReturnToWorkDate <- as.Date(bd3$ReturnToWorkDate)
bd3$ClaimantOpenedDate <- as.Date(bd3$ClaimantOpenedDate)
bd3$ClaimantClosedDate <- as.Date(bd3$ClaimantClosedDate)
bd3$EmployerNotificationDate <- as.Date(bd3$EmployerNotificationDate)
bd3$ReceivedDate <- as.Date(bd3$ReceivedDate)
bd3$IsDenied <- as.integer(bd3$IsDenied)
bd3 <- bd3 %>%
mutate(Days_Passed = as.numeric(difftime(ClaimantClosedDate, ClaimantOpenedDate, units = "days")))
bd3 <- bd3 %>%
mutate(Days_To_Notify = as.numeric(difftime(ReceivedDate, EmployerNotificationDate, units = "days")))bd3 <- bd3 %>%
mutate(Total_Incurred_Cost_per_Claim = TotalReserves + IndemnityPaid + OtherPaid - TotalRecovery)
summary(bd3)## ClaimID TotalPaid TotalReserves TotalRecovery
## Min. : 633915 Min. : -270 Min. : 0 Min. : 0.00
## 1st Qu.: 810246 1st Qu.: 60 1st Qu.: 0 1st Qu.: 0.00
## Median : 856915 Median : 235 Median : 0 Median : 0.00
## Mean :12344572 Mean : 6746 Mean : 2233 Mean : 68.88
## 3rd Qu.:22716420 3rd Qu.: 938 3rd Qu.: 0 3rd Qu.: 0.00
## Max. :62246496 Max. :4527291 Max. :2069575 Max. :130541.03
## NA's :52673 NA's :52673 NA's :52673
## IndemnityPaid OtherPaid ClaimStatus IncidentDate
## Min. : -475 Min. : -7820 Length:186677 Min. :1947-02-24
## 1st Qu.: 0 1st Qu.: 58 Class :character 1st Qu.:1998-12-21
## Median : 0 Median : 230 Mode :character Median :2004-01-05
## Mean : 3061 Mean : 3685 Mean :2003-12-08
## 3rd Qu.: 0 3rd Qu.: 855 3rd Qu.:2009-02-02
## Max. :640732 Max. :4129915 Max. :2014-06-27
## NA's :52673 NA's :52673 NA's :52673
## IncidentDescription ReturnToWorkDate AverageWeeklyWage
## Length:186677 Min. :1976-10-29 Min. : 0.0
## Class :character 1st Qu.:2002-04-25 1st Qu.: 300.0
## Mode :character Median :2007-07-09 Median : 492.0
## Mean :2006-06-01 Mean : 587.3
## 3rd Qu.:2011-06-01 3rd Qu.: 660.4
## Max. :2015-05-07 Max. :2024000.0
## NA's :111310 NA's :137597
## ClaimantOpenedDate ClaimantClosedDate EmployerNotificationDate
## Min. :1947-02-24 Min. :1999-06-01 Min. :1972-09-10
## 1st Qu.:1999-02-09 1st Qu.:2005-03-31 1st Qu.:2000-03-13
## Median :2004-02-17 Median :2006-04-04 Median :2004-12-28
## Mean :2004-01-23 Mean :2007-05-24 Mean :2005-08-29
## 3rd Qu.:2009-04-09 3rd Qu.:2009-11-11 3rd Qu.:2009-11-03
## Max. :2014-06-30 Max. :2014-06-30 Max. :9999-07-21
## NA's :52673 NA's :57351 NA's :74961
## ReceivedDate IsDenied ClaimantAge_at_DOI Gender
## Min. :1947-02-24 Min. :0.00 Min. :-8000.00 Length:186677
## 1st Qu.:1999-02-09 1st Qu.:0.00 1st Qu.: 33.00 Class :character
## Median :2004-02-13 Median :0.00 Median : 42.00 Mode :character
## Mean :2004-07-19 Mean :0.04 Mean : 39.85
## 3rd Qu.:2009-02-27 3rd Qu.:0.00 3rd Qu.: 51.00
## Max. :9999-07-21 Max. :1.00 Max. : 94.00
## NA's :52673 NA's :52673 NA's :97751
## ClaimantType InjuryNature BodyPartRegion BodyPart
## Length:186677 Length:186677 Length:186677 Length:186677
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## BillReviewALE Hospital PhysicianOutpatient Rx
## Min. : -456.0 Min. : -12570.4 Min. : -4655.7 Min. : -469.5
## 1st Qu.: 16.0 1st Qu.: 193.9 1st Qu.: 107.6 1st Qu.: 23.3
## Median : 32.0 Median : 559.1 Median : 221.6 Median : 58.3
## Mean : 191.2 Mean : 4394.7 Mean : 1752.3 Mean : 1140.4
## 3rd Qu.: 80.0 3rd Qu.: 2253.4 3rd Qu.: 710.5 3rd Qu.: 174.5
## Max. :56475.3 Max. :2759604.0 Max. :1481468.5 Max. :631635.5
## NA's :139865 NA's :145262 NA's :84986 NA's :145752
## Days_Passed Days_To_Notify Total_Incurred_Cost_per_Claim
## Min. : 0.0 Min. :-2921939.0 Min. : -11775
## 1st Qu.: 161.0 1st Qu.: 3.0 1st Qu.: 59
## Median : 992.5 Median : 7.0 Median : 234
## Mean : 1318.1 Mean : 11.8 Mean : 8910
## 3rd Qu.: 2143.0 3rd Qu.: 19.0 3rd Qu.: 965
## Max. :19177.0 Max. : 2921968.0 Max. :5054823
## NA's :57351 NA's :74961 NA's :52673
regresion <- lm(Total_Incurred_Cost_per_Claim ~ ClaimantAge_at_DOI + Gender + ClaimantType + Days_Passed + IsDenied + BodyPartRegion + BodyPart, data=bd3)
summary(regresion)##
## Call:
## lm(formula = Total_Incurred_Cost_per_Claim ~ ClaimantAge_at_DOI +
## Gender + ClaimantType + Days_Passed + IsDenied + BodyPartRegion +
## BodyPart, data = bd3)
##
## Residuals:
## Min 1Q Median 3Q Max
## -35126 -4290 -139 1896 1373222
##
## Coefficients: (7 not defined because of singularities)
## Estimate
## (Intercept) 1.118e+04
## ClaimantAge_at_DOI 1.227e+00
## GenderMale -2.546e+00
## GenderNot Available 6.057e+03
## ClaimantTypeMedical Only -1.627e+04
## ClaimantTypeReport Only -1.630e+04
## Days_Passed 2.808e+00
## IsDenied -6.030e+03
## BodyPartRegionLower Extremities 4.573e+03
## BodyPartRegionMultiple Body Parts 9.204e+03
## BodyPartRegionNeck 1.829e+04
## BodyPartRegionNon-Standard Code -4.613e+03
## BodyPartRegionNot Available 5.060e+03
## BodyPartRegionTrunk 1.720e+03
## BodyPartRegionUpper Extremities 3.196e+03
## BodyPartAnkle -2.094e+03
## BodyPartArtificial Appliance -7.110e+03
## BodyPartBody Systems and Multiple Body Systems -5.845e+03
## BodyPartBrain 1.310e+04
## BodyPartButtocks 2.011e+03
## BodyPartChest 1.888e+03
## BodyPartDisc-Trunk 4.168e+03
## BodyPartEar(S) 3.018e+03
## BodyPartElbow 6.192e+02
## BodyPartEyes 2.790e+03
## BodyPartFacial Bones 2.855e+03
## BodyPartFinger(S) -1.059e+03
## BodyPartFoot -2.115e+03
## BodyPartGreat Toe -2.292e+03
## BodyPartHand -3.795e+01
## BodyPartHeart 6.099e+02
## BodyPartHip -1.556e+02
## BodyPartInsufficient Info to Properly Identify?Unclassified -5.523e+03
## BodyPartInternal Organs 1.156e+03
## BodyPartKnee 7.218e+02
## BodyPartLarynx -1.845e+04
## BodyPartLower Arm 5.481e+02
## BodyPartLower Back Area 3.286e+03
## BodyPartLower Leg -1.395e+03
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk) 4.497e+03
## BodyPartLungs 2.872e+03
## BodyPartMouth 2.041e+03
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts) -4.396e+03
## BodyPartMultiple Head Injury 4.093e+03
## BodyPartMultiple Lower Extremities 1.146e+03
## BodyPartMultiple Neck Injury -1.329e+04
## BodyPartMultiple Trunk -1.846e+03
## BodyPartMultiple Upper Extremities -3.590e+02
## BodyPartNo Physical Injury -5.968e+03
## BodyPartNon-Standard Code NA
## BodyPartNose 3.964e+03
## BodyPartNot Available NA
## BodyPartPelvis 4.755e+03
## BodyPartSacrum And Coccyx -5.280e+02
## BodyPartShoulder(S) 4.411e+03
## BodyPartSkull 4.354e+03
## BodyPartSoft Tissue-Head 5.134e+03
## BodyPartSoft Tissue-Neck -1.412e+04
## BodyPartSpinal Cord-Trunk -1.888e+03
## BodyPartTeeth NA
## BodyPartThumb -7.151e+02
## BodyPartToes -2.535e+03
## BodyPartTrachea -1.548e+04
## BodyPartUpper Arm 5.184e+02
## BodyPartUpper Back Area 1.688e+03
## BodyPartUpper Leg NA
## BodyPartVertebrae NA
## BodyPartWhole Body NA
## BodyPartWrist NA
## Std. Error
## (Intercept) 1.431e+03
## ClaimantAge_at_DOI 6.012e-01
## GenderMale 1.498e+02
## GenderNot Available 9.807e+02
## ClaimantTypeMedical Only 1.808e+02
## ClaimantTypeReport Only 3.239e+02
## Days_Passed 8.050e-02
## IsDenied 3.329e+02
## BodyPartRegionLower Extremities 1.642e+03
## BodyPartRegionMultiple Body Parts 2.716e+03
## BodyPartRegionNeck 4.952e+03
## BodyPartRegionNon-Standard Code 1.488e+03
## BodyPartRegionNot Available 8.147e+03
## BodyPartRegionTrunk 1.567e+03
## BodyPartRegionUpper Extremities 1.465e+03
## BodyPartAnkle 8.896e+02
## BodyPartArtificial Appliance 8.965e+03
## BodyPartBody Systems and Multiple Body Systems 2.567e+03
## BodyPartBrain 4.011e+03
## BodyPartButtocks 1.367e+03
## BodyPartChest 8.549e+02
## BodyPartDisc-Trunk 1.221e+03
## BodyPartEar(S) 1.775e+03
## BodyPartElbow 6.449e+02
## BodyPartEyes 1.466e+03
## BodyPartFacial Bones 1.628e+03
## BodyPartFinger(S) 4.482e+02
## BodyPartFoot 9.255e+02
## BodyPartGreat Toe 1.845e+03
## BodyPartHand 4.669e+02
## BodyPartHeart 3.650e+03
## BodyPartHip 1.065e+03
## BodyPartInsufficient Info to Properly Identify?Unclassified 2.522e+03
## BodyPartInternal Organs 1.855e+03
## BodyPartKnee 8.569e+02
## BodyPartLarynx 7.747e+03
## BodyPartLower Arm 5.641e+02
## BodyPartLower Back Area 7.026e+02
## BodyPartLower Leg 9.457e+02
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk) 9.852e+02
## BodyPartLungs 1.206e+03
## BodyPartMouth 1.788e+03
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts) 2.328e+03
## BodyPartMultiple Head Injury 1.509e+03
## BodyPartMultiple Lower Extremities 1.162e+03
## BodyPartMultiple Neck Injury 4.784e+03
## BodyPartMultiple Trunk 1.962e+03
## BodyPartMultiple Upper Extremities 7.846e+02
## BodyPartNo Physical Injury 2.436e+03
## BodyPartNon-Standard Code NA
## BodyPartNose 1.795e+03
## BodyPartNot Available NA
## BodyPartPelvis 1.968e+03
## BodyPartSacrum And Coccyx 2.775e+03
## BodyPartShoulder(S) 4.845e+02
## BodyPartSkull 1.638e+03
## BodyPartSoft Tissue-Head 1.610e+03
## BodyPartSoft Tissue-Neck 4.770e+03
## BodyPartSpinal Cord-Trunk 1.383e+03
## BodyPartTeeth NA
## BodyPartThumb 6.154e+02
## BodyPartToes 1.301e+03
## BodyPartTrachea 7.747e+03
## BodyPartUpper Arm 6.943e+02
## BodyPartUpper Back Area 1.024e+03
## BodyPartUpper Leg NA
## BodyPartVertebrae NA
## BodyPartWhole Body NA
## BodyPartWrist NA
## t value
## (Intercept) 7.811
## ClaimantAge_at_DOI 2.041
## GenderMale -0.017
## GenderNot Available 6.176
## ClaimantTypeMedical Only -89.996
## ClaimantTypeReport Only -50.328
## Days_Passed 34.881
## IsDenied -18.115
## BodyPartRegionLower Extremities 2.786
## BodyPartRegionMultiple Body Parts 3.388
## BodyPartRegionNeck 3.693
## BodyPartRegionNon-Standard Code -3.100
## BodyPartRegionNot Available 0.621
## BodyPartRegionTrunk 1.098
## BodyPartRegionUpper Extremities 2.182
## BodyPartAnkle -2.353
## BodyPartArtificial Appliance -0.793
## BodyPartBody Systems and Multiple Body Systems -2.277
## BodyPartBrain 3.267
## BodyPartButtocks 1.471
## BodyPartChest 2.208
## BodyPartDisc-Trunk 3.413
## BodyPartEar(S) 1.701
## BodyPartElbow 0.960
## BodyPartEyes 1.903
## BodyPartFacial Bones 1.754
## BodyPartFinger(S) -2.362
## BodyPartFoot -2.285
## BodyPartGreat Toe -1.243
## BodyPartHand -0.081
## BodyPartHeart 0.167
## BodyPartHip -0.146
## BodyPartInsufficient Info to Properly Identify?Unclassified -2.190
## BodyPartInternal Organs 0.623
## BodyPartKnee 0.842
## BodyPartLarynx -2.381
## BodyPartLower Arm 0.972
## BodyPartLower Back Area 4.677
## BodyPartLower Leg -1.475
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk) 4.565
## BodyPartLungs 2.381
## BodyPartMouth 1.142
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts) -1.888
## BodyPartMultiple Head Injury 2.711
## BodyPartMultiple Lower Extremities 0.986
## BodyPartMultiple Neck Injury -2.779
## BodyPartMultiple Trunk -0.941
## BodyPartMultiple Upper Extremities -0.458
## BodyPartNo Physical Injury -2.450
## BodyPartNon-Standard Code NA
## BodyPartNose 2.208
## BodyPartNot Available NA
## BodyPartPelvis 2.416
## BodyPartSacrum And Coccyx -0.190
## BodyPartShoulder(S) 9.104
## BodyPartSkull 2.659
## BodyPartSoft Tissue-Head 3.189
## BodyPartSoft Tissue-Neck -2.960
## BodyPartSpinal Cord-Trunk -1.365
## BodyPartTeeth NA
## BodyPartThumb -1.162
## BodyPartToes -1.949
## BodyPartTrachea -1.998
## BodyPartUpper Arm 0.747
## BodyPartUpper Back Area 1.648
## BodyPartUpper Leg NA
## BodyPartVertebrae NA
## BodyPartWhole Body NA
## BodyPartWrist NA
## Pr(>|t|)
## (Intercept) 5.73e-15
## ClaimantAge_at_DOI 0.041265
## GenderMale 0.986441
## GenderNot Available 6.60e-10
## ClaimantTypeMedical Only < 2e-16
## ClaimantTypeReport Only < 2e-16
## Days_Passed < 2e-16
## IsDenied < 2e-16
## BodyPartRegionLower Extremities 0.005344
## BodyPartRegionMultiple Body Parts 0.000704
## BodyPartRegionNeck 0.000222
## BodyPartRegionNon-Standard Code 0.001938
## BodyPartRegionNot Available 0.534574
## BodyPartRegionTrunk 0.272367
## BodyPartRegionUpper Extremities 0.029127
## BodyPartAnkle 0.018613
## BodyPartArtificial Appliance 0.427733
## BodyPartBody Systems and Multiple Body Systems 0.022787
## BodyPartBrain 0.001089
## BodyPartButtocks 0.141424
## BodyPartChest 0.027237
## BodyPartDisc-Trunk 0.000642
## BodyPartEar(S) 0.089035
## BodyPartElbow 0.336940
## BodyPartEyes 0.057075
## BodyPartFacial Bones 0.079401
## BodyPartFinger(S) 0.018169
## BodyPartFoot 0.022306
## BodyPartGreat Toe 0.214022
## BodyPartHand 0.935220
## BodyPartHeart 0.867283
## BodyPartHip 0.883857
## BodyPartInsufficient Info to Properly Identify?Unclassified 0.028542
## BodyPartInternal Organs 0.533352
## BodyPartKnee 0.399590
## BodyPartLarynx 0.017268
## BodyPartLower Arm 0.331292
## BodyPartLower Back Area 2.92e-06
## BodyPartLower Leg 0.140240
## BodyPartLumbar and/or Sacral Vertebrae (Vertebra NOC Trunk) 5.01e-06
## BodyPartLungs 0.017284
## BodyPartMouth 0.253519
## BodyPartMultiple Body Parts (Including Body Systems and Body Parts) 0.059009
## BodyPartMultiple Head Injury 0.006702
## BodyPartMultiple Lower Extremities 0.323973
## BodyPartMultiple Neck Injury 0.005454
## BodyPartMultiple Trunk 0.346853
## BodyPartMultiple Upper Extremities 0.647249
## BodyPartNo Physical Injury 0.014273
## BodyPartNon-Standard Code NA
## BodyPartNose 0.027263
## BodyPartNot Available NA
## BodyPartPelvis 0.015693
## BodyPartSacrum And Coccyx 0.849074
## BodyPartShoulder(S) < 2e-16
## BodyPartSkull 0.007848
## BodyPartSoft Tissue-Head 0.001429
## BodyPartSoft Tissue-Neck 0.003073
## BodyPartSpinal Cord-Trunk 0.172388
## BodyPartTeeth NA
## BodyPartThumb 0.245242
## BodyPartToes 0.051301
## BodyPartTrachea 0.045675
## BodyPartUpper Arm 0.455256
## BodyPartUpper Back Area 0.099408
## BodyPartUpper Leg NA
## BodyPartVertebrae NA
## BodyPartWhole Body NA
## BodyPartWrist NA
##
## (Intercept) ***
## ClaimantAge_at_DOI *
## GenderMale
## GenderNot Available ***
## ClaimantTypeMedical Only ***
## ClaimantTypeReport Only ***
## Days_Passed ***
## IsDenied ***
## BodyPartRegionLower Extremities **
## BodyPartRegionMultiple Body Parts ***
## BodyPartRegionNeck ***
## BodyPartRegionNon-Standard Code **
## BodyPartRegionNot Available
## 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 *
## BodyPartNot Available
## 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
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 21210 on 84227 degrees of freedom
## (102388 observations deleted due to missingness)
## Multiple R-squared: 0.1232, Adjusted R-squared: 0.1226
## F-statistic: 194 on 61 and 84227 DF, p-value: < 2.2e-16
## Gender Sort n
## 1 Female TRUE 59197
## 2 Male TRUE 65125
## 3 Not Available TRUE 9682
## 4 <NA> TRUE 52673
## ClaimantType Sort n
## 1 Indemnity TRUE 33726
## 2 Medical Only TRUE 87943
## 3 Report Only TRUE 12335
## 4 <NA> TRUE 52673
## IsDenied Sort n
## 1 0 TRUE 128008
## 2 1 TRUE 5996
## 3 NA TRUE 52673
## InjuryNature n
## 1 <NA> 52673
## 2 Strain 32135
## 3 Contusion 27853
## 4 Non-Standard Code 13777
## 5 All Other Specific Injuries, Noc 12232
## 6 Sprain 11150
## 7 Laceration 9378
## 8 Puncture 4743
## 9 Fracture 3353
## 10 Foreign Body 3228
## 11 Multiple Physical Injuries Only 2357
## 12 No Physical Injury 1862
## 13 Dermatitis 1719
## 14 Inflammation 1466
## 15 Burn 1368
## 16 Respiratory Disorders 997
## 17 Carpal Tunnel Syndrome 842
## 18 Crushing 823
## 19 Concussion 698
## 20 Dislocation 475
## 21 Contagious Disease 456
## 22 Infection 396
## 23 Not Available 362
## 24 Poisoning?Chemical (Other Than Metals) 293
## 25 Hernia 242
## 26 Mental Stress 239
## 27 Heat Prostration 202
## 28 Syncope 159
## 29 Rupture 158
## 30 Electric Shock 150
## 31 Poisoning?General (NOT OD or Cumulative Injury) 146
## 32 Severance 92
## 33 Hearing Loss Or Impairment 82
## 34 Amputation 71
## 35 Loss of Hearing 67
## 36 Asbestosis 66
## 37 Multiple Injuries Including Both Physical and Psychological 63
## 38 All Other Cumulative Injury, NOC 45
## 39 Vision Loss 38
## 40 Myocardial Infarction 33
## 41 Radiation 31
## 42 Dust Disease, NOC 21
## 43 All Other Occupational Disease Injury, NOC 19
## 44 Angina Pectoris 18
## 45 Mental Disorder 18
## 46 Asphyxiation 15
## 47 Cancer 14
## 48 Vascular 13
## 49 AIDS 12
## 50 Freezing 9
## 51 Silicosis 6
## 52 VDT-Related Disease 6
## 53 Black Lung 4
## 54 Poisoning?Metal 2
## BodyPartRegion n
## 1 <NA> 52673
## 2 Upper Extremities 38952
## 3 Lower Extremities 27609
## 4 Trunk 21223
## 5 Multiple Body Parts 16380
## 6 Head 12832
## 7 Non-Standard Code 12651
## 8 Neck 4349
## 9 Not Available 8
## BodyPart n
## 1 <NA> 52673
## 2 Multiple Body Parts (Including Body Systems and Body Parts) 13884
## 3 Non-Standard Code 12651
## 4 Lower Back Area 12458
## 5 Knee 11108
## 6 Finger(S) 9287
## 7 Hand 7343
## 8 Ankle 5685
## 9 Shoulder(S) 5251
## 10 Wrist 5089
## 11 Eyes 5083
## 12 Foot 3682
## 13 Lower Arm 2952
## 14 Multiple Head Injury 2906
## 15 Lower Leg 2764
## 16 Thumb 2646
## 17 Upper Arm 2432
## 18 Soft Tissue-Neck 2425
## 19 Chest 2210
## 20 Elbow 2104
## 21 Multiple Neck Injury 1868
## 22 Multiple Upper Extremities 1848
## 23 Hip 1448
## 24 Abdomen 1240
## 25 Lumbar and/or Sacral Vertebrae (Vertebra NOC Trunk) 1204
## 26 No Physical Injury 1169
## 27 Multiple Lower Extremities 1129
## 28 Facial Bones 1073
## 29 Disc-Trunk 978
## 30 Upper Back Area 978
## 31 Soft Tissue-Head 956
## 32 Upper Leg 944
## 33 Skull 750
## 34 Insufficient Info to Properly Identify?Unclassified 713
## 35 Toes 661
## 36 Mouth 620
## 37 Lungs 570
## 38 Nose 556
## 39 Ear(S) 550
## 40 Body Systems and Multiple Body Systems 507
## 41 Buttocks 404
## 42 Spinal Cord-Trunk 335
## 43 Internal Organs 316
## 44 Teeth 292
## 45 Multiple Trunk 222
## 46 Great Toe 188
## 47 Pelvis 172
## 48 Whole Body 96
## 49 Sacrum And Coccyx 89
## 50 Heart 47
## 51 Brain 46
## 52 Vertebrae 26
## 53 Trachea 17
## 54 Larynx 13
## 55 Artificial Appliance 11
## 56 Not Available 8
datos<- data.frame(ClaimantAge_at_DOI=39.85 , Gender= "Male" , ClaimantType="Medical Only" ,Days_Passed= 1318.1 , IsDenied=0 , BodyPartRegion= "Upper Extremities", BodyPart= "Lower Back Area")
predict(regresion,datos)## Warning in predict.lm(regresion, datos): prediction from rank-deficient fit;
## attr(*, "non-estim") has doubtful cases
## 1
## 5140.915
## attr(,"non-estim")
## 1
## 1
bd_arbol <- select(bd3, Total_Incurred_Cost_per_Claim, Gender)
sapply(bd_arbol, function(x) sum(is.na(x)))## Total_Incurred_Cost_per_Claim Gender
## 52673 52673
bd_arbol <- na.omit(bd_arbol)
a_costo <- rpart(formula = Gender ~ ., data=bd_arbol)
rpart.plot(a_costo)## Gender BodyPartRegion
## 52673 52673
## ClaimantType Gender
## 52673 52673
#Costo total y los dias que lleva abierta la claim
clusters_datos <- bd3%>%
select(Total_Incurred_Cost_per_Claim,Days_Passed)
grupos <- 3
clusters_datos<- na.omit(clusters_datos)
clusters_datos<- clusters_datos[clusters_datos$Total_Incurred_Cost_per_Claim >= 0,]
boxplot(clusters_datos$Total_Incurred_Cost_per_Claim, horizontal= TRUE)## [1] 742.9825
## [1] 1981
## Total_Incurred_Cost_per_Claim Days_Passed
## Min. : 0.0 Min. : 0
## 1st Qu.: 51.8 1st Qu.: 161
## Median : 219.9 Median : 992
## Mean : 4083.0 Mean : 1318
## 3rd Qu.: 794.7 3rd Qu.: 2142
## Max. :1758919.5 Max. :19177
## [1] 1909.174
## [1] 5113.5
clusters_datos<- clusters_datos[clusters_datos$Total_Incurred_Cost_per_Claim <= 1909.174,]
clusters_datos<- clusters_datos[clusters_datos$Days_Passed <= 5113.5,]
summary(clusters_datos)## Total_Incurred_Cost_per_Claim Days_Passed
## Min. : 0.00 Min. : 0
## 1st Qu.: 11.72 1st Qu.: 134
## Median : 160.66 Median : 971
## Mean : 302.20 Mean :1298
## 3rd Qu.: 388.39 3rd Qu.:2163
## Max. :1909.07 Max. :5091
clusters_datos <- as.data.frame(scale(clusters_datos))
segmentos <- kmeans(clusters_datos, grupos)
#head(segmentos)# set.seed(123) # Establece una semilla para reproducibilidad
# indices_muestra <- sample(1:nrow(clusters_datos), size = 20000, replace = FALSE)
# clusters_datos_muestra <- clusters_datos[indices_muestra, ]
# optimizacion <- clusGap(clusters_datos_muestra, FUN=kmeans, nstart=1, K.max=10)
# plot(optimizacion,
# xlab= "Número de clusters k")
# La optimización del cluster tuvo que hacerse con una muestra de 20000 observaciones de la base de datos original debido a que no hubo otra manera de obtener la visualización del cluster. Se intentó en diversas computadoras, incluso se dejó correr el código por 10 horas sin éxito. El gráfico que se muestra a continuación es el resultado del código incluido en este cluster.