data<-read.csv("C:/R_work/ECMO905.csv")
head(data)
  Unit.number   Name Sex Age     Date Year Holiday Insertion.time
1   `08243022 이영순   1  49 20090511 2009       1              1
2    13034861 윤기정   1  77 20090518 2009       1             NA
3    14186610 임지현   1  33 20090722 2009       1              1
4    14340394 이수맹   0  67 20091007 2009       1              1
5    10870744 김창길   0  56 20100212 2010       1              0
6    11071670 이영익   0  67 20100217 2010       1              0
  ECMO.duration Death Height Weight   BMI   Diagnosis Smoking CAD CVA PAD
1             8     1     NA     NA    NA Myocarditis       2   1   1   1
2            24     0     NA     NA    NA         ACS       2   1   1   1
3             8     2     NA     NA    NA        ARDS       2   1   1   1
4            15     0     NA     NA    NA         ACS       0   0   1   1
5             5     0   1.65     68 29.76         ACS       2   1   1   1
6             2     0   1.70     65 26.37        ARDS       2   1   1   1
  DM HBP Indication Mode CA OHCA CPR.duration CA.ECMO.Time EKG Weaning
1  1   1          0    0  1   NA           NA           NA   2       0
2  1   0          0    0  1   NA           NA           NA   2       0
3  1   1          1    1  1   NA           NA           NA   2       0
4  0   0          0    0  0    1           37           37   0       0
5  1   0          0    0  0    1           25           25   0       1
6  1   1          1    1  0    1          210          210   2       1
  Vent Intu.day HD ICU.stay CRRT CRRT.duration CAG PCI GCS Bleeding
1    0        8 30       11    0             8   1   1  15        1
2    0       27 31       31    1            NA   0   1   5        1
3    0       27 28       28    1            NA   1   1  15        0
4    0       17 17       17    0            13   0   0   3        1
5    0        5  5        5    0             3   0   0   3        1
6    0        3 43        3    1            NA   1   1  12        1
  Tamponade Pulmo AKI Liver.failure MOF Sepsis Stroke Leg.ischemia   WBC
1         1     1   0             1   1      1      1            1 16400
2         1     1   0             1   1      1      1            1  5230
3         1     0   1             1   0      0      1            1 18030
4         1     0   0             1   0      1      1            1  9670
5         1     1   0             1   1      1      1            1 10930
6         1     1   0             1   1      0      1            1 17950
   Hct PLT Sodium   K Lactate   PH HCO3  BUN  Cr Glucose Albumin
1 43.0 248  143.2 3.9    10.6 7.20 15.9 20.1 2.3     184     4.7
2 30.1 154  143.2 3.1      NA 7.49 22.0  6.3 1.0     153     4.2
3 37.8  55  148.9 3.4      NA 7.59 23.3 22.3 1.3     150     3.1
4 36.0  54  144.8 3.4      NA 7.26  9.0 20.1 1.5      56     2.2
5 44.8 293  136.8 3.2      NA 7.18 13.4 15.9 1.5     200     2.5
6 22.3  70  143.2 6.5      NA 7.14 10.9 48.9 2.5     488     1.6
  Total..bilirubin   CRP D.dimer  CK.MB Troponin PRC FFP  PC Cryo
1              1.1  0.31    2.29  30.95    3.050   5   3  72    0
2              0.5  1.03      NA   3.97    0.298  22   7  61    0
3              1.1  8.22   11.28 219.50    1.300   4  19  40    0
4              0.5 13.34    1.03   8.91    0.088  35   9 136    0
5              0.6  0.07      NA   3.47    0.020  10   0  18    0
6              0.3 23.27    0.44   4.38    0.036  24   5  42    0
data1=data[data$Death<2,-c(1,2,5)]
data1$Survive=ifelse(data1$Death==0,0,1)
table(data1$Death)

 0  1 
51 22 
library(compareGroups)
data1$Sex=ifelse(data1$Sex==1,"Female","Male")
data1$Holiday=ifelse(data1$Holiday==1,"Not Holiday","Holiday")
data1$Insertion.time=ifelse(data1$Insertion.time==1,"Emergency","Elective")
data1$Death=ifelse(data1$Death==1,"Survivor","Non-survivor")
data1$Smoking=ifelse(data1$Smoking==1,"No","Yes")
data1$CAD=ifelse(data1$CAD==1,"No","Yes")
data1$CVA=ifelse(data1$CVA==1,"No","Yes")
data1$PAD=ifelse(data1$PAD==1,"No","Yes")
data1$DM=ifelse(data1$DM==1,"No","Yes")
data1$HBP=ifelse(data1$HBP==1,"No","Yes")
data1$Indication=ifelse(data1$Indication==1,"Respiratory","Cardiology")
data1$Mode=ifelse(data1$Mode==1,"VV","VA")
data1$CA=ifelse(data1$CA==1,"No","Yes")
data1$OHCA=ifelse(data1$OHCA==1,"IHCA","OHCA")
data1$EKG=ifelse(data1$EKG==0,"Asystole",
                 ifelse(data1$EKG==1,"PEA","ETC"))
data1$Weaning=ifelse(data1$Weaning==1,"Fail","Success")
data1$Vent=ifelse(data1$Vent==1,"No","Yes")
data1$CRRT=ifelse(data1$CRRT==1,"No","Yes")
data1$CAG=ifelse(data1$CAG==1,"No","Yes")
data1$PCI=ifelse(data1$PCI==1,"No","Yes")
data1$Bleeding=ifelse(data1$Bleeding==1,"No","Yes")
data1$Tamponade=ifelse(data1$Tamponade==1,"No","Yes")
data1$Pulmo=ifelse(data1$Pulmo==1,"No","Yes")
data1$AKI=ifelse(data1$AKI==1,"No","Yes")
data1$Liver.failure=ifelse(data1$Liver.failure==1,"No","Yes")
data1$MOF=ifelse(data1$MOF==1,"No","Yes")
data1$Sepsis=ifelse(data1$Sepsis==1,"No","Yes")
data1$Stroke=ifelse(data1$Stroke==1,"No","Yes")
data1$Leg.ischemia=ifelse(data1$Leg.ischemia==1,"No","Yes")
mosaicplot(~Year+Death,data=data1,color=TRUE,main="Distribution of ECMO")

plot of chunk unnamed-chunk-1

res=compareGroups(Survive~.,data=data1)
res


-------- Summary of results by groups of 'Survive'---------


   var              N  p.value  method            selection
1  Sex              73 0.812    categorical       ALL      
2  Age              73 0.034**  continuous normal ALL      
3  Year             73 0.026**  continuous normal ALL      
4  Holiday          73 1.000    categorical       ALL      
5  Insertion.time   72 0.729    categorical       ALL      
6  ECMO.duration    73 0.170    continuous normal ALL      
7  Death            73 <0.001** categorical       ALL      
8  Height           64 0.684    continuous normal ALL      
9  Weight           66 0.910    continuous normal ALL      
10 BMI              64 0.629    continuous normal ALL      
11 Diagnosis        73 0.175    categorical       ALL      
12 Smoking          73 0.476    categorical       ALL      
13 CAD              73 0.320    categorical       ALL      
14 CVA              73 1.000    categorical       ALL      
15 PAD              73 .        categorical       ALL      
16 DM               73 0.196    categorical       ALL      
17 HBP              73 0.188    categorical       ALL      
18 Indication       73 0.747    categorical       ALL      
19 Mode             73 0.747    categorical       ALL      
20 CA               73 0.132    categorical       ALL      
21 OHCA             38 1.000    categorical       ALL      
22 CPR.duration     38 0.065*   continuous normal ALL      
23 CA.ECMO.Time     38 0.074*   continuous normal ALL      
24 EKG              73 0.041**  categorical       ALL      
25 Weaning          73 <0.001** categorical       ALL      
26 Vent             73 0.088*   categorical       ALL      
27 HD               73 <0.001** continuous normal ALL      
28 ICU.stay         73 <0.001** continuous normal ALL      
29 CRRT             73 0.243    categorical       ALL      
30 CRRT.duration    29 0.175    continuous normal ALL      
31 CAG              73 0.231    categorical       ALL      
32 PCI              73 0.476    categorical       ALL      
33 GCS              73 0.002**  continuous normal ALL      
34 Bleeding         73 0.578    categorical       ALL      
35 Tamponade        73 1.000    categorical       ALL      
36 Pulmo            73 0.714    categorical       ALL      
37 AKI              73 0.342    categorical       ALL      
38 Liver.failure    73 0.308    categorical       ALL      
39 MOF              73 0.029**  categorical       ALL      
40 Sepsis           73 1.000    categorical       ALL      
41 Stroke           73 0.088*   categorical       ALL      
42 Leg.ischemia     73 0.579    categorical       ALL      
43 WBC              73 0.632    continuous normal ALL      
44 Hct              73 0.604    continuous normal ALL      
45 PLT              73 0.429    continuous normal ALL      
46 Sodium           73 0.441    continuous normal ALL      
47 K                73 0.017**  continuous normal ALL      
48 Lactate          48 0.046**  continuous normal ALL      
49 PH               73 0.103    continuous normal ALL      
50 HCO3             73 0.048**  continuous normal ALL      
51 BUN              73 0.018**  continuous normal ALL      
52 Cr               73 0.004**  continuous normal ALL      
53 Glucose          72 0.392    continuous normal ALL      
54 Albumin          73 0.676    continuous normal ALL      
55 Total..bilirubin 73 0.532    continuous normal ALL      
56 CRP              73 0.161    continuous normal ALL      
57 D.dimer          49 0.796    continuous normal ALL      
58 CK.MB            64 0.829    continuous normal ALL      
59 Troponin         62 0.556    continuous normal ALL      
60 PRC              72 0.219    continuous normal ALL      
61 FFP              72 0.381    continuous normal ALL      
62 PC               72 0.087*   continuous normal ALL      
63 Cryo             72 0.787    continuous normal ALL      
-----
Signif. codes:  0 '**' 0.05 '*' 0.1 ' ' 1 
createTable(res)

--------Summary descriptives table by 'Survive'---------

_________________________________________________________ 
                           0            1       p.overall 
                          N=51         N=22               
<U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF> 
Sex:                                              0.812   
    Female             20 (39.2%)   10 (45.5%)            
    Male               31 (60.8%)   12 (54.5%)            
Age                   63.6 (13.6)  53.3 (19.7)    0.034   
Year                  2012 (1.41)  2013 (1.44)    0.026   
Holiday:                                          1.000   
    Holiday            7 (13.7%)    3 (13.6%)             
    Not Holiday        44 (86.3%)   19 (86.4%)            
Insertion.time:                                   0.729   
    Elective           28 (56.0%)   14 (63.6%)            
    Emergency          22 (44.0%)   8 (36.4%)             
ECMO.duration         6.86 (6.52)  8.73 (4.61)    0.170   
Death:                                           <0.001   
    Non-survivor       51 (100%)    0 (0.00%)             
    Survivor           0 (0.00%)    22 (100%)             
Height                1.64 (0.08)  1.62 (0.19)    0.684   
Weight                60.6 (8.69)  60.2 (14.5)    0.910   
BMI                   26.7 (3.50)  26.2 (4.04)    0.629   
Diagnosis:                                        0.175   
    ACS                26 (51.0%)   5 (22.7%)             
    ARDS               8 (15.7%)    5 (22.7%)             
    Drug Intoxication  1 (1.96%)    0 (0.00%)             
    LA myxoma          1 (1.96%)    0 (0.00%)             
    Myocarditis        2 (3.92%)    4 (18.2%)             
    PTE                4 (7.84%)    4 (18.2%)             
    Pump failure       5 (9.80%)    2 (9.09%)             
    Trauma             1 (1.96%)    1 (4.55%)             
    VF, VT             3 (5.88%)    1 (4.55%)             
Smoking:                                          0.476   
    No                 6 (11.8%)    4 (18.2%)             
    Yes                45 (88.2%)   18 (81.8%)            
CAD:                                              0.320   
    No                 40 (78.4%)   20 (90.9%)            
    Yes                11 (21.6%)   2 (9.09%)             
CVA:                                              1.000   
    No                 48 (94.1%)   21 (95.5%)            
    Yes                3 (5.88%)    1 (4.55%)             
PAD: No                51 (100%)    22 (100%)       .     
DM:                                               0.196   
    No                 35 (68.6%)   19 (86.4%)            
    Yes                16 (31.4%)   3 (13.6%)             
HBP:                                              0.188   
    No                 27 (52.9%)   16 (72.7%)            
    Yes                24 (47.1%)   6 (27.3%)             
Indication:                                       0.747   
    Cardiology         42 (82.4%)   17 (77.3%)            
    Respiratory        9 (17.6%)    5 (22.7%)             
Mode:                                             0.747   
    VA                 42 (82.4%)   17 (77.3%)            
    VV                 9 (17.6%)    5 (22.7%)             
CA:                                               0.132   
    No                 21 (41.2%)   14 (63.6%)            
    Yes                30 (58.8%)   8 (36.4%)             
OHCA:                                             1.000   
    IHCA               26 (86.7%)   7 (87.5%)             
    OHCA               4 (13.3%)    1 (12.5%)             
CPR.duration          33.4 (37.2)  16.9 (15.0)    0.065   
CA.ECMO.Time           112 (224)   35.2 (16.3)    0.074   
EKG:                                              0.041   
    Asystole           15 (29.4%)   1 (4.55%)             
    ETC                33 (64.7%)   20 (90.9%)            
    PEA                3 (5.88%)    1 (4.55%)             
Weaning:                                         <0.001   
    Fail               43 (84.3%)   0 (0.00%)             
    Success            8 (15.7%)    22 (100%)             
Vent:                                             0.088   
    No                 0 (0.00%)    2 (9.09%)             
    Yes                51 (100%)    20 (90.9%)            
HD                    15.0 (15.6)  41.8 (17.3)   <0.001   
ICU.stay              9.92 (9.44)  19.7 (9.61)   <0.001   
CRRT:                                             0.243   
    No                 28 (54.9%)   16 (72.7%)            
    Yes                23 (45.1%)   6 (27.3%)             
CRRT.duration         5.78 (4.65)  9.17 (5.00)    0.175   
CAG:                                              0.231   
    No                 23 (45.1%)   14 (63.6%)            
    Yes                28 (54.9%)   8 (36.4%)             
PCI:                                              0.476   
    No                 36 (70.6%)   18 (81.8%)            
    Yes                15 (29.4%)   4 (18.2%)             
GCS                   6.88 (4.25)  10.7 (4.51)    0.002   
Bleeding:                                         0.578   
    No                 32 (62.7%)   16 (72.7%)            
    Yes                19 (37.3%)   6 (27.3%)             
Tamponade:                                        1.000   
    No                 48 (94.1%)   21 (95.5%)            
    Yes                3 (5.88%)    1 (4.55%)             
Pulmo:                                            0.714   
    No                 44 (86.3%)   20 (90.9%)            
    Yes                7 (13.7%)    2 (9.09%)             
AKI:                                              0.342   
    No                 27 (52.9%)   15 (68.2%)            
    Yes                24 (47.1%)   7 (31.8%)             
Liver.failure:                                    0.308   
    No                 47 (92.2%)   22 (100%)             
    Yes                4 (7.84%)    0 (0.00%)             
MOF:                                              0.029   
    No                 35 (68.6%)   21 (95.5%)            
    Yes                16 (31.4%)   1 (4.55%)             
Sepsis:                                           1.000   
    No                 45 (88.2%)   19 (86.4%)            
    Yes                6 (11.8%)    3 (13.6%)             
Stroke:                                           0.088   
    No                 51 (100%)    20 (90.9%)            
    Yes                0 (0.00%)    2 (9.09%)             
Leg.ischemia:                                     0.579   
    No                 49 (96.1%)   20 (90.9%)            
    Yes                2 (3.92%)    2 (9.09%)             
WBC                   13814 (8323) 13009 (5637)   0.632   
Hct                   34.3 (7.27)  35.3 (7.98)    0.604   
PLT                    166 (100)    148 (78.2)    0.429   
Sodium                 142 (5.28)   141 (5.91)    0.441   
K                     4.36 (1.08)  3.93 (0.45)    0.017   
Lactate               7.13 (5.48)  4.00 (4.52)    0.046   
PH                    7.24 (0.16)  7.32 (0.21)    0.103   
HCO3                  13.8 (5.12)  17.0 (6.54)    0.048   
BUN                   29.0 (17.7)  20.9 (10.3)    0.018   
Cr                    1.64 (1.23)  1.05 (0.41)    0.004   
Glucose                209 (108)    192 (59.6)    0.392   
Albumin               2.95 (0.86)  3.04 (0.78)    0.676   
Total..bilirubin      1.21 (1.37)  1.42 (1.26)    0.532   
CRP                   6.19 (7.69)  9.78 (10.6)    0.161   
D.dimer               9.86 (12.2)  8.94 (11.4)    0.796   
CK.MB                 36.8 (47.6)  33.0 (72.6)    0.829   
Troponin              1.56 (3.52)  1.13 (2.17)    0.556   
PRC                   27.0 (27.6)  20.1 (18.2)    0.219   
FFP                   12.2 (14.3)  9.33 (11.4)    0.381   
PC                    54.6 (62.3)  35.0 (33.2)    0.087   
Cryo                  1.90 (4.88)  1.62 (3.61)    0.787   
<U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF><U+00AF> 
data1$EKG1=ifelse(data1$EKG=="ETC","ETC", "Asystole/PEA")
head(data1)
     Sex Age Year     Holiday Insertion.time ECMO.duration        Death
1 Female  49 2009 Not Holiday      Emergency             8     Survivor
2 Female  77 2009 Not Holiday           <NA>            24 Non-survivor
4   Male  67 2009 Not Holiday      Emergency            15 Non-survivor
5   Male  56 2010 Not Holiday       Elective             5 Non-survivor
6   Male  67 2010 Not Holiday       Elective             2 Non-survivor
7   Male  76 2010 Not Holiday       Elective             5 Non-survivor
  Height Weight   BMI   Diagnosis Smoking CAD CVA PAD  DM HBP  Indication
1     NA     NA    NA Myocarditis     Yes  No  No  No  No  No  Cardiology
2     NA     NA    NA         ACS     Yes  No  No  No  No Yes  Cardiology
4     NA     NA    NA         ACS     Yes Yes  No  No Yes Yes  Cardiology
5   1.65     68 29.76         ACS     Yes  No  No  No  No Yes  Cardiology
6   1.70     65 26.37        ARDS     Yes  No  No  No  No  No Respiratory
7   1.64     68 30.21         ACS      No  No  No  No Yes Yes  Cardiology
  Mode  CA OHCA CPR.duration CA.ECMO.Time      EKG Weaning Vent Intu.day
1   VA  No <NA>           NA           NA      ETC Success  Yes        8
2   VA  No <NA>           NA           NA      ETC Success  Yes       27
4   VA Yes IHCA           37           37 Asystole Success  Yes       17
5   VA Yes IHCA           25           25 Asystole    Fail  Yes        5
6   VV Yes IHCA          210          210      ETC    Fail  Yes        3
7   VA  No <NA>           NA           NA      ETC Success  Yes        9
  HD ICU.stay CRRT CRRT.duration CAG PCI GCS Bleeding Tamponade Pulmo AKI
1 30       11  Yes             8  No  No  15       No        No    No Yes
2 31       31   No            NA Yes  No   5       No        No    No Yes
4 17       17  Yes            13 Yes Yes   3       No        No   Yes Yes
5  5        5  Yes             3 Yes Yes   3       No        No    No Yes
6 43        3   No            NA  No  No  12       No        No    No Yes
7 12       12   No            NA Yes Yes   4       No        No    No  No
  Liver.failure MOF Sepsis Stroke Leg.ischemia   WBC  Hct PLT Sodium   K
1            No  No     No     No           No 16400 43.0 248  143.2 3.9
2            No  No     No     No           No  5230 30.1 154  143.2 3.1
4            No Yes     No     No           No  9670 36.0  54  144.8 3.4
5            No  No     No     No           No 10930 44.8 293  136.8 3.2
6            No  No    Yes     No           No 17950 22.3  70  143.2 6.5
7            No Yes     No     No           No  6790 40.1 173  140.5 3.8
  Lactate   PH HCO3  BUN  Cr Glucose Albumin Total..bilirubin   CRP
1    10.6 7.20 15.9 20.1 2.3     184     4.7              1.1  0.31
2      NA 7.49 22.0  6.3 1.0     153     4.2              0.5  1.03
4      NA 7.26  9.0 20.1 1.5      56     2.2              0.5 13.34
5      NA 7.18 13.4 15.9 1.5     200     2.5              0.6  0.07
6      NA 7.14 10.9 48.9 2.5     488     1.6              0.3 23.27
7      NA 7.29 14.9 15.8 0.9     178     3.8              1.1  0.29
  D.dimer CK.MB Troponin PRC FFP  PC Cryo Survive         EKG1
1    2.29 30.95    3.050   5   3  72    0       1          ETC
2      NA  3.97    0.298  22   7  61    0       0          ETC
4    1.03  8.91    0.088  35   9 136    0       0 Asystole/PEA
5      NA  3.47    0.020  10   0  18    0       0 Asystole/PEA
6    0.44  4.38    0.036  24   5  42    0       0          ETC
7      NA 17.70    0.674  14   0  46    0       0          ETC
boxplot(K~Survive,data=data1)

plot of chunk unnamed-chunk-1

boxplot(PH~Survive,data=data1)

plot of chunk unnamed-chunk-1

boxplot(HCO3~Survive,data=data1)

plot of chunk unnamed-chunk-1

data2=data1[data1$EKG1=="ETC",]
data3=data1[data1$EKG1!="ETC",]

cor.test(data1$K,data1$PH)

    Pearson's product-moment correlation

data:  data1$K and data1$PH
t = -0.9558, df = 71, p-value = 0.3424
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.3341  0.1205
sample estimates:
    cor 
-0.1127 
cor.test(data1$K,data1$HCO3)

    Pearson's product-moment correlation

data:  data1$K and data1$HCO3
t = -1.81, df = 71, p-value = 0.07445
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.41985  0.02101
sample estimates:
    cor 
-0.2101 
model=glm(Survive~Age+DM+GCS+CA.ECMO.Time+K+HCO3+PH+Cr+CRP+EKG1,data=data1)
summary(model)

Call:
glm(formula = Survive ~ Age + DM + GCS + CA.ECMO.Time + K + HCO3 + 
    PH + Cr + CRP + EKG1, data = data1)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-0.450  -0.221  -0.100   0.122   0.920  

Coefficients:
              Estimate Std. Error t value Pr(>|t|)  
(Intercept)   4.409608   2.898546    1.52    0.140  
Age          -0.004126   0.004533   -0.91    0.371  
DMYes        -0.004492   0.154742   -0.03    0.977  
GCS           0.013508   0.016248    0.83    0.413  
CA.ECMO.Time -0.000605   0.000354   -1.71    0.098 .
K            -0.062913   0.080790   -0.78    0.443  
HCO3          0.007142   0.019483    0.37    0.717  
PH           -0.543038   0.414999   -1.31    0.202  
Cr           -0.054469   0.078921   -0.69    0.496  
CRP           0.009290   0.009752    0.95    0.349  
EKG1ETC       0.318728   0.162452    1.96    0.060 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 0.1479)

    Null deviance: 6.3158  on 37  degrees of freedom
Residual deviance: 3.9928  on 27  degrees of freedom
  (35 observations deleted due to missingness)
AIC: 46.22

Number of Fisher Scoring iterations: 2
model1=glm(Survive~Age+GCS+CA.ECMO.Time+K+HCO3+EKG1,data=data1)
summary(model1)

Call:
glm(formula = Survive ~ Age + GCS + CA.ECMO.Time + K + HCO3 + 
    EKG1, data = data1)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-0.5290  -0.2085  -0.0846   0.0814   0.9116  

Coefficients:
              Estimate Std. Error t value Pr(>|t|)  
(Intercept)   0.694469   0.434642    1.60    0.120  
Age          -0.004996   0.004297   -1.16    0.254  
GCS           0.013879   0.014841    0.94    0.357  
CA.ECMO.Time -0.000546   0.000343   -1.59    0.121  
K            -0.100673   0.056008   -1.80    0.082 .
HCO3          0.006385   0.015027    0.42    0.674  
EKG1ETC       0.295827   0.144800    2.04    0.050 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 0.1424)

    Null deviance: 6.3158  on 37  degrees of freedom
Residual deviance: 4.4159  on 31  degrees of freedom
  (35 observations deleted due to missingness)
AIC: 42.05

Number of Fisher Scoring iterations: 2
model2=glm(Survive~Age+GCS+CA.ECMO.Time+K+EKG1,data=data1)
summary(model2)

Call:
glm(formula = Survive ~ Age + GCS + CA.ECMO.Time + K + EKG1, 
    data = data1)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-0.5078  -0.1894  -0.0880   0.0692   0.9243  

Coefficients:
              Estimate Std. Error t value Pr(>|t|)  
(Intercept)   0.783343   0.376098    2.08    0.045 *
Age          -0.005103   0.004234   -1.21    0.237  
GCS           0.013207   0.014566    0.91    0.371  
CA.ECMO.Time -0.000550   0.000338   -1.63    0.114  
K            -0.102079   0.055190   -1.85    0.074 .
EKG1ETC       0.303278   0.141882    2.14    0.040 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 0.1388)

    Null deviance: 6.3158  on 37  degrees of freedom
Residual deviance: 4.4416  on 32  degrees of freedom
  (35 observations deleted due to missingness)
AIC: 40.27

Number of Fisher Scoring iterations: 2
model3=glm(Survive~Age+GCS+K,data=data1)
summary(model3)

Call:
glm(formula = Survive ~ Age + GCS + K, data = data1)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-0.634  -0.260  -0.125   0.325   0.855  

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.00046    0.30839    3.24   0.0018 ** 
Age         -0.00857    0.00293   -2.92   0.0047 ** 
GCS          0.03591    0.01024    3.51   0.0008 ***
K           -0.11078    0.05012   -2.21   0.0304 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 0.162)

    Null deviance: 15.370  on 72  degrees of freedom
Residual deviance: 11.177  on 69  degrees of freedom
AIC: 80.18

Number of Fisher Scoring iterations: 2
anova(model2,model1,model,test="Chisq")
Analysis of Deviance Table

Model 1: Survive ~ Age + GCS + CA.ECMO.Time + K + EKG1
Model 2: Survive ~ Age + GCS + CA.ECMO.Time + K + HCO3 + EKG1
Model 3: Survive ~ Age + DM + GCS + CA.ECMO.Time + K + HCO3 + PH + Cr + 
    CRP + EKG1
  Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1        32       4.44                     
2        31       4.42  1    0.026     0.68
3        27       3.99  4    0.423     0.58
kmodel=glm(Survive~K,data=data1)
summary(kmodel)

Call:
glm(formula = Survive ~ K, data = data1)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-0.490  -0.336  -0.253   0.623   0.747  

Coefficients:
            Estimate Std. Error t value Pr(>|t|)   
(Intercept)   0.7380     0.2442    3.02   0.0035 **
K            -0.1031     0.0563   -1.83   0.0712 . 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 0.2067)

    Null deviance: 15.370  on 72  degrees of freedom
Residual deviance: 14.676  on 71  degrees of freedom
AIC: 96.06

Number of Fisher Scoring iterations: 2
plot(Survive~K,data=data1)

plot of chunk unnamed-chunk-1

plot(Survive~K,data=data2)

plot of chunk unnamed-chunk-1

plot(Survive~K,data=data3)

curve(predict(kmodel,data.frame(K=x),type="resp"),add=TRUE,col="blue",lty=3)

plot of chunk unnamed-chunk-1

predict.data = seq(3,8,0.1)
y=plogis(kmodel$coefficients[1]+kmodel$coefficient[2]*predict.data)
xy=data.frame(K=predict.data)
yhat=predict(kmodel,xy,type="link",se.fit=TRUE)
yhat
$fit
        1         2         3         4         5         6         7 
 0.428538  0.418224  0.407909  0.397594  0.387279  0.376964  0.366650 
        8         9        10        11        12        13        14 
 0.356335  0.346020  0.335705  0.325391  0.315076  0.304761  0.294446 
       15        16        17        18        19        20        21 
 0.284131  0.273817  0.263502  0.253187  0.242872  0.232558  0.222243 
       22        23        24        25        26        27        28 
 0.211928  0.201613  0.191298  0.180984  0.170669  0.160354  0.150039 
       29        30        31        32        33        34        35 
 0.139725  0.129410  0.119095  0.108780  0.098465  0.088151  0.077836 
       36        37        38        39        40        41        42 
 0.067521  0.057206  0.046891  0.036577  0.026262  0.015947  0.005632 
       43        44        45        46        47        48        49 
-0.004682 -0.014997 -0.025312 -0.035627 -0.045942 -0.056256 -0.066571 
       50        51 
-0.076886 -0.087201 

$se.fit
      1       2       3       4       5       6       7       8       9 
0.08748 0.08308 0.07883 0.07478 0.07093 0.06734 0.06405 0.06109 0.05853 
     10      11      12      13      14      15      16      17      18 
0.05642 0.05481 0.05374 0.05325 0.05335 0.05404 0.05530 0.05709 0.05936 
     19      20      21      22      23      24      25      26      27 
0.06206 0.06514 0.06854 0.07222 0.07614 0.08027 0.08457 0.08901 0.09359 
     28      29      30      31      32      33      34      35      36 
0.09827 0.10305 0.10792 0.11285 0.11784 0.12290 0.12799 0.13314 0.13832 
     37      38      39      40      41      42      43      44      45 
0.14353 0.14878 0.15405 0.15935 0.16466 0.17000 0.17536 0.18073 0.18612 
     46      47      48      49      50      51 
0.19153 0.19694 0.20237 0.20781 0.21326 0.21872 

$residual.scale
[1] 0.4547
upperlogit=yhat$fit+1.96*yhat$se.fit
lowerlogit=yhat$fit-1.96*yhat$se.fit
ucl=plogis(upperlogit)
lcl=plogis(lowerlogit)
plot(predict.data,y,type="l",ylim=c(0,1),ylab="Predicted probability of survival",xlab="K")
lines(predict.data,ucl,lty=2,lwd=2)
lines(predict.data,lcl,lty=2,lwd=2)

plot of chunk unnamed-chunk-1