Diabetes 130-US hospitals for years 1999-2008

Los datos provienen del Centro de Investigación Clínica y Traslacional de la Virginia Commonwealth University. Reflejan Informacion de pacientes con diabetes en 130 hospitales de EE. UU. Durante un período de diez años desde 1999 hasta 2008. Hay más de 100.000 ingresos hospitalarios únicos en este conjunto de datos, de aproximadamente 70.000 pacientes únicos. Los datos incluyen elementos demográficos, como edad, sexo y raza, así como atributos clínicos como pruebas realizadas, visitas de emergencia

Objetivos - Identificar diferentes insights asociados a los típos de readmisión de los pacientes.

Metodología:

Se realizó una etapa de preparación de datos. Posteriormente se exploraron los datos de manera univariada y multivariada. Acto seguido, se realiza elproceso de feature engineering y se construye el set de entrenamiento y validación. Finalmente, se propone el modelo XGBoost como estrategia de clasificación.

Carga de Datos

#Data Loading----

ds<- read.csv('diabetic_data.csv')
dim(ds)
## [1] 101766     50
names(ds)
##  [1] "encounter_id"             "patient_nbr"             
##  [3] "race"                     "gender"                  
##  [5] "age"                      "weight"                  
##  [7] "admission_type_id"        "discharge_disposition_id"
##  [9] "admission_source_id"      "time_in_hospital"        
## [11] "payer_code"               "medical_specialty"       
## [13] "num_lab_procedures"       "num_procedures"          
## [15] "num_medications"          "number_outpatient"       
## [17] "number_emergency"         "number_inpatient"        
## [19] "diag_1"                   "diag_2"                  
## [21] "diag_3"                   "number_diagnoses"        
## [23] "max_glu_serum"            "A1Cresult"               
## [25] "metformin"                "repaglinide"             
## [27] "nateglinide"              "chlorpropamide"          
## [29] "glimepiride"              "acetohexamide"           
## [31] "glipizide"                "glyburide"               
## [33] "tolbutamide"              "pioglitazone"            
## [35] "rosiglitazone"            "acarbose"                
## [37] "miglitol"                 "troglitazone"            
## [39] "tolazamide"               "examide"                 
## [41] "citoglipton"              "insulin"                 
## [43] "glyburide.metformin"      "glipizide.metformin"     
## [45] "glimepiride.pioglitazone" "metformin.rosiglitazone" 
## [47] "metformin.pioglitazone"   "change"                  
## [49] "diabetesMed"              "readmitted"
#head(ds)
dim(ds)
## [1] 101766     50

Se cuenta con 101766 registros y 50 variables

Datos Faltantes y manipulación de datos

#Data Preparation---
round(sapply(ds, function(x) sum(x=="?"))/101766*100,2) 
##             encounter_id              patient_nbr                     race 
##                     0.00                     0.00                     2.23 
##                   gender                      age                   weight 
##                     0.00                     0.00                    96.86 
##        admission_type_id discharge_disposition_id      admission_source_id 
##                     0.00                     0.00                     0.00 
##         time_in_hospital               payer_code        medical_specialty 
##                     0.00                    39.56                    49.08 
##       num_lab_procedures           num_procedures          num_medications 
##                     0.00                     0.00                     0.00 
##        number_outpatient         number_emergency         number_inpatient 
##                     0.00                     0.00                     0.00 
##                   diag_1                   diag_2                   diag_3 
##                     0.02                     0.35                     1.40 
##         number_diagnoses            max_glu_serum                A1Cresult 
##                     0.00                     0.00                     0.00 
##                metformin              repaglinide              nateglinide 
##                     0.00                     0.00                     0.00 
##           chlorpropamide              glimepiride            acetohexamide 
##                     0.00                     0.00                     0.00 
##                glipizide                glyburide              tolbutamide 
##                     0.00                     0.00                     0.00 
##             pioglitazone            rosiglitazone                 acarbose 
##                     0.00                     0.00                     0.00 
##                 miglitol             troglitazone               tolazamide 
##                     0.00                     0.00                     0.00 
##                  examide              citoglipton                  insulin 
##                     0.00                     0.00                     0.00 
##      glyburide.metformin      glipizide.metformin glimepiride.pioglitazone 
##                     0.00                     0.00                     0.00 
##  metformin.rosiglitazone   metformin.pioglitazone                   change 
##                     0.00                     0.00                     0.00 
##              diabetesMed               readmitted 
##                     0.00                     0.00
ds<-ds[,c(-6,-11,-12)]
#str(ds)
dim(ds)
## [1] 101766     47

Como se puede observar existen campos con una alta proporción de datos faltantes, por lo que no se tendrán en cuenta en el análisis.

Estos campos son:

Por otro lado,existen campos 13 campos numéricos y 37 categóricos:

str(ds)
## 'data.frame':    101766 obs. of  47 variables:
##  $ encounter_id            : int  2278392 149190 64410 500364 16680 35754 55842 63768 12522 15738 ...
##  $ patient_nbr             : int  8222157 55629189 86047875 82442376 42519267 82637451 84259809 114882984 48330783 63555939 ...
##  $ race                    : Factor w/ 6 levels "?","AfricanAmerican",..: 4 4 2 4 4 4 4 4 4 4 ...
##  $ gender                  : Factor w/ 3 levels "Female","Male",..: 1 1 1 2 2 2 2 2 1 1 ...
##  $ age                     : Factor w/ 10 levels "[0-10)","[10-20)",..: 1 2 3 4 5 6 7 8 9 10 ...
##  $ admission_type_id       : int  6 1 1 1 1 2 3 1 2 3 ...
##  $ discharge_disposition_id: int  25 1 1 1 1 1 1 1 1 3 ...
##  $ admission_source_id     : int  1 7 7 7 7 2 2 7 4 4 ...
##  $ time_in_hospital        : int  1 3 2 2 1 3 4 5 13 12 ...
##  $ num_lab_procedures      : int  41 59 11 44 51 31 70 73 68 33 ...
##  $ num_procedures          : int  0 0 5 1 0 6 1 0 2 3 ...
##  $ num_medications         : int  1 18 13 16 8 16 21 12 28 18 ...
##  $ number_outpatient       : int  0 0 2 0 0 0 0 0 0 0 ...
##  $ number_emergency        : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ number_inpatient        : int  0 0 1 0 0 0 0 0 0 0 ...
##  $ diag_1                  : Factor w/ 717 levels "?","10","11",..: 126 145 456 556 56 265 265 278 254 284 ...
##  $ diag_2                  : Factor w/ 749 levels "?","11","110",..: 1 81 80 99 26 248 248 316 262 48 ...
##  $ diag_3                  : Factor w/ 790 levels "?","11","110",..: 1 123 768 250 88 88 772 88 231 319 ...
##  $ number_diagnoses        : int  1 9 6 7 5 9 7 8 8 8 ...
##  $ max_glu_serum           : Factor w/ 4 levels ">200",">300",..: 3 3 3 3 3 3 3 3 3 3 ...
##  $ A1Cresult               : Factor w/ 4 levels ">7",">8","None",..: 3 3 3 3 3 3 3 3 3 3 ...
##  $ metformin               : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 3 2 2 2 ...
##  $ repaglinide             : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ nateglinide             : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ chlorpropamide          : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ glimepiride             : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 3 2 2 2 ...
##  $ acetohexamide           : Factor w/ 2 levels "No","Steady": 1 1 1 1 1 1 1 1 1 1 ...
##  $ glipizide               : Factor w/ 4 levels "Down","No","Steady",..: 2 2 3 2 3 2 2 2 3 2 ...
##  $ glyburide               : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 3 2 2 ...
##  $ tolbutamide             : Factor w/ 2 levels "No","Steady": 1 1 1 1 1 1 1 1 1 1 ...
##  $ pioglitazone            : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ rosiglitazone           : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 3 ...
##  $ acarbose                : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ miglitol                : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ troglitazone            : Factor w/ 2 levels "No","Steady": 1 1 1 1 1 1 1 1 1 1 ...
##  $ tolazamide              : Factor w/ 3 levels "No","Steady",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ examide                 : Factor w/ 1 level "No": 1 1 1 1 1 1 1 1 1 1 ...
##  $ citoglipton             : Factor w/ 1 level "No": 1 1 1 1 1 1 1 1 1 1 ...
##  $ insulin                 : Factor w/ 4 levels "Down","No","Steady",..: 2 4 2 4 3 3 3 2 3 3 ...
##  $ glyburide.metformin     : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ glipizide.metformin     : Factor w/ 2 levels "No","Steady": 1 1 1 1 1 1 1 1 1 1 ...
##  $ glimepiride.pioglitazone: Factor w/ 2 levels "No","Steady": 1 1 1 1 1 1 1 1 1 1 ...
##  $ metformin.rosiglitazone : Factor w/ 2 levels "No","Steady": 1 1 1 1 1 1 1 1 1 1 ...
##  $ metformin.pioglitazone  : Factor w/ 2 levels "No","Steady": 1 1 1 1 1 1 1 1 1 1 ...
##  $ change                  : Factor w/ 2 levels "Ch","No": 2 1 2 1 1 2 1 2 1 1 ...
##  $ diabetesMed             : Factor w/ 2 levels "No","Yes": 1 2 2 2 2 2 2 2 2 2 ...
##  $ readmitted              : Factor w/ 3 levels "<30",">30","NO": 3 2 3 3 3 2 3 2 3 3 ...

Teniendo en cuenta que algunos campos numéricos no aportan mucha información (por ejemplo el lugar codificado desde que los pacientes fueron dados de alta “discharge_disposition_id”), pero si lo pueden hacer como variables categóricas, se procede a redefinirlos como factores.

#Cambiar algunos numéricos a factor
ds$admission_source_id<- as.factor(ds$admission_source_id)
levels(ds$admission_source_id)
##  [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "13" "14" "17" "20"
## [16] "22" "25"
ds$admission_type_id<- as.factor(ds$admission_type_id)
levels(ds$admission_type_id)
## [1] "1" "2" "3" "4" "5" "6" "7" "8"
ds$discharge_disposition_id<-as.factor(ds$discharge_disposition_id)
levels(ds$discharge_disposition_id)
##  [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15"
## [16] "16" "17" "18" "19" "20" "22" "23" "24" "25" "27" "28"

Campos Numéricos

A continuación,se procesan los campos numéricos (excluyendo los Ids) para identificar sus características y su posible grado de asociación entre sí y a su vez con la variable repuesta (“Readmittion”). Recordando que puede tomar los siguientes valores:

A continuación, se muestran los gráficos de densidad y boxplot para estas variables. Posteriormene se realiza una prueba Tukey para explorar la significancia de cada una de ella respecto del tipo de readmisión.

Tiempo de estadía en el Hospital

## 
##  Descriptive statistics by group 
## group: <30
##    vars     n mean   sd median trimmed  mad min max range skew kurtosis   se
## X1    1 11357 4.77 3.03      4    4.43 2.97   1  14    13 0.98     0.47 0.03
## ------------------------------------------------------------ 
## group: >30
##    vars     n mean   sd median trimmed  mad min max range skew kurtosis   se
## X1    1 35545  4.5 2.99      4    4.11 2.97   1  14    13  1.1     0.76 0.02
## ------------------------------------------------------------ 
## group: NO
##    vars     n mean   sd median trimmed  mad min max range skew kurtosis   se
## X1    1 54864 4.25 2.96      3    3.83 2.97   1  14    13  1.2     1.02 0.01
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = num$time_in_hospital ~ ds$readmitted)
## 
## $`ds$readmitted`
##               diff        lwr        upr p adj
## >30-<30 -0.2727078 -0.3479940 -0.1974216     0
## NO-<30  -0.5138195 -0.5858246 -0.4418145     0
## NO->30  -0.2411117 -0.2886686 -0.1935548     0

Número de Exámenes de Laboratorio

## 
##  Descriptive statistics by group 
## group: <30
##    vars     n  mean    sd median trimmed   mad min max range  skew kurtosis
## X1    1 11357 44.23 19.28     45      45 17.79   1 132   131 -0.28    -0.13
##      se
## X1 0.18
## ------------------------------------------------------------ 
## group: >30
##    vars     n  mean    sd median trimmed   mad min max range  skew kurtosis  se
## X1    1 35545 43.84 19.57     45   44.64 19.27   1 129   128 -0.29    -0.22 0.1
## ------------------------------------------------------------ 
## group: NO
##    vars     n  mean   sd median trimmed   mad min max range  skew kurtosis   se
## X1    1 54864 42.38 19.8     44   42.97 19.27   1 126   125 -0.19    -0.27 0.08
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = num$num_lab_procedures ~ ds$readmitted)
## 
## $`ds$readmitted`
##               diff        lwr        upr     p adj
## >30-<30 -0.3894265 -0.8860641  0.1072111 0.1573457
## NO-<30  -1.8444299 -2.3194230 -1.3694367 0.0000000
## NO->30  -1.4550034 -1.7687202 -1.1412865 0.0000000

Número de Procedimientos

## 
##  Descriptive statistics by group 
## group: <30
##    vars     n mean   sd median trimmed  mad min max range skew kurtosis   se
## X1    1 11357 1.28 1.64      1    0.96 1.48   0   6     6 1.38     1.17 0.02
## ------------------------------------------------------------ 
## group: >30
##    vars     n mean   sd median trimmed  mad min max range skew kurtosis   se
## X1    1 35545 1.25 1.67      1    0.92 1.48   0   6     6 1.41     1.16 0.01
## ------------------------------------------------------------ 
## group: NO
##    vars     n mean   sd median trimmed  mad min max range skew kurtosis   se
## X1    1 54864 1.41 1.74      1    1.09 1.48   0   6     6 1.24     0.63 0.01
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = num$num_procedures ~ ds$readmitted)
## 
## $`ds$readmitted`
##                diff         lwr       upr     p adj
## >30-<30 -0.03128494 -0.07433457 0.0117647 0.2039427
## NO-<30   0.12942145  0.08824800 0.1705949 0.0000000
## NO->30   0.16070638  0.13351272 0.1879000 0.0000000

Número de Medicamentos

## 
##  Descriptive statistics by group 
## group: <30
##    vars     n mean  sd median trimmed  mad min max range skew kurtosis   se
## X1    1 11357 16.9 8.1     16   16.15 7.41   1  81    80 1.32      3.8 0.08
## ------------------------------------------------------------ 
## group: >30
##    vars     n  mean   sd median trimmed  mad min max range skew kurtosis   se
## X1    1 35545 16.28 7.62     15   15.63 7.41   1  70    69 1.16     2.92 0.04
## ------------------------------------------------------------ 
## group: NO
##    vars     n  mean   sd median trimmed  mad min max range skew kurtosis   se
## X1    1 54864 15.67 8.43     14   14.78 7.41   1  79    78 1.42     3.66 0.04
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = num$num_medications ~ ds$readmitted)
## 
## $`ds$readmitted`
##               diff        lwr        upr p adj
## >30-<30 -0.6203751 -0.8254246 -0.4153256     0
## NO-<30  -1.2327767 -1.4288897 -1.0366637     0
## NO->30  -0.6124016 -0.7419276 -0.4828756     0

Número de Tratamientos Ambulatorios

## 
##  Descriptive statistics by group 
## group: <30
##    vars     n mean  sd median trimmed mad min max range skew kurtosis   se
## X1    1 11357 0.44 1.3      0    0.13   0   0  40    40 7.51   118.93 0.01
## ------------------------------------------------------------ 
## group: >30
##    vars     n mean   sd median trimmed mad min max range skew kurtosis   se
## X1    1 35545  0.5 1.54      0    0.15   0   0  42    42 8.41   126.25 0.01
## ------------------------------------------------------------ 
## group: NO
##    vars     n mean   sd median trimmed mad min max range skew kurtosis se
## X1    1 54864 0.27 1.03      0    0.03   0   0  36    36 8.67   143.68  0
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = num$number_outpatient ~ ds$readmitted)
## 
## $`ds$readmitted`
##                diff         lwr        upr    p adj
## >30-<30  0.05941744  0.02751399  0.0913209 3.78e-05
## NO-<30  -0.16379946 -0.19431250 -0.1332864 0.00e+00
## NO->30  -0.22321690 -0.24336973 -0.2030641 0.00e+00

Número de Atenciones de Urgencia

## 
##  Descriptive statistics by group 
## group: <30
##    vars     n mean   sd median trimmed mad min max range  skew kurtosis   se
## X1    1 11357 0.36 1.37      0    0.08   0   0  64    64 14.69   475.65 0.01
## ------------------------------------------------------------ 
## group: >30
##    vars     n mean   sd median trimmed mad min max range  skew kurtosis   se
## X1    1 35545 0.28 1.19      0    0.06   0   0  76    76 21.23   937.14 0.01
## ------------------------------------------------------------ 
## group: NO
##    vars     n mean   sd median trimmed mad min max range  skew kurtosis se
## X1    1 54864 0.11 0.52      0       0   0   0  37    37 17.39   757.67  0
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = num$number_emergency ~ ds$readmitted)
## 
## $`ds$readmitted`
##                diff         lwr         upr p adj
## >30-<30 -0.07364408 -0.09701908 -0.05026908     0
## NO-<30  -0.24809716 -0.27045343 -0.22574089     0
## NO->30  -0.17445307 -0.18921863 -0.15968752     0

Número de Hospitalizaciones

## 
##  Descriptive statistics by group 
## group: <30
##    vars     n mean   sd median trimmed mad min max range skew kurtosis   se
## X1    1 11357 1.22 1.95      0    0.79   0   0  21    21 2.79    10.98 0.02
## ------------------------------------------------------------ 
## group: >30
##    vars     n mean   sd median trimmed mad min max range skew kurtosis   se
## X1    1 35545 0.84 1.39      0    0.53   0   0  19    19 2.92    13.58 0.01
## ------------------------------------------------------------ 
## group: NO
##    vars     n mean   sd median trimmed mad min max range skew kurtosis se
## X1    1 54864 0.38 0.86      0    0.18   0   0  16    16 3.78    23.99  0
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = num$number_inpatient ~ ds$readmitted)
## 
## $`ds$readmitted`
##               diff        lwr        upr p adj
## >30-<30 -0.3850100 -0.4160231 -0.3539969     0
## NO-<30  -0.8420401 -0.8717016 -0.8123787     0
## NO->30  -0.4570302 -0.4766206 -0.4374397     0

Número de Diagnósticos

## 
##  Descriptive statistics by group 
## group: <30
##    vars     n mean   sd median trimmed mad min max range  skew kurtosis   se
## X1    1 11357 7.69 1.77      9    7.98   0   1  16    15 -1.08     0.46 0.02
## ------------------------------------------------------------ 
## group: >30
##    vars     n mean   sd median trimmed mad min max range  skew kurtosis   se
## X1    1 35545 7.65 1.81      9    7.95   0   1  16    15 -1.08     0.44 0.01
## ------------------------------------------------------------ 
## group: NO
##    vars     n mean   sd median trimmed  mad min max range  skew kurtosis   se
## X1    1 54864 7.22 2.02      8    7.48 1.48   1  16    15 -0.71     -0.4 0.01
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = num$number_diagnoses ~ ds$readmitted)
## 
## $`ds$readmitted`
##                diff         lwr          upr     p adj
## >30-<30 -0.04589029 -0.09442676  0.002646182 0.0685035
## NO-<30  -0.47142303 -0.51784418 -0.425001877 0.0000000
## NO->30  -0.42553274 -0.45619234 -0.394873143 0.0000000

Se puede observar que en general todas las variables numéricas que describen el uso que el paciente le ha dado al sistema (costos variables) parecen ser buenos estimadores para determinar las readmisiones.

Asociaciones entre Campos Numéricos

No hay asociaciones muy fuertes entre las variables, con excepción del tiempo de hospitalización y el número de medicamentos, asociación fácilmente comprensible.

Previo al procesamiento de las variables categóricas, se muestra gráficamente el comportamiento de todos los campos numéricos respecto de los tipos de readmisión y se realiza una estandarización de todos ellos.

## [1] "<30" ">30" "NO"

##                    vars      n mean sd median trimmed  mad   min   max range
## time_in_hospital      1 101766    0  1  -0.13   -0.13 0.99 -1.14  3.22  4.35
## num_lab_procedures    2 101766    0  1   0.05    0.04 0.98 -2.14  4.52  6.66
## num_procedures        3 101766    0  1  -0.20   -0.19 0.87 -0.79  2.73  3.52
## num_medications       4 101766    0  1  -0.13   -0.10 0.91 -1.85  7.99  9.84
## number_outpatient     5 101766    0  1  -0.29   -0.23 0.00 -0.29 32.85 33.14
## number_emergency      6 101766    0  1  -0.21   -0.20 0.00 -0.21 81.47 81.68
## number_inpatient      7 101766    0  1  -0.50   -0.23 0.00 -0.50 16.13 16.63
## number_diagnoses      8 101766    0  1   0.30    0.15 0.77 -3.32  4.44  7.76
##                     skew kurtosis se
## time_in_hospital    1.13     0.85  0
## num_lab_procedures -0.24    -0.25  0
## num_procedures      1.32     0.86  0
## num_medications     1.33     3.47  0
## number_outpatient   8.83   147.90  0
## number_emergency   22.85  1191.60  0
## number_inpatient    3.61    20.72  0
## number_diagnoses   -0.88    -0.08  0

Variables Categóricas

Ahora, se contruyen las 36 tablas cruzadas correspondiantes a las asociaciones entre todas las variables categóricas y la variable respuesta(“readmittion”). También, se realizan pruebas chi-squared para estimar la significancia entre cada variable categórica y la variable respuesta(“readmitted”). Lo anterior nos ayuda a tener una idea de qué variables aportarían o no en el proceso de clasificación.

A continuación, se muestran las tablas sólo como ejemplo ilustrativo, pues algunos campos de estos tienen muchos niveles(36 tablas).

#Categóricos----
fact_cols <- unlist(lapply(ds, is.factor))         # Categoricos
fact<-ds[,fact_cols]
names(fact)
##  [1] "race"                     "gender"                  
##  [3] "age"                      "admission_type_id"       
##  [5] "discharge_disposition_id" "admission_source_id"     
##  [7] "diag_1"                   "diag_2"                  
##  [9] "diag_3"                   "max_glu_serum"           
## [11] "A1Cresult"                "metformin"               
## [13] "repaglinide"              "nateglinide"             
## [15] "chlorpropamide"           "glimepiride"             
## [17] "acetohexamide"            "glipizide"               
## [19] "glyburide"                "tolbutamide"             
## [21] "pioglitazone"             "rosiglitazone"           
## [23] "acarbose"                 "miglitol"                
## [25] "troglitazone"             "tolazamide"              
## [27] "examide"                  "citoglipton"             
## [29] "insulin"                  "glyburide.metformin"     
## [31] "glipizide.metformin"      "glimepiride.pioglitazone"
## [33] "metformin.rosiglitazone"  "metformin.pioglitazone"  
## [35] "change"                   "diabetesMed"             
## [37] "readmitted"
dim(fact)
## [1] 101766     37
prop.table(table(fact$readmitted))# Hay un pequeño desbalance para <30
## 
##       <30       >30        NO 
## 0.1115992 0.3492817 0.5391192
str(fact)
## 'data.frame':    101766 obs. of  37 variables:
##  $ race                    : Factor w/ 6 levels "?","AfricanAmerican",..: 4 4 2 4 4 4 4 4 4 4 ...
##  $ gender                  : Factor w/ 3 levels "Female","Male",..: 1 1 1 2 2 2 2 2 1 1 ...
##  $ age                     : Factor w/ 10 levels "[0-10)","[10-20)",..: 1 2 3 4 5 6 7 8 9 10 ...
##  $ admission_type_id       : Factor w/ 8 levels "1","2","3","4",..: 6 1 1 1 1 2 3 1 2 3 ...
##  $ discharge_disposition_id: Factor w/ 26 levels "1","2","3","4",..: 24 1 1 1 1 1 1 1 1 3 ...
##  $ admission_source_id     : Factor w/ 17 levels "1","2","3","4",..: 1 7 7 7 7 2 2 7 4 4 ...
##  $ diag_1                  : Factor w/ 717 levels "?","10","11",..: 126 145 456 556 56 265 265 278 254 284 ...
##  $ diag_2                  : Factor w/ 749 levels "?","11","110",..: 1 81 80 99 26 248 248 316 262 48 ...
##  $ diag_3                  : Factor w/ 790 levels "?","11","110",..: 1 123 768 250 88 88 772 88 231 319 ...
##  $ max_glu_serum           : Factor w/ 4 levels ">200",">300",..: 3 3 3 3 3 3 3 3 3 3 ...
##  $ A1Cresult               : Factor w/ 4 levels ">7",">8","None",..: 3 3 3 3 3 3 3 3 3 3 ...
##  $ metformin               : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 3 2 2 2 ...
##  $ repaglinide             : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ nateglinide             : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ chlorpropamide          : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ glimepiride             : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 3 2 2 2 ...
##  $ acetohexamide           : Factor w/ 2 levels "No","Steady": 1 1 1 1 1 1 1 1 1 1 ...
##  $ glipizide               : Factor w/ 4 levels "Down","No","Steady",..: 2 2 3 2 3 2 2 2 3 2 ...
##  $ glyburide               : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 3 2 2 ...
##  $ tolbutamide             : Factor w/ 2 levels "No","Steady": 1 1 1 1 1 1 1 1 1 1 ...
##  $ pioglitazone            : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ rosiglitazone           : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 3 ...
##  $ acarbose                : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ miglitol                : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ troglitazone            : Factor w/ 2 levels "No","Steady": 1 1 1 1 1 1 1 1 1 1 ...
##  $ tolazamide              : Factor w/ 3 levels "No","Steady",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ examide                 : Factor w/ 1 level "No": 1 1 1 1 1 1 1 1 1 1 ...
##  $ citoglipton             : Factor w/ 1 level "No": 1 1 1 1 1 1 1 1 1 1 ...
##  $ insulin                 : Factor w/ 4 levels "Down","No","Steady",..: 2 4 2 4 3 3 3 2 3 3 ...
##  $ glyburide.metformin     : Factor w/ 4 levels "Down","No","Steady",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ glipizide.metformin     : Factor w/ 2 levels "No","Steady": 1 1 1 1 1 1 1 1 1 1 ...
##  $ glimepiride.pioglitazone: Factor w/ 2 levels "No","Steady": 1 1 1 1 1 1 1 1 1 1 ...
##  $ metformin.rosiglitazone : Factor w/ 2 levels "No","Steady": 1 1 1 1 1 1 1 1 1 1 ...
##  $ metformin.pioglitazone  : Factor w/ 2 levels "No","Steady": 1 1 1 1 1 1 1 1 1 1 ...
##  $ change                  : Factor w/ 2 levels "Ch","No": 2 1 2 1 1 2 1 2 1 1 ...
##  $ diabetesMed             : Factor w/ 2 levels "No","Yes": 1 2 2 2 2 2 2 2 2 2 ...
##  $ readmitted              : Factor w/ 3 levels "<30",">30","NO": 3 2 3 3 3 2 3 2 3 3 ...
names(fact)
##  [1] "race"                     "gender"                  
##  [3] "age"                      "admission_type_id"       
##  [5] "discharge_disposition_id" "admission_source_id"     
##  [7] "diag_1"                   "diag_2"                  
##  [9] "diag_3"                   "max_glu_serum"           
## [11] "A1Cresult"                "metformin"               
## [13] "repaglinide"              "nateglinide"             
## [15] "chlorpropamide"           "glimepiride"             
## [17] "acetohexamide"            "glipizide"               
## [19] "glyburide"                "tolbutamide"             
## [21] "pioglitazone"             "rosiglitazone"           
## [23] "acarbose"                 "miglitol"                
## [25] "troglitazone"             "tolazamide"              
## [27] "examide"                  "citoglipton"             
## [29] "insulin"                  "glyburide.metformin"     
## [31] "glipizide.metformin"      "glimepiride.pioglitazone"
## [33] "metformin.rosiglitazone"  "metformin.pioglitazone"  
## [35] "change"                   "diabetesMed"             
## [37] "readmitted"
for (i in seq(1,26)){
print(i)
print((names(fact[i])))
print(round(prop.table(table(fact$readmitted,fact[,i]),1)*100,1))
print(chisq.test(fact$readmitted,fact[,i]))#Ho: Independence
  }
## [1] 1
## [1] "race"
##      
##          ? AfricanAmerican Asian Caucasian Hispanic Other
##   <30  1.7            19.0   0.6      75.7      1.9   1.3
##   >30  1.5            18.7   0.5      76.3      1.8   1.3
##   NO   2.8            19.0   0.8      73.6      2.2   1.7
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 282.59, df = 10, p-value < 2.2e-16
## 
## [1] 2
## [1] "gender"
##      
##       Female Male Unknown/Invalid
##   <30   54.2 45.8             0.0
##   >30   54.9 45.1             0.0
##   NO    52.9 47.1             0.0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 37.461, df = 4, p-value = 1.447e-07
## 
## [1] 3
## [1] "age"
##      
##       [0-10) [10-20) [20-30) [30-40) [40-50) [50-60) [60-70) [70-80) [80-90)
##   <30    0.0     0.4     2.1     3.7     9.0    14.7    22.0    27.0    18.3
##   >30    0.1     0.6     1.4     3.3     9.2    16.6    22.2    26.7    17.5
##   NO     0.2     0.8     1.7     3.9     9.8    17.6    22.0    24.7    16.2
##      
##       [90-100)
##   <30      2.7
##   >30      2.3
##   NO       3.1
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 313.17, df = 18, p-value < 2.2e-16
## 
## [1] 4
## [1] "admission_type_id"
##      
##          1    2    3    4    5    6    7    8
##   <30 54.8 18.2 17.3  0.0  4.4  5.2  0.0  0.2
##   >30 54.3 18.2 16.2  0.0  4.8  6.3  0.0  0.2
##   NO  51.9 18.2 20.3  0.0  4.7  4.5  0.0  0.4
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 415.76, df = 14, p-value < 2.2e-16
## 
## [1] 5
## [1] "discharge_disposition_id"
##      
##          1    2    3    4    5    6    7    8    9   10   11   12   13   14
##   <30 49.3  3.0 18.0  0.9  2.2 14.4  0.8  0.1  0.1  0.0  0.0  0.0  0.2  0.2
##   >30 60.5  1.9 13.8  0.8  1.0 15.1  0.6  0.1  0.0  0.0  0.0  0.0  0.1  0.0
##   NO  60.4  2.0 12.7  0.8  1.1 10.8  0.6  0.1  0.0  0.0  3.0  0.0  0.6  0.6
##      
##         15   16   17   18   19   20   22   23   24   25   27   28
##   <30  0.2  0.0  0.0  4.0  0.0  0.0  4.9  0.3  0.1  0.8  0.0  0.4
##   >30  0.1  0.0  0.0  2.9  0.0  0.0  1.5  0.4  0.0  1.1  0.0  0.1
##   NO   0.0  0.0  0.0  4.0  0.0  0.0  1.7  0.4  0.0  0.9  0.0  0.1
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 3587.3, df = 50, p-value < 2.2e-16
## 
## [1] 6
## [1] "admission_source_id"
##      
##          1    2    3    4    5    6    7    8    9   10   11   13   14   17
##   <30 27.6  1.0  0.3  2.7  0.9  1.9 59.2  0.0  0.1  0.0  0.0  0.0  0.0  6.2
##   >30 27.1  0.9  0.2  1.9  0.7  1.1 61.0  0.0  0.0  0.0  0.0  0.0  0.0  6.9
##   NO  30.6  1.2  0.2  4.0  0.9  3.0 53.1  0.0  0.2  0.0  0.0  0.0  0.0  6.6
##      
##         20   22   25
##   <30  0.2  0.0  0.0
##   >30  0.2  0.0  0.0
##   NO   0.1  0.0  0.0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 1151, df = 32, p-value < 2.2e-16
## 
## [1] 7
## [1] "diag_1"
##      
##         ?  10  11 110 112 114 115 117 131 133 135 136 141 142 143 145 146 147
##   <30 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       148 149 150 151 152 153 154 155 156 157 158 160 161 162 163 164 170 171
##   <30 0.0 0.0 0.0 0.0 0.0 0.3 0.1 0.0 0.0 0.1 0.0 0.0 0.0 0.4 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.3 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.3 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.1 0.0 0.3 0.1 0.1 0.0 0.2 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.0
##      
##       172 173 174 175 179 180 182 183 184 185 187 188 189 191 192 193 194 195
##   <30 0.0 0.0 0.1 0.0 0.0 0.0 0.1 0.0 0.0 0.1 0.0 0.1 0.1 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.1 0.1 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.2 0.0 0.0 0.0 0.2 0.0 0.0 0.2 0.0 0.1 0.1 0.1 0.0 0.0 0.0 0.0
##      
##       196 197 198 199 200 201 202 203 204 205 207 208 210 211 212 214 215 216
##   <30 0.0 0.4 0.3 0.0 0.0 0.0 0.2 0.0 0.1 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0
##   >30 0.0 0.2 0.1 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0
##   NO  0.0 0.4 0.3 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0
##      
##       217 218 219 220 223 225 226 227 228 229  23 230 233 235 236 237 238 239
##   <30 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.1
##   >30 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0
##   NO  0.0 0.2 0.0 0.1 0.0 0.1 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0
##      
##       240 241 242 244 245 246 250 250.01 250.02 250.03 250.1 250.11 250.12
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.1    0.0    0.5    0.1   0.3    0.8    0.3
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.1    0.0    0.6    0.1   0.3    0.7    0.4
##   NO  0.0 0.1 0.0 0.0 0.0 0.0 0.3    0.1    0.7    0.3   0.3    0.5    0.4
##      
##       250.13 250.2 250.21 250.22 250.23 250.3 250.31 250.32 250.33 250.4 250.41
##   <30    1.0   0.1    0.0    0.1    0.0   0.0    0.0    0.0    0.0   0.2    0.2
##   >30    0.8   0.1    0.0    0.1    0.0   0.0    0.0    0.0    0.0   0.4    0.1
##   NO     0.8   0.1    0.0    0.2    0.0   0.0    0.0    0.0    0.0   0.2    0.1
##      
##       250.42 250.43 250.5 250.51 250.52 250.53 250.6 250.7 250.8 250.81 250.82
##   <30    0.2    0.1   0.0    0.0    0.0    0.0   1.9   1.5   1.6    0.2    0.6
##   >30    0.1    0.0   0.0    0.0    0.0    0.0   1.5   0.9   2.0    0.2    0.5
##   NO     0.1    0.0   0.0    0.0    0.0    0.0   0.8   0.7   1.5    0.2    0.3
##      
##       250.83 250.9 250.91 250.92 250.93 251 252 253 255 261 262 263 266  27 271
##   <30    0.1   0.0    0.0    0.1    0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30    0.1   0.0    0.0    0.1    0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO     0.1   0.0    0.0    0.0    0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
##   <30 0.0 0.0 0.1 0.0 2.3 0.0 0.2 0.0 0.3 0.1 0.1 0.0 0.1 0.5 0.0 0.1 0.1 0.0
##   >30 0.0 0.0 0.1 0.0 2.0 0.1 0.1 0.0 0.4 0.0 0.1 0.0 0.1 0.4 0.0 0.1 0.1 0.0
##   NO  0.0 0.0 0.1 0.1 1.7 0.0 0.6 0.0 0.3 0.0 0.0 0.0 0.0 0.3 0.0 0.1 0.1 0.0
##      
##       290 291 292 293 294 295 296 297 298 299   3 300 301 303 304 305 306 307
##   <30 0.1 0.1 0.1 0.1 0.2 0.4 0.9 0.0 0.1 0.0 0.0 0.1 0.0 0.1 0.0 0.0 0.0 0.0
##   >30 0.0 0.1 0.1 0.1 0.1 0.5 0.9 0.0 0.0 0.0 0.0 0.1 0.0 0.1 0.0 0.0 0.0 0.0
##   NO  0.1 0.1 0.1 0.0 0.1 0.4 0.9 0.0 0.1 0.0 0.0 0.1 0.0 0.1 0.0 0.0 0.0 0.0
##      
##       308 309  31 310 311 312 314 318 320 322 323 324 325 327 331 332 333 334
##   <30 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.1 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.1 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.0 0.0 0.0
##      
##       335 336 337 338  34 340 341 342 344 345 346 347 348 349  35 350 351 352
##   <30 0.0 0.0 0.0 0.1 0.0 0.1 0.0 0.0 0.0 0.1 0.0 0.0 0.2 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.1 0.0 0.1 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.1 0.0 0.2 0.0 0.0 0.0 0.0 0.0
##      
##       353 354 355 356 357 358 359  36 360 361 362 363 365 366 368 369 370 372
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       373 374 375 376 377 378 379  38 380 381 382 383 384 385 386 388 389  39
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.6 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.6 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.7 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.0 0.0 0.0
##      
##       391 394 395 396 397 398 401 402 403 404 405  41 410 411 412 413 414 415
##   <30 0.0 0.0 0.0 0.0 0.0 0.1 0.3 0.4 0.7 0.3 0.0 0.0 3.3 0.2 0.0 0.1 5.2 0.4
##   >30 0.0 0.0 0.0 0.0 0.0 0.2 0.4 0.5 0.6 0.3 0.0 0.0 3.0 0.3 0.0 0.1 6.0 0.4
##   NO  0.0 0.0 0.0 0.0 0.0 0.1 0.3 0.4 0.4 0.2 0.0 0.0 4.0 0.3 0.0 0.1 7.0 0.5
##      
##       416 417  42 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
##   <30 0.0 0.0 0.0 0.1 0.1 0.0 0.1 0.2 0.1 0.2 2.2 8.5 0.1 0.0 0.1 0.1 0.7 2.9
##   >30 0.1 0.0 0.0 0.0 0.0 0.0 0.1 0.1 0.1 0.2 2.7 8.7 0.0 0.0 0.1 0.0 0.8 1.7
##   NO  0.1 0.0 0.0 0.1 0.0 0.0 0.1 0.2 0.1 0.3 2.8 5.1 0.0 0.0 0.2 0.1 0.8 2.0
##      
##       435 436 437 438 440 441 442 443 444 445 446 447 448 451 452 453 454 455
##   <30 0.7 0.2 0.1 0.1 1.2 0.1 0.0 0.2 0.2 0.0 0.0 0.1 0.0 0.0 0.0 0.5 0.0 0.1
##   >30 1.0 0.2 0.1 0.1 0.9 0.1 0.0 0.1 0.1 0.0 0.0 0.1 0.0 0.0 0.0 0.5 0.0 0.1
##   NO  1.0 0.2 0.1 0.1 0.7 0.1 0.0 0.1 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.6 0.0 0.1
##      
##       456 457 458 459 461 462 463 464 465 466  47 470 471 473 474 475 477 478
##   <30 0.0 0.0 0.4 0.1 0.0 0.0 0.0 0.0 0.0 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.5 0.1 0.0 0.0 0.0 0.0 0.0 0.3 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.4 0.1 0.0 0.0 0.0 0.0 0.1 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##        48 480 481 482 483 485 486 487  49 490 491 492 493 494 495 496   5 500
##   <30 0.0 0.0 0.0 0.4 0.0 0.0 2.8 0.1 0.0 0.1 2.5 0.0 0.9 0.0 0.0 0.1 0.0 0.0
##   >30 0.0 0.0 0.1 0.4 0.0 0.0 3.9 0.1 0.0 0.1 3.0 0.0 1.4 0.0 0.0 0.1 0.0 0.0
##   NO  0.0 0.0 0.1 0.3 0.0 0.0 3.3 0.1 0.0 0.1 1.7 0.0 0.8 0.0 0.0 0.1 0.0 0.0
##      
##       501 506 507 508 510 511 512 513 514 515 516 518 519  52 521 522 523 524
##   <30 0.0 0.0 0.8 0.0 0.0 0.4 0.1 0.0 0.1 0.1 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.4 0.0 0.0 0.2 0.0 0.0 0.0 0.1 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.7 0.0 0.0 0.3 0.0 0.0 0.0 0.1 0.0 1.2 0.1 0.0 0.0 0.0 0.0 0.0
##      
##       526 527 528 529  53 530 531 532 533 534 535 536 537  54 540 541 542 543
##   <30 0.0 0.0 0.0 0.0 0.1 0.4 0.2 0.1 0.0 0.0 0.3 0.2 0.2 0.0 0.1 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.1 0.5 0.3 0.2 0.0 0.0 0.5 0.2 0.1 0.0 0.1 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.1 0.6 0.3 0.2 0.0 0.0 0.4 0.1 0.1 0.0 0.3 0.0 0.0 0.0
##      
##       550 551 552 553 555 556 557 558 560 562 564 565 566 567 568 569  57 570
##   <30 0.1 0.0 0.2 0.1 0.0 0.0 0.2 0.4 0.8 0.8 0.1 0.0 0.0 0.1 0.0 0.2 0.0 0.0
##   >30 0.0 0.0 0.2 0.1 0.0 0.0 0.2 0.4 0.9 1.0 0.1 0.0 0.1 0.1 0.0 0.3 0.0 0.0
##   NO  0.1 0.0 0.3 0.2 0.1 0.1 0.2 0.3 0.8 1.0 0.1 0.0 0.1 0.0 0.0 0.3 0.0 0.0
##      
##       571 572 573 574 575 576 577 578 579  58 580 581 582 583 584 585 586 588
##   <30 0.4 0.4 0.0 0.7 0.2 0.1 1.3 0.6 0.0 0.0 0.0 0.0 0.0 0.0 1.8 0.1 0.0 0.0
##   >30 0.2 0.3 0.0 0.8 0.2 0.1 1.1 0.7 0.0 0.0 0.0 0.0 0.0 0.0 1.5 0.1 0.0 0.0
##   NO  0.3 0.2 0.0 1.1 0.2 0.1 0.9 0.6 0.0 0.0 0.0 0.0 0.0 0.0 1.4 0.1 0.0 0.0
##      
##       590 591 592 593 594 595 596 598 599 600 601 602 603 604 605 607 608  61
##   <30 0.2 0.0 0.3 0.2 0.0 0.1 0.0 0.0 1.5 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0
##   >30 0.3 0.0 0.3 0.1 0.0 0.1 0.1 0.0 1.7 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0
##   NO  0.4 0.0 0.4 0.1 0.0 0.1 0.0 0.0 1.5 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0
##      
##       610 611 614 615 616 617 618 619 620 621 622 623 625 626 627 632 633 634
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.0 0.1 0.0 0.0 0.0 0.1 0.1 0.0 0.0 0.0 0.0
##      
##       637 640 641 642 643 644 645 646 647 648 649 652 653 654 655 656 657 658
##   <30 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.4 0.0 0.0 0.0 0.2 0.0 0.0 0.0 0.0
##      
##       659  66 660 661 663 664 665 669 671 674 680 681 682 683 684 685 686 690
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 1.6 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 2.2 0.0 0.0 0.0 0.0 0.0
##   NO  0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 2.0 0.0 0.0 0.0 0.0 0.0
##      
##       691 692 693 694 695 696 698   7  70 700 703 704 705 706 707 708 709 710
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.4 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.3 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.0 0.0 0.0
##      
##       711 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730
##   <30 0.1 0.1 1.9 0.0 0.0 0.0 0.1 0.0 0.1 0.4 0.0 0.4 0.0 0.0 0.0 0.1 0.1 0.3
##   >30 0.1 0.0 1.6 0.0 0.0 0.0 0.1 0.0 0.1 0.5 0.1 0.4 0.0 0.1 0.0 0.1 0.1 0.3
##   NO  0.1 0.0 2.5 0.1 0.0 0.0 0.0 0.0 0.2 1.0 0.1 0.5 0.0 0.1 0.1 0.1 0.1 0.2
##      
##       731 732 733 734 735 736 737 738 745 746 747  75 751 753 756 759  78 780
##   <30 0.0 0.0 0.4 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.7
##   >30 0.0 0.0 0.4 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 2.1
##   NO  0.0 0.0 0.3 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 2.0
##      
##       781 782 783 784 785 786 787 788 789  79 790 791 792 793 794 795 796 797
##   <30 0.1 0.1 0.0 0.1 0.1 2.6 0.4 0.1 0.6 0.1 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.1 0.1 0.0 0.2 0.1 4.0 0.3 0.0 0.6 0.1 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.1 0.1 0.0 0.1 0.1 4.2 0.2 0.0 0.5 0.1 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       799   8 800 801 802 803 804 805 806 807 808 810 812 813 814 815 816 817
##   <30 0.1 0.6 0.0 0.0 0.0 0.0 0.0 0.2 0.0 0.1 0.2 0.0 0.2 0.1 0.0 0.0 0.0 0.0
##   >30 0.1 0.5 0.0 0.0 0.0 0.0 0.0 0.2 0.0 0.1 0.1 0.0 0.2 0.0 0.0 0.0 0.0 0.0
##   NO  0.1 0.5 0.0 0.0 0.0 0.0 0.0 0.2 0.0 0.1 0.1 0.0 0.3 0.1 0.0 0.0 0.0 0.0
##      
##        82 820 821 822 823 824 825 826 827 831 832 833 834 835 836 837 838 839
##   <30 0.0 1.5 0.1 0.0 0.1 0.4 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.8 0.1 0.0 0.1 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 1.1 0.2 0.1 0.1 0.4 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##        84 840 842 843 844 845 846 847 848 850 851 852 853 854 860 861 862 863
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.1 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       864 865 866 867 868 870 871 873 875 878 879  88 880 881 882 883 885 886
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       890 891 892 893 895 897   9 903 904 906 911 913 914 915 916 917 919 920
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       921 922 923 924 928 933 934 935 936 939  94 941 942 944 945 952 955 957
##   <30 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       958 959 962 963 964 965 966 967 968 969  97 970 971 972 973 974 975 976
##   <30 0.0 0.0 0.1 0.0 0.0 0.1 0.0 0.1 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.1 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       977  98 980 982 983 986 987 988 989 990 991 992 994 995 996 997 998 999
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 2.3 0.4 0.8 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 2.2 0.4 0.7 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 1.7 0.4 0.8 0.0
##      
##       E909 V07 V25 V26 V43 V45 V51 V53 V54 V55 V56 V57 V58 V60 V63 V66 V67 V70
##   <30  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.4 0.8 0.0 0.0 0.0 0.0 0.0
##   >30  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 1.2 0.2 0.0 0.0 0.0 0.0 0.0
##   NO   0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.1 0.1 0.0 1.1 0.1 0.0 0.0 0.0 0.0 0.0
##      
##       V71
##   <30 0.0
##   >30 0.0
##   NO  0.0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 4970.8, df = 1432, p-value < 2.2e-16
## 
## [1] 8
## [1] "diag_2"
##      
##         ?  11 110 111 112 114 115 117 123 130 131 135 136 137 138 140 141 145
##   <30 0.3 0.0 0.0 0.0 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.2 0.0 0.0 0.0 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.5 0.0 0.0 0.0 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       150 151 152 153 154 155 156 157 162 163 164 171 172 173 174 179 180 182
##   <30 0.1 0.0 0.1 0.2 0.1 0.0 0.0 0.1 0.5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.1 0.1 0.0 0.0 0.1 0.3 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.1 0.4 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       183 185 186 188 189 191 192 193 195 196 197 198 199 200 201 202 203 204
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.5 0.4 0.0 0.0 0.0 0.4 0.2 0.1
##   >30 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.2 0.3 0.2 0.0 0.0 0.0 0.2 0.1 0.1
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.5 0.3 0.0 0.0 0.0 0.1 0.1 0.1
##      
##       205 208 211 212 214 215 217 218 220 223 225 226 227 228 232 233 235 238
##   <30 0.1 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       239 240 241 242 244 245 246 250 250.01 250.02 250.03 250.1 250.11 250.12
##   <30 0.0 0.0 0.0 0.1 0.1 0.0 0.0 3.9    1.7    1.9    0.3   0.1    0.1    0.1
##   >30 0.0 0.0 0.0 0.1 0.1 0.0 0.0 4.7    1.5    2.1    0.3   0.0    0.1    0.1
##   NO  0.0 0.0 0.0 0.1 0.2 0.0 0.0 7.2    1.5    2.0    0.2   0.0    0.1    0.1
##      
##       250.13 250.2 250.21 250.22 250.23 250.3 250.31 250.32 250.33 250.4 250.41
##   <30    0.2   0.0    0.0    0.0    0.0   0.0    0.0    0.0    0.0   0.2    0.5
##   >30    0.1   0.0    0.0    0.1    0.0   0.0    0.0    0.0    0.0   0.2    0.3
##   NO     0.1   0.0    0.0    0.0    0.0   0.0    0.0    0.0    0.0   0.1    0.1
##      
##       250.42 250.43 250.5 250.51 250.52 250.53 250.6 250.7 250.8 250.81 250.82
##   <30    0.1    0.1   0.1    0.1    0.1    0.1   1.3   0.2   0.2    0.1    0.2
##   >30    0.1    0.0   0.1    0.1    0.1    0.0   1.0   0.1   0.2    0.1    0.2
##   NO     0.1    0.0   0.1    0.1    0.0    0.0   0.7   0.1   0.2    0.1    0.1
##      
##       250.83 250.9 250.91 250.92 250.93 251 252 253 255 256 258 259 260 261 262
##   <30    0.0   0.0    0.0    0.2    0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0
##   >30    0.1   0.0    0.0    0.2    0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0
##   NO     0.0   0.0    0.0    0.2    0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       263 266 268 269  27 270 271 272 273 274 275 276 277 278 279 280 281 282
##   <30 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.0 0.0 0.0 7.1 0.0 0.1 0.0 0.6 0.0 0.0
##   >30 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.3 0.0 0.0 0.0 6.7 0.1 0.2 0.0 0.6 0.0 0.1
##   NO  0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0 6.5 0.0 0.3 0.0 0.6 0.0 0.0
##      
##       283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
##   <30 0.0 0.1 1.2 0.1 0.3 0.1 0.0 0.1 0.0 0.1 0.1 0.1 0.3 0.2 0.0 0.0 0.0 0.1
##   >30 0.0 0.2 1.4 0.1 0.3 0.1 0.1 0.0 0.1 0.1 0.1 0.1 0.4 0.1 0.0 0.0 0.0 0.2
##   NO  0.0 0.2 1.6 0.1 0.3 0.1 0.0 0.1 0.1 0.1 0.1 0.2 0.4 0.2 0.0 0.0 0.0 0.1
##      
##       301 302 303 304 305 306 307 308 309  31 310 311 312 314 316 317 318 319
##   <30 0.0 0.0 0.3 0.2 0.6 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.1 0.0 0.3 0.2 0.6 0.0 0.0 0.0 0.1 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.1 0.0 0.3 0.1 0.8 0.0 0.0 0.0 0.1 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       320 322 323 324 325 327 331 332 333 335 336 337 338  34 340 341 342 343
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.1 0.0 0.0 0.0 0.1 0.0 0.0 0.1 0.0 0.4 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.1 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.1 0.0 0.2 0.0
##      
##       344 345 346 347 348 349  35 350 351 352 353 354 355 356 357 358 359 360
##   <30 0.0 0.1 0.0 0.0 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0
##   >30 0.1 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0
##   NO  0.1 0.0 0.0 0.0 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0
##      
##       362 364 365 366 368 369 372 373 374 376 377 378 379  38 380 381 382 383
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.0
##      
##       386 388 389 394 395 396 397 398  40 401 402 403 404 405  41 410 411 412
##   <30 0.0 0.0 0.0 0.0 0.0 0.2 0.1 0.0 0.0 2.4 0.3 3.8 0.2 0.0 0.3 0.6 2.2 0.1
##   >30 0.0 0.0 0.0 0.0 0.0 0.2 0.1 0.0 0.0 2.9 0.3 3.6 0.3 0.0 0.4 0.5 2.6 0.1
##   NO  0.0 0.0 0.0 0.0 0.0 0.1 0.1 0.0 0.0 4.4 0.3 2.0 0.2 0.0 0.4 0.6 2.5 0.1
##      
##       413 414 415 416  42 420 421 422 423 424 425 426 427 428 429 430 431 432
##   <30 0.8 1.9 0.1 0.1 0.1 0.0 0.0 0.0 0.0 1.0 1.5 0.2 5.0 7.4 0.0 0.0 0.0 0.0
##   >30 1.1 2.5 0.1 0.1 0.1 0.0 0.0 0.0 0.0 1.1 1.7 0.3 5.1 7.5 0.0 0.0 0.0 0.0
##   NO  1.1 2.8 0.1 0.1 0.1 0.0 0.0 0.0 0.0 1.0 1.2 0.3 4.8 5.7 0.0 0.0 0.0 0.0
##      
##       433 434 435 436 437 438 440 441 442 443 444 446 447 448 451 452 453 454
##   <30 0.2 0.2 0.1 0.0 0.1 0.3 0.7 0.0 0.0 0.1 0.1 0.0 0.0 0.0 0.0 0.0 0.4 0.0
##   >30 0.1 0.1 0.1 0.0 0.0 0.3 0.4 0.0 0.0 0.1 0.1 0.0 0.0 0.0 0.0 0.0 0.3 0.0
##   NO  0.1 0.2 0.1 0.0 0.1 0.2 0.3 0.0 0.0 0.1 0.1 0.0 0.0 0.0 0.0 0.0 0.4 0.0
##      
##       455 456 457 458 459  46 460 461 462 463 464 465 466 470 472 473 474 475
##   <30 0.0 0.1 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.1 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.1 0.0 0.1 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.1 0.0 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.1 0.0 0.0 0.0 0.0 0.0
##      
##       477 478 480 481 482 483 484 485 486 487 490 491 492 493 494 495 496   5
##   <30 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 1.3 0.0 0.0 1.8 0.2 0.6 0.0 0.0 3.2 0.0
##   >30 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 1.4 0.0 0.1 2.0 0.2 0.9 0.0 0.0 3.8 0.0
##   NO  0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 1.4 0.0 0.0 1.2 0.2 0.9 0.0 0.0 2.9 0.0
##      
##       500 501 506 507 508 510 511 512 513 514 515 516 517 518 519  52 520 521
##   <30 0.0 0.0 0.0 0.1 0.0 0.0 0.6 0.0 0.0 0.0 0.1 0.0 0.0 1.2 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.1 0.0 0.0 0.5 0.0 0.0 0.0 0.2 0.0 0.0 1.1 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.2 0.0 0.0 0.5 0.1 0.0 0.0 0.2 0.0 0.0 1.5 0.0 0.0 0.0 0.0
##      
##       522 523 524 527 528 529  53 530 531 532 533 534 535 536 537  54 540 542
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.3 0.1 0.0 0.0 0.0 0.2 0.3 0.1 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.0 0.0 0.0 0.0 0.2 0.3 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.3 0.1 0.0 0.0 0.0 0.2 0.1 0.0 0.0 0.0 0.0
##      
##       543 550 552 553 555 556 557 558 560 562 564 565 566 567 568 569 570 571
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.4 0.1 0.1 0.0 0.0 0.1 0.0 0.1 0.0 0.6
##   >30 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.1 0.3 0.1 0.1 0.0 0.0 0.1 0.1 0.2 0.0 0.5
##   NO  0.0 0.0 0.1 0.1 0.0 0.0 0.0 0.1 0.5 0.2 0.1 0.0 0.0 0.1 0.1 0.2 0.0 0.3
##      
##       572 573 574 575 576 577 578 579 580 581 583 584 585 586 588 590 591 592
##   <30 0.2 0.1 0.2 0.0 0.1 0.6 0.3 0.0 0.0 0.1 0.0 1.7 2.4 0.0 0.0 0.1 0.2 0.1
##   >30 0.1 0.0 0.3 0.1 0.1 0.4 0.3 0.0 0.0 0.1 0.0 1.6 2.3 0.0 0.0 0.1 0.2 0.1
##   NO  0.1 0.0 0.4 0.1 0.1 0.3 0.4 0.0 0.0 0.1 0.0 1.6 1.4 0.0 0.0 0.1 0.3 0.1
##      
##       593 594 595 596 598 599 600 601 602 603 604 605 607 608 610 611 614 615
##   <30 0.1 0.0 0.1 0.1 0.0 3.3 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.1 0.0 0.1 0.0 0.0 3.3 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.1 0.0 0.1 0.1 0.0 3.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       616 617 618 619 620 621 622 623 625 626 627 634 641 642 644 645 646 647
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       648 649 652 654 656 658 659  66 661 663 664 665 670 674 680 681 682 683
##   <30 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 1.7 0.0
##   >30 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.6 0.0
##   NO  0.5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.2 0.0
##      
##       684 685 686 691 692 693 694 695 696 698   7  70 701 702 703 704 705 706
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.3 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.3 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       707 709 710 711 712 713 714 715 716 717 718 719 721 722 723 724 725 726
##   <30 2.5 0.0 0.1 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.1 0.1 0.1 0.0 0.1 0.0 0.0
##   >30 2.3 0.0 0.2 0.1 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.1 0.1 0.1 0.0 0.1 0.0 0.0
##   NO  1.6 0.0 0.2 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.1 0.1 0.2 0.1 0.2 0.0 0.0
##      
##       727 728 729 730 731 733 734 736 737 738 741 742 745 746 747 748  75 750
##   <30 0.0 0.1 0.1 0.3 0.1 0.3 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.1 0.1 0.3 0.1 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.1 0.1 0.2 0.1 0.2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       751 752 753 754 755 756 758 759  78 780 781 782 783 784 785 786 787 788
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.3 0.1 0.0 0.0 0.2 0.7 0.4 0.2 0.3
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.5 0.1 0.1 0.0 0.2 0.4 0.6 0.2 0.3
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.5 0.1 0.1 0.0 0.2 0.5 0.7 0.2 0.4
##      
##       789  79 790 791 792 793 794 795 796 797 799   8 800 801 802 805 806 807
##   <30 0.4 0.0 0.3 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.3 0.2 0.0 0.0 0.0 0.1 0.0 0.0
##   >30 0.3 0.0 0.3 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.3 0.2 0.0 0.0 0.0 0.1 0.0 0.0
##   NO  0.3 0.0 0.2 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.3 0.2 0.0 0.0 0.0 0.1 0.0 0.1
##      
##       808 810 811 812 813 814 815 816 820 821 822 823 824 825 826 831 832 833
##   <30 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       836 837 840 842 843 844 845 846 847 850 851 852 853 860 861 862 863 864
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       865 866 867 868 869 870 871 872 873 879  88 880 881 882 883 884 891 892
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       893 894   9 905 906 907 908 909 910 911 912 913 915 916 917 918 919 920
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       921 922 923 924 927 933 934  94 942 944 945 947 948 952 953 955 958 959
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##        96 962 963 965 967 968 969 972 974 975 977 980 987 989  99 990 991 992
##   <30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##   NO  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
##      
##       994 995 996 997 998 999 E812 E813 E814 E816 E817 E818 E819 E821 E826 E829
##   <30 0.0 0.2 0.6 0.4 0.6 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30 0.0 0.1 0.5 0.3 0.4 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO  0.0 0.1 0.4 0.4 0.6 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##       E849 E850 E853 E854 E858 E868 E870 E878 E879 E880 E881 E882 E883 E884
##   <30  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0
##      
##       E885 E887 E888 E890 E900 E905 E906 E915 E916 E917 E918 E919 E924 E927
##   <30  0.1  0.0  0.2  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.1  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.1  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##       E928 E929 E930 E931 E932 E933 E934 E935 E936 E937 E938 E939 E941 E942
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##       E944 E945 E947 E950 E965 E968 E980 V02 V03 V08 V09 V10 V11 V12 V13 V14
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.1 0.0 0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0 0.0 0.0 0.0 0.0 0.1 0.0 0.1 0.0 0.0
##      
##       V15 V16 V17 V18 V23 V25 V42 V43 V44 V45 V46 V49 V50 V53 V54 V55 V57 V58
##   <30 0.1 0.0 0.0 0.0 0.0 0.0 0.3 0.1 0.0 0.4 0.0 0.1 0.0 0.0 0.1 0.0 0.0 0.2
##   >30 0.1 0.0 0.0 0.0 0.0 0.0 0.3 0.1 0.0 0.4 0.0 0.1 0.0 0.0 0.1 0.0 0.0 0.2
##   NO  0.1 0.0 0.0 0.0 0.0 0.0 0.3 0.1 0.0 0.4 0.0 0.0 0.0 0.0 0.1 0.0 0.0 0.1
##      
##       V60 V61 V62 V63 V64 V65 V66 V69 V70 V72 V85 V86
##   <30 0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.0
##   >30 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.1 0.0
##   NO  0.0 0.0 0.1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.2 0.0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 4014.6, df = 1496, p-value < 2.2e-16
## 
## [1] 9
## [1] "diag_3"
##      
##          ?   11  110  111  112  115  117  122  123  131  132  135  136  138
##   <30  0.8  0.0  0.0  0.0  0.2  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1
##   >30  1.0  0.0  0.0  0.0  0.2  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0
##   NO   1.8  0.0  0.0  0.0  0.2  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0
##      
##        139   14  141  146  148  150  151  152  153  154  155  156  157  158
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.1  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0
##      
##        161  162  163  164   17  170  171  172  173  174  175  179  180  182
##   <30  0.0  0.3  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0
##   >30  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.2  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        183  185  186  188  189  191  192  193  195  196  197  198  199  200
##   <30  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.6  0.2  0.1  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.3  0.1  0.0  0.0
##   NO   0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.4  0.3  0.0  0.0
##      
##        201  202  203  204  205  208  211  214  215  216  217  218  220  223
##   <30  0.0  0.1  0.0  0.1  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.1  0.1  0.1  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.1  0.1  0.1  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.1  0.0  0.0
##      
##        225  226  227  228  230  233  235  236  238  239  240  241  242  243
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.1  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0
##      
##        244  245  246  250 250.01 250.02 250.03 250.1 250.11 250.12 250.13 250.2
##   <30  0.4  0.0  0.0  8.7    1.0    1.6    0.1   0.0    0.0    0.1    0.0   0.0
##   >30  0.5  0.0  0.0 10.0    1.0    1.5    0.2   0.0    0.0    0.0    0.0   0.0
##   NO   0.6  0.0  0.0 12.8    0.8    1.2    0.1   0.0    0.0    0.0    0.0   0.0
##      
##       250.21 250.22 250.23 250.3 250.31 250.4 250.41 250.42 250.43 250.5 250.51
##   <30    0.0    0.0    0.0   0.0    0.0   0.6    0.3    0.3    0.1   0.1    0.2
##   >30    0.0    0.0    0.0   0.0    0.0   0.5    0.3    0.1    0.1   0.1    0.1
##   NO     0.0    0.0    0.0   0.0    0.0   0.3    0.1    0.1    0.1   0.1    0.1
##      
##       250.52 250.53 250.6 250.7 250.8 250.81 250.82 250.83 250.9 250.91 250.92
##   <30    0.1    0.1   1.7   0.2   0.4    0.1    0.1    0.0   0.0    0.0    0.2
##   >30    0.0    0.0   1.3   0.2   0.4    0.1    0.1    0.0   0.0    0.0    0.2
##   NO     0.1    0.0   0.8   0.1   0.3    0.0    0.1    0.0   0.0    0.0    0.1
##      
##       250.93  251  252  253  255  256  258  259  260  261  262  263  265  266
##   <30    0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.3  0.0  0.0
##   >30    0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.2  0.0  0.0
##   NO     0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.2  0.0  0.0
##      
##        268   27  270  271  272  273  274  275  276  277  278  279  280  281
##   <30  0.0  0.0  0.0  0.0  1.2  0.0  0.0  0.1  5.3  0.0  0.4  0.0  0.4  0.0
##   >30  0.0  0.0  0.0  0.0  1.6  0.0  0.0  0.1  5.0  0.0  0.6  0.0  0.5  0.0
##   NO   0.0  0.0  0.0  0.0  2.3  0.0  0.1  0.1  5.1  0.0  0.8  0.0  0.3  0.0
##      
##        282  283  284  285  286  287  288  289  290  291  292  293  294  295
##   <30  0.0  0.0  0.2  1.1  0.2  0.3  0.1  0.0  0.0  0.0  0.1  0.1  0.4  0.3
##   >30  0.0  0.0  0.2  1.2  0.1  0.4  0.1  0.0  0.1  0.0  0.1  0.1  0.3  0.3
##   NO   0.0  0.0  0.1  1.2  0.1  0.4  0.1  0.0  0.1  0.0  0.1  0.1  0.3  0.3
##      
##        296  297  298  299    3  300  301  303  304  305  306  307  308  309
##   <30  0.2  0.0  0.1  0.0  0.0  0.3  0.1  0.2  0.3  0.7  0.0  0.0  0.0  0.1
##   >30  0.2  0.0  0.0  0.0  0.0  0.3  0.1  0.2  0.2  0.8  0.0  0.0  0.0  0.0
##   NO   0.2  0.0  0.0  0.0  0.0  0.2  0.1  0.2  0.1  1.0  0.0  0.0  0.0  0.1
##      
##        310  311  312  313  314  315  317  318  319  323  327  331  332  333
##   <30  0.0  0.2  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.2  0.1  0.0
##   >30  0.0  0.2  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.1  0.1  0.0
##   NO   0.0  0.2  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.2  0.1  0.0
##      
##        334  335  336  337  338   34  340  341  342  343  344  345  346  347
##   <30  0.0  0.0  0.0  0.1  0.0  0.0  0.1  0.0  0.3  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.1  0.0  0.0  0.1  0.0  0.1  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.1  0.0  0.0  0.1  0.0  0.2  0.0  0.1  0.0  0.0  0.0
##      
##        348  349   35  350  351  353  354  355  356  357  358  359  360  361
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.5  0.0  0.0  0.0  0.0
##   >30  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.4  0.0  0.0  0.0  0.0
##   NO   0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.4  0.0  0.0  0.0  0.0
##      
##        362  365 365.44  366  368  369  370  372  373  374  376  377  378  379
##   <30  0.1  0.0    0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.1  0.0    0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.1  0.0    0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##         38  380  381  382  383  384  385  386  387  388  389  391  394  395
##   <30  0.2  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.2  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.2  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        396  397  398  401  402  403  404  405   41  410  411  412  413  414
##   <30  0.3  0.1  0.0  6.1  0.2  3.4  0.2  0.0  0.5  0.2  0.3  0.3  0.2  3.0
##   >30  0.3  0.2  0.0  7.0  0.4  2.8  0.1  0.0  0.7  0.2  0.4  0.3  0.4  3.8
##   NO   0.2  0.1  0.0  9.3  0.4  1.8  0.1  0.0  0.8  0.2  0.4  0.4  0.3  3.6
##      
##        415  416  417   42  420  421  423  424  425  426  427  428  429  430
##   <30  0.0  0.2  0.0  0.1  0.0  0.0  0.0  1.0  1.2  0.2  4.0  4.9  0.1  0.0
##   >30  0.0  0.2  0.0  0.0  0.0  0.0  0.0  1.2  1.3  0.3  4.2  5.3  0.1  0.0
##   NO   0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.9  1.0  0.3  3.6  3.9  0.1  0.0
##      
##        431  432  433  434  435  436  437  438  440  441  442  443  444  445
##   <30  0.0  0.0  0.1  0.1  0.1  0.0  0.1  0.4  0.3  0.1  0.0  0.2  0.1  0.0
##   >30  0.0  0.0  0.2  0.0  0.1  0.0  0.1  0.3  0.2  0.0  0.0  0.3  0.1  0.0
##   NO   0.0  0.0  0.1  0.1  0.1  0.0  0.1  0.3  0.2  0.1  0.0  0.2  0.0  0.0
##      
##        446  447  448  451  452  453  454  455  456  457  458  459  460  461
##   <30  0.0  0.1  0.0  0.0  0.0  0.3  0.0  0.1  0.0  0.0  0.2  0.1  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.2  0.0  0.1  0.1  0.0  0.3  0.1  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.2  0.0  0.1  0.0  0.0  0.3  0.1  0.0  0.0
##      
##        462  463  464  465  466   47  470  472  473  475  477  478  480  481
##   <30  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.1  0.2  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.1  0.1  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0
##      
##        482  483  484  485  486  487   49  490  491  492  493  494  495  496
##   <30  0.1  0.0  0.0  0.0  0.7  0.0  0.0  0.0  0.6  0.1  0.7  0.0  0.0  3.1
##   >30  0.1  0.0  0.0  0.0  0.6  0.0  0.0  0.1  0.7  0.1  0.8  0.0  0.0  2.8
##   NO   0.0  0.0  0.0  0.0  0.5  0.0  0.0  0.1  0.5  0.2  0.6  0.0  0.0  2.3
##      
##          5  500  501  506  507  508  510  511  512  514  515  516  517  518
##   <30  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.6  0.0  0.0  0.1  0.0  0.0  0.9
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.3  0.0  0.0  0.2  0.0  0.1  0.8
##   NO   0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.4  0.0  0.0  0.1  0.0  0.0  0.9
##      
##        519  521  522  523  524  525  527  528  529   53  530  531  532  533
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.5  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.6  0.1  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.6  0.0  0.0  0.0
##      
##        534  535  536  537  538   54  540  542  543  550  552  553  555  556
##   <30  0.0  0.3  0.6  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0
##   >30  0.0  0.3  0.4  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0
##   NO   0.0  0.2  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.2  0.0  0.0
##      
##        557  558  560  562  564  565  566  567  568  569   57  570  571  572
##   <30  0.0  0.1  0.3  0.2  0.1  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.4  0.1
##   >30  0.0  0.1  0.2  0.2  0.1  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.3  0.0
##   NO   0.0  0.1  0.3  0.2  0.1  0.0  0.0  0.0  0.1  0.1  0.0  0.0  0.3  0.1
##      
##        573  574  575  576  577  578  579  580  581  582  583  584  585  586
##   <30  0.1  0.1  0.0  0.1  0.2  0.3  0.0  0.0  0.3  0.0  0.1  1.1  3.0  0.0
##   >30  0.0  0.1  0.0  0.0  0.1  0.3  0.0  0.0  0.1  0.0  0.1  1.0  2.4  0.0
##   NO   0.0  0.1  0.0  0.0  0.1  0.2  0.0  0.0  0.1  0.0  0.1  0.9  1.5  0.0
##      
##        588  590  591  592  593  594  595  596  597  598  599  600  601  602
##   <30  0.0  0.0  0.1  0.1  0.3  0.0  0.1  0.1  0.0  0.0  2.1  0.0  0.0  0.0
##   >30  0.0  0.1  0.1  0.1  0.3  0.0  0.1  0.1  0.0  0.0  2.0  0.1  0.0  0.0
##   NO   0.0  0.0  0.1  0.1  0.3  0.0  0.0  0.1  0.0  0.0  1.8  0.1  0.0  0.0
##      
##        603  604  605  607  608  610  611  614  616  617  618  619  620  621
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        622  623  624  625  626  627  641  642  643  644  646  647  648  649
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0
##   NO   0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0
##      
##        652  653  654  655  656  657  658  659   66  660  661  663  664  665
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        669  670  671  674  680  681  682  684  685  686  690  692  693  694
##   <30  0.0  0.0  0.0  0.0  0.0  0.1  1.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.1  1.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.1  0.7  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        695  696  697  698    7   70  701  702  703  704  705  706  707  708
##   <30  0.0  0.0  0.0  0.0  0.0  0.4  0.0  0.0  0.0  0.0  0.0  0.0  1.8  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.3  0.0  0.0  0.0  0.0  0.0  0.0  1.5  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.2  0.0  0.0  0.0  0.0  0.0  0.0  1.1  0.0
##      
##        709  710  711  712  713  714  715  716  717  718  719  720  721  722
##   <30  0.0  0.1  0.0  0.0  0.0  0.1  0.2  0.1  0.0  0.0  0.1  0.0  0.0  0.1
##   >30  0.0  0.1  0.0  0.0  0.0  0.1  0.2  0.0  0.0  0.0  0.1  0.0  0.1  0.1
##   NO   0.0  0.1  0.0  0.0  0.0  0.1  0.2  0.1  0.0  0.0  0.1  0.0  0.1  0.1
##      
##        723  724  725  726  727  728  729  730  731  732  733  734  735  736
##   <30  0.1  0.1  0.0  0.0  0.0  0.1  0.2  0.2  0.1  0.0  0.3  0.0  0.0  0.0
##   >30  0.0  0.1  0.0  0.0  0.0  0.1  0.2  0.2  0.2  0.0  0.2  0.0  0.0  0.0
##   NO   0.0  0.2  0.0  0.0  0.0  0.1  0.1  0.2  0.1  0.0  0.2  0.0  0.0  0.0
##      
##        737  738  741  742  744  745  746  747   75  750  751  752  753  754
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        755  756  757  758  759   78  780  781  782  783  784  785  786  787
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  1.3  0.2  0.1  0.1  0.3  0.6  0.5  0.3
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  1.3  0.1  0.1  0.0  0.2  0.3  0.6  0.4
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  1.3  0.1  0.1  0.1  0.2  0.4  0.6  0.3
##      
##        788  789   79  790  791  792  793  794  795  796  797  799    8  800
##   <30  0.3  0.4  0.0  0.2  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.3  0.3  0.0
##   >30  0.4  0.3  0.0  0.2  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.3  0.2  0.0
##   NO   0.3  0.3  0.0  0.2  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.3  0.2  0.0
##      
##        801  802  805  807  808  810  811  812  813  814  815  816  820  821
##   <30  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        822  823  824  825  826  831  834  836  837  838  840  841  842  844
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        845  847  848  850  851  852  853  854  860  861  862  863  864  865
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        866  867  868  870  871  872  873  875  876  877  879   88  880  881
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        882  883  884  890  891  892  893    9  905  906  907  908  909  910
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        911  912  913  915  916  917  918  919  920  921  922  923  924  928
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        930  933  934  935   94  942  943  944  945  948  951  952  953  955
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        956  958  959  962  965  966  967  969  970  971  972  980  987  989
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        991  992  995  996  997  998  999 E812 E813 E815 E816 E817 E818 E819
##   <30  0.0  0.0  0.3  0.4  0.3  0.3  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.3  0.3  0.2  0.3  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.3  0.2  0.3  0.3  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##       E822 E825 E826 E828 E849 E850 E852 E853 E854 E855 E858 E861 E864 E865
##   <30  0.0  0.0  0.0  0.0  0.2  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.2  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.3  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##       E870 E876 E878 E879 E880 E881 E882 E883 E884 E885 E886 E887 E888 E892
##   <30  0.0  0.0  0.1  0.1  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.1  0.0
##   >30  0.0  0.0  0.2  0.1  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.1  0.0
##   NO   0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.1  0.0
##      
##       E894 E900 E901 E904 E905 E906 E912 E915 E916 E917 E919 E920 E922 E924
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##       E927 E928 E929 E930 E931 E932 E933 E934 E935 E936 E937 E938 E939 E941
##   <30  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##       E942 E943 E944 E945 E946 E947 E949 E950 E955 E956 E965 E966 E980 E987
##   <30  0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##   NO   0.1  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
##      
##        V01  V02  V03  V06  V07  V08  V09  V10  V11  V12  V13  V14  V15  V16
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.1  0.0  0.3  0.0  0.0  0.3  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.2  0.0  0.2  0.0  0.0  0.3  0.0
##   NO   0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.3  0.0  0.2  0.0  0.0  0.4  0.0
##      
##        V17  V18  V22  V23  V25  V27  V42  V43  V44  V45  V46  V49  V53  V54
##   <30  0.0  0.0  0.0  0.0  0.0  0.0  0.3  0.2  0.0  1.2  0.1  0.1  0.0  0.0
##   >30  0.0  0.0  0.0  0.0  0.0  0.0  0.3  0.2  0.0  1.6  0.1  0.1  0.0  0.1
##   NO   0.0  0.0  0.0  0.0  0.0  0.1  0.2  0.2  0.0  1.3  0.0  0.0  0.0  0.1
##      
##        V55  V57  V58  V60  V61  V62  V63  V64  V65  V66  V70  V72  V85  V86
##   <30  0.0  0.0  0.4  0.0  0.0  0.0  0.0  0.1  0.0  0.0  0.0  0.0  0.1  0.0
##   >30  0.0  0.0  0.5  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0
##   NO   0.0  0.0  0.5  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.1  0.0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 3938.8, df = 1578, p-value < 2.2e-16
## 
## [1] 10
## [1] "max_glu_serum"
##      
##       >200 >300 None Norm
##   <30  1.6  1.6 94.2  2.6
##   >30  1.5  1.5 94.6  2.5
##   NO   1.4  1.0 95.0  2.6
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 51.922, df = 6, p-value = 1.933e-09
## 
## [1] 11
## [1] "A1Cresult"
##      
##         >7   >8 None Norm
##   <30  3.4  7.1 85.2  4.2
##   >30  3.7  8.2 83.7  4.5
##   NO   3.9  8.2 82.6  5.3
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 70.124, df = 6, p-value = 3.856e-13
## 
## [1] 12
## [1] "metformin"
##      
##       Down   No Steady   Up
##   <30  0.6 82.9   15.7  0.8
##   >30  0.5 81.1   17.4  1.0
##   NO   0.6 79.3   18.9  1.2
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 104.84, df = 6, p-value < 2.2e-16
## 
## [1] 13
## [1] "repaglinide"
##      
##       Down   No Steady   Up
##   <30  0.0 98.2    1.6  0.2
##   >30  0.1 98.2    1.7  0.1
##   NO   0.0 98.7    1.1  0.1
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 58.965, df = 6, p-value = 7.303e-11
## 
## [1] 14
## [1] "nateglinide"
##      
##       Down   No Steady   Up
##   <30  0.0 99.3    0.7  0.0
##   >30  0.0 99.3    0.7  0.0
##   NO   0.0 99.3    0.6  0.0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 3.4237, df = 6, p-value = 0.7541
## 
## [1] 15
## [1] "chlorpropamide"
##      
##        Down    No Steady    Up
##   <30   0.0 100.0    0.0   0.0
##   >30   0.0  99.9    0.1   0.0
##   NO    0.0  99.9    0.1   0.0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 8.9556, df = 6, p-value = 0.1761
## 
## [1] 16
## [1] "glimepiride"
##      
##       Down   No Steady   Up
##   <30  0.2 95.3    4.1  0.3
##   >30  0.2 94.6    4.9  0.3
##   NO   0.2 95.0    4.5  0.3
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 16.654, df = 6, p-value = 0.01064
## 
## [1] 17
## [1] "acetohexamide"
##      
##        No Steady
##   <30 100      0
##   >30 100      0
##   NO  100      0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 1.863, df = 2, p-value = 0.394
## 
## [1] 18
## [1] "glipizide"
##      
##       Down   No Steady   Up
##   <30  0.7 87.2   11.2  0.9
##   >30  0.6 86.7   11.9  0.8
##   NO   0.5 88.1   10.7  0.7
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 54.256, df = 6, p-value = 6.551e-10
## 
## [1] 19
## [1] "glyburide"
##      
##       Down   No Steady   Up
##   <30  0.5 90.0    8.8  0.7
##   >30  0.6 89.5    9.1  0.8
##   NO   0.5 89.4    9.2  0.8
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 9.9938, df = 6, p-value = 0.1249
## 
## [1] 20
## [1] "tolbutamide"
##      
##        No Steady
##   <30 100      0
##   >30 100      0
##   NO  100      0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 1.635, df = 2, p-value = 0.4415
## 
## [1] 21
## [1] "pioglitazone"
##      
##       Down   No Steady   Up
##   <30  0.2 93.2    6.4  0.3
##   >30  0.1 92.2    7.4  0.3
##   NO   0.1 93.1    6.6  0.2
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 29.936, df = 6, p-value = 4.043e-05
## 
## [1] 22
## [1] "rosiglitazone"
##      
##       Down   No Steady   Up
##   <30  0.0 94.1    5.6  0.2
##   >30  0.1 93.2    6.6  0.1
##   NO   0.1 94.0    5.7  0.2
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 43.009, df = 6, p-value = 1.162e-07
## 
## [1] 23
## [1] "acarbose"
##      
##       Down   No Steady   Up
##   <30  0.0 99.8    0.2  0.0
##   >30  0.0 99.6    0.4  0.0
##   NO   0.0 99.8    0.2  0.0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 35.684, df = 6, p-value = 3.176e-06
## 
## [1] 24
## [1] "miglitol"
##      
##        Down    No Steady    Up
##   <30   0.0 100.0    0.0   0.0
##   >30   0.0  99.9    0.0   0.0
##   NO    0.0 100.0    0.0   0.0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 11.594, df = 6, p-value = 0.07166
## 
## [1] 25
## [1] "troglitazone"
##      
##        No Steady
##   <30 100      0
##   >30 100      0
##   NO  100      0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 1.4357, df = 2, p-value = 0.4878
## 
## [1] 26
## [1] "tolazamide"
##      
##        No Steady  Up
##   <30 100      0   0
##   >30 100      0   0
##   NO  100      0   0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 5.0863, df = 4, p-value = 0.2786
for (i in seq(29,36)){
  print(i)
  print((names(fact[i])))
  print(round(prop.table(table(fact$readmitted,fact[,i]),1)*100,1))
  print(chisq.test(fact$readmitted,fact[,i]))#Ho: Independence
}
## [1] 29
## [1] "insulin"
##      
##       Down   No Steady   Up
##   <30 15.0 41.9   30.2 12.9
##   >30 13.4 44.9   29.5 12.3
##   NO  10.5 48.6   30.9 10.0
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 516.7, df = 6, p-value < 2.2e-16
## 
## [1] 30
## [1] "glyburide.metformin"
##      
##       Down   No Steady   Up
##   <30  0.0 99.3    0.7  0.0
##   >30  0.0 99.3    0.7  0.0
##   NO   0.0 99.3    0.7  0.0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 8.5245, df = 6, p-value = 0.2021
## 
## [1] 31
## [1] "glipizide.metformin"
##      
##        No Steady
##   <30 100      0
##   >30 100      0
##   NO  100      0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 2.048, df = 2, p-value = 0.3592
## 
## [1] 32
## [1] "glimepiride.pioglitazone"
##      
##        No Steady
##   <30 100      0
##   >30 100      0
##   NO  100      0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 1.863, df = 2, p-value = 0.394
## 
## [1] 33
## [1] "metformin.rosiglitazone"
##      
##        No Steady
##   <30 100      0
##   >30 100      0
##   NO  100      0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 1.7098, df = 2, p-value = 0.4253
## 
## [1] 34
## [1] "metformin.pioglitazone"
##      
##        No Steady
##   <30 100      0
##   >30 100      0
##   NO  100      0
## Warning in chisq.test(fact$readmitted, fact[, i]): Chi-squared approximation may
## be incorrect
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 0.85489, df = 2, p-value = 0.6522
## 
## [1] 35
## [1] "change"
##      
##         Ch   No
##   <30 48.9 51.1
##   >30 48.6 51.4
##   NO  44.1 55.9
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 215.83, df = 2, p-value < 2.2e-16
## 
## [1] 36
## [1] "diabetesMed"
##      
##         No  Yes
##   <30 19.8 80.2
##   >30 20.3 79.7
##   NO  25.4 74.6
## 
##  Pearson's Chi-squared test
## 
## data:  fact$readmitted and fact[, i]
## X-squared = 386.51, df = 2, p-value < 2.2e-16

Del análisis anterior se logran identificar los índices de los factores que parecen no brindar información significatuva para estimar el típo de readmisión (14,15,17,19,20,24,25,26,27,28,30,31,32,33,34).

Variables Categóricas a Utilizar

A continuación, se listan las 22 variables categóricas a utilizar. Por otro lado,teniendo en cuenta que el tipo de readmisión principal a estimar es el de readmisión en menos de 30 días desde la fecha de referencia, pues es el más grave, se decide reducir el número de niveles del campo readmisión de 3 a 2, unificando el tipo de admisión “mayor a 30 días” y “Sin readmisión”

Se define 0 para la caracteristicas de interés “menor a 30 días” Se define 1 para el complemento.(“mayor a 30 días”)

fact$readmitted<-ifelse(fact$readmitted=="<30",0,1)
fact$readmitted<-as.factor(fact$readmitted)
fact_r<-fact[,c(1:13,16,18,21,22,23,29,35,36,37)]
#head(fact_r)
names(fact_r)
##  [1] "race"                     "gender"                  
##  [3] "age"                      "admission_type_id"       
##  [5] "discharge_disposition_id" "admission_source_id"     
##  [7] "diag_1"                   "diag_2"                  
##  [9] "diag_3"                   "max_glu_serum"           
## [11] "A1Cresult"                "metformin"               
## [13] "repaglinide"              "glimepiride"             
## [15] "glipizide"                "pioglitazone"            
## [17] "rosiglitazone"            "acarbose"                
## [19] "insulin"                  "change"                  
## [21] "diabetesMed"              "readmitted"
fact_r$readmitted<-as.factor(fact_r$readmitted)

Posteriormente se procede a ampliar el límite de memoria y la numerización n a n(Construcción de Dummies) de las variables categóricas.

#One hot Encoding

memory.limit(size = 19000)
## [1] 19000
dmy <- dummyVars(" ~ .", data = fact_r[,-22])
fact_d <- data.frame(predict(dmy, newdata = fact_r[,-22]))#Factores numerización n:n
fact_d<-fact_d[,-fact_d$discharge_disposition_id.11] 
readmitted<-fact_r$readmitted
fact_dr<-cbind(fact_d,readmitted)
#dim(fact_d)
#dim(fact_dr)
#Vista minable----
vm<-cbind(num_s,fact_dr)# Vista Mináble con Factores con numericos standarizados
#dim(vm)
prop.table(table(fact$readmitted))# Hay un pequeño desbalance para <30
## 
##         0         1 
## 0.1115992 0.8884008

Entrenamiento y Validación

Se procede a construir los conjuntos de entrenamiento y validación. Teniendo en cuenta que existe un ligero desbalance entre los niveles de la variable objetivo, también se realiza undersampling.

#creo entrenamiento y validacion
unos<-subset(vm,vm$readmitted==1)#white
cero<-subset(vm,vm$readmitted==0)#red
sample <- sample.int(nrow(unos), round(.5*nrow(unos)))
unos.train <- unos[sample, ]
unos.test <- unos[-sample, ]
#porcentaje que debo obtener para balancear entrenamiento
value=nrow(unos.train)/nrow(unos)
#value
#sacar ese numero en entrenamiento, el resto en validacion
sample <- sample.int(nrow(cero), round(value*nrow(cero)))
cero.train <- cero[sample, ]
cero.test <- cero[-sample, ]
#dim(cero.train)
#dim(cero.test)
#creo entrenamiento y validacion
data.train<-rbind(cero.train,unos.train)
data.test<-rbind(cero.test,unos.test)

XGBoost

Se procede a ajustar el modelo de clasificación XGBoost

## 
## Attaching package: 'xgboost'
## The following object is masked from 'package:dplyr':
## 
##     slice
## 
## Attaching package: 'data.table'
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
## The following object is masked from 'package:purrr':
## 
##     transpose
## Loading required package: ParamHelpers
## 
## Attaching package: 'mlr'
## The following object is masked from 'package:caret':
## 
##     train
## [1]  train-error:0.109420+0.000449   test-error:0.113007+0.001917 
## [2]  train-error:0.109218+0.000437   test-error:0.112515+0.002022 
## [3]  train-error:0.109120+0.000202   test-error:0.112161+0.001918 
## [4]  train-error:0.108983+0.000427   test-error:0.111827+0.002199 
## [5]  train-error:0.109081+0.000418   test-error:0.111768+0.002180 
## [6]  train-error:0.109086+0.000443   test-error:0.111808+0.002295 
## [7]  train-error:0.109312+0.000229   test-error:0.111906+0.002255 
## [8]  train-error:0.109194+0.000298   test-error:0.112004+0.002007 
## [9]  train-error:0.109184+0.000322   test-error:0.112083+0.002068 
## [10] train-error:0.109105+0.000340   test-error:0.112024+0.002130 
## [11] train-error:0.109149+0.000378   test-error:0.112083+0.002129 
## [12] train-error:0.108948+0.000355   test-error:0.111965+0.001986 
## [13] train-error:0.108929+0.000391   test-error:0.112161+0.002101
## [1]  val-error:0.112314  train-error:0.109548 
## [2]  val-error:0.112177  train-error:0.108860 
## [3]  val-error:0.111941  train-error:0.108840 
## [4]  val-error:0.111823  train-error:0.109253 
## [5]  val-error:0.111941  train-error:0.109194 
## [6]  val-error:0.111921  train-error:0.109528 
## [7]  val-error:0.111666  train-error:0.109233 
## [8]  val-error:0.111548  train-error:0.109253 
## [9]  val-error:0.111607  train-error:0.109548 
## [10] val-error:0.111803  train-error:0.109528 
## [11] val-error:0.111803  train-error:0.109430 
## [12] val-error:0.111666  train-error:0.109115 
## [13] val-error:0.111705  train-error:0.109213
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction     0     1
##          0    71    76
##          1  5608 45129
##                                          
##                Accuracy : 0.8883         
##                  95% CI : (0.8855, 0.891)
##     No Information Rate : 0.8884         
##     P-Value [Acc > NIR] : 0.5316         
##                                          
##                   Kappa : 0.0188         
##                                          
##  Mcnemar's Test P-Value : <2e-16         
##                                          
##             Sensitivity : 0.012502       
##             Specificity : 0.998319       
##          Pos Pred Value : 0.482993       
##          Neg Pred Value : 0.889469       
##              Prevalence : 0.111607       
##          Detection Rate : 0.001395       
##    Detection Prevalence : 0.002889       
##       Balanced Accuracy : 0.505410       
##                                          
##        'Positive' Class : 0              
## 

-Por otro lado, con mayor disponibilidad de tiempo para el análisis se sugeriría hacer tratamiento de outliers, reducción de dimensionalidad y data binning.

-También se sugeriría correr otras modelos de clasificación más simples como una regresión logística o ensambles tipo bagging para comparar su desempeño.