Khác với mô hình hồi quy tuyến tính là phân tích mối liên hệ giữa các biến liên tục. Phân tích hồi quy logistic là tìm mối tương quan giữa biến phụ thuộc là biến nhị phân với biến tiên lượng –> Nghiên cứu LAR trong tiên lượng tử vong 28 ngày ở BN nhiễm khuẩn huyết Ta có: Biến phụ thuộc là Tử vong(1) hay Sống(0), các biến còn lại là biến tiên lượng như tuổi, giới tính, bệnh lý đi kèm, nguồn nhiễm khuẩn, sinh hiệu, lactate, lar, albumin …
Vậy chạy logistic để làm gì? –> Một trong những ứng dụng của mô hình hồi quy logistic là xây dựng mô hình tiên lượng Mô hình này có thể sử dụng trong thực tế hay không? –> Phải đánh giá hai khía cạnh của mô hình tiên lượng: Thứ nhất là khả năng phân định (dùng AUC) Thứ hai là độ chính xác (calibration) - Chỉ số Brier
Quay lại nghiên cứu của mình #Chạy hồi quy logistic đơn biến (Lar, lactate, albumin) để trả lời câu hỏi có các giá trị tiên lượng của tỷ số lactate/albumin
library(readxl)
lar6 <- read_excel("~/Desktop/R - R studio/Chạy mẫu lần 3/lar6.xlsx")
View(lar6)
head(lar6,10)
## # A tibble: 10 × 58
## stt sex age ngay tha dtd btm dqn bpm bthm bgm ut nkp
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 0 87 18 1 0 0 0 0 0 0 0 1
## 2 2 1 70 6 0 0 0 0 0 0 0 1 1
## 3 3 1 69 20 1 1 0 0 0 0 0 0 0
## 4 4 1 71 12 1 1 1 0 0 0 0 0 0
## 5 5 0 66 13 1 1 0 0 0 0 0 0 0
## 6 6 1 78 4 1 0 1 0 0 0 0 0 1
## 7 7 1 73 8 0 0 0 0 0 0 0 0 1
## 8 8 0 87 1 0 0 0 1 0 0 0 0 1
## 9 9 0 63 1 0 0 0 1 0 0 0 1 1
## 10 10 1 67 11 1 0 1 0 0 0 0 0 1
## # ℹ 45 more variables: nktn <dbl>, nkth <dbl>, nkdmm <dbl>, khac <dbl>,
## # gcs <dbl>, hatb <dbl>, hatt <dbl>, hattr <dbl>, mach <dbl>, nhietdo <dbl>,
## # nhiptho <dbl>, sp02 <dbl>, fi02 <dbl>, PFr <dbl>, caymau <dbl>, rltk <dbl>,
## # rlhh <dbl>, rltm <dbl>, rlthan <dbl>, rlgan <dbl>, rldongmau <dbl>,
## # suydacoquan <dbl>, thongkhich <dbl>, locmau <dbl>, bc <dbl>, hct <dbl>,
## # tc <dbl>, bilitp <dbl>, lactate <dbl>, albumin <dbl>, lar <dbl>, pct <dbl>,
## # na <dbl>, k <dbl>, ast <dbl>, alt <dbl>, ure <dbl>, crea <dbl>, …
mean(lar6$age)
## [1] 73.19685
table(lar6$tuvong)
##
## 0 1
## 45 82
lar6$tuvong
## [1] 1 1 0 1 1 1 0 1 1 1 1 1 0 1 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 1 1 1 0 1 1
## [38] 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 1 0 1 0 1 1 0 0 1
## [75] 1 1 1 1 0 0 1 1 0 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1
## [112] 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1
plot(x=lar6$lactate, y=lar6$tuvong)
m = glm(lar6$tuvong ~ lar6$lactate, family=binomial)
lines(lar6$lactate, m$fitted.values)
library(pROC)
## Type 'citation("pROC")' for a citation.
##
## Attaching package: 'pROC'
## The following objects are masked from 'package:stats':
##
## cov, smooth, var
roc(lar6$tuvong, m$fitted.values, plot = TRUE,legacy.axes=TRUE, percent=TRUE,
main = "Đường cong ROC của Lactate,Albumin,Lactate/Albumin",
xlab="1-Độ đặc hiệu", ylab="Độ nhạy",
col="#377eb8",ldw=4, print.auc=TRUE)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
##
## Call:
## roc.default(response = lar6$tuvong, predictor = m$fitted.values, percent = TRUE, plot = TRUE, legacy.axes = TRUE, main = "Đường cong ROC của Lactate,Albumin,Lactate/Albumin", xlab = "1-Độ đặc hiệu", ylab = "Độ nhạy", col = "#377eb8", ldw = 4, print.auc = TRUE)
##
## Data: m$fitted.values in 45 controls (lar6$tuvong 0) < 82 cases (lar6$tuvong 1).
## Area under the curve: 81.08%
lar6$tuvong
## [1] 1 1 0 1 1 1 0 1 1 1 1 1 0 1 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 1 1 1 0 1 1
## [38] 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 1 0 1 0 1 1 0 0 1
## [75] 1 1 1 1 0 0 1 1 0 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1
## [112] 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1
plot(x=lar6$albumin, y=lar6$tuvong)
m1 = glm(lar6$tuvong ~ lar6$albumin, family=binomial)
lines(lar6$albumin, m1$fitted.values)
library(pROC)
roc(lar6$tuvong, m1$fitted.values, plot = TRUE,legacy.axes=TRUE, percent=TRUE,
main = "Đường cong ROC của Lactate,Albumin,Lactate/Albumin",
xlab="1-Độ đặc hiệu", ylab="Độ nhạy",
col="#7eb837",ldw=4, print.auc=TRUE)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
##
## Call:
## roc.default(response = lar6$tuvong, predictor = m1$fitted.values, percent = TRUE, plot = TRUE, legacy.axes = TRUE, main = "Đường cong ROC của Lactate,Albumin,Lactate/Albumin", xlab = "1-Độ đặc hiệu", ylab = "Độ nhạy", col = "#7eb837", ldw = 4, print.auc = TRUE)
##
## Data: m1$fitted.values in 45 controls (lar6$tuvong 0) < 82 cases (lar6$tuvong 1).
## Area under the curve: 59.32%
lar6$tuvong
## [1] 1 1 0 1 1 1 0 1 1 1 1 1 0 1 1 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 1 1 1 0 1 1
## [38] 1 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 1 0 1 0 1 1 0 0 1
## [75] 1 1 1 1 0 0 1 1 0 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1
## [112] 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1
plot(x=lar6$lar, y=lar6$tuvong)
m2 = glm(lar6$tuvong ~ lar6$lar, family=binomial)
lines(lar6$lar, m2$fitted.values)
library(pROC)
roc(lar6$tuvong, m2$fitted.values, plot = TRUE,legacy.axes=TRUE, percent=TRUE,
main = "ROC của Lactate,Albumin,Lactate/Albumin",
xlab="1-Độ đặc hiệu", ylab="Độ nhạy",
col="#b8377e",ldw=4, print.auc=TRUE)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
##
## Call:
## roc.default(response = lar6$tuvong, predictor = m2$fitted.values, percent = TRUE, plot = TRUE, legacy.axes = TRUE, main = "ROC của Lactate,Albumin,Lactate/Albumin", xlab = "1-Độ đặc hiệu", ylab = "Độ nhạy", col = "#b8377e", ldw = 4, print.auc = TRUE)
##
## Data: m2$fitted.values in 45 controls (lar6$tuvong 0) < 82 cases (lar6$tuvong 1).
## Area under the curve: 82.53%
plot.roc(lar6$tuvong,m$fitted.values, percent=TRUE, col="#377eb8", print.auc=TRUE,
add=TRUE, print.auc.y=40)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
plot.roc(lar6$tuvong,m1$fitted.values, percent=TRUE, col="#7eb837", print.auc=TRUE,
add=TRUE, print.auc.y=30)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
legend("bottomright", legend=c("Lactate/Albumin", "Lactate", "Albumin"),
col=c("#b8377e", "#377eb8", "#7eb837"), lty=1:2, cex=0.8)
#Vẽ sơ đồ AUC của 3 biến, so sánh AUC?
#Chạy hồi quy logistic đa biến để tìm mô hình tiên lượng tốt nhất trên bệnh nhân NKH Làm sao để tìm ra mô hình tiên lượng tốt nhất? Có ba cách để tìm ra mô hình tiên lượng
library(table1)
##
## Attaching package: 'table1'
## The following objects are masked from 'package:base':
##
## units, units<-
table1(~ sex + age + hatb + mach + nhietdo + nhiptho + sp02 + lactate
+ albumin + lar + pct | tuvong, data = lar6)
## Warning in table1.formula(~sex + age + hatb + mach + nhietdo + nhiptho + :
## Terms to the right of '|' in formula 'x' define table columns and are expected
## to be factors with meaningful labels.
| 0 (N=45) |
1 (N=82) |
Overall (N=127) |
|
|---|---|---|---|
| sex | |||
| Mean (SD) | 0.667 (0.477) | 0.537 (0.502) | 0.583 (0.495) |
| Median [Min, Max] | 1.00 [0, 1.00] | 1.00 [0, 1.00] | 1.00 [0, 1.00] |
| age | |||
| Mean (SD) | 67.7 (14.3) | 76.2 (14.8) | 73.2 (15.1) |
| Median [Min, Max] | 69.0 [39.0, 96.0] | 79.0 [16.0, 101] | 74.0 [16.0, 101] |
| hatb | |||
| Mean (SD) | 96.5 (28.5) | 89.1 (26.1) | 91.7 (27.1) |
| Median [Min, Max] | 93.0 [43.0, 163] | 83.0 [43.0, 163] | 87.0 [43.0, 163] |
| mach | |||
| Mean (SD) | 112 (23.0) | 108 (24.8) | 109 (24.2) |
| Median [Min, Max] | 109 [62.0, 170] | 105 [60.0, 166] | 106 [60.0, 170] |
| nhietdo | |||
| Mean (SD) | 37.9 (1.06) | 37.4 (1.06) | 37.6 (1.08) |
| Median [Min, Max] | 38.0 [36.0, 41.3] | 37.0 [36.0, 41.1] | 37.5 [36.0, 41.3] |
| nhiptho | |||
| Mean (SD) | 27.6 (11.8) | 26.0 (7.92) | 26.6 (9.48) |
| Median [Min, Max] | 24.0 [18.0, 93.0] | 26.0 [10.0, 40.0] | 26.0 [10.0, 93.0] |
| sp02 | |||
| Mean (SD) | 90.6 (7.74) | 88.4 (12.2) | 89.1 (10.9) |
| Median [Min, Max] | 93.0 [65.0, 98.0] | 92.0 [20.0, 99.0] | 93.0 [20.0, 99.0] |
| lactate | |||
| Mean (SD) | 3.54 (1.93) | 7.30 (3.94) | 5.97 (3.81) |
| Median [Min, Max] | 3.07 [0.900, 8.05] | 6.85 [1.60, 20.8] | 5.10 [0.900, 20.8] |
| albumin | |||
| Mean (SD) | 2.64 (0.499) | 2.48 (0.615) | 2.54 (0.580) |
| Median [Min, Max] | 2.68 [1.49, 4.11] | 2.48 [0.840, 4.46] | 2.54 [0.840, 4.46] |
| lar | |||
| Mean (SD) | 1.39 (0.784) | 3.06 (1.70) | 2.47 (1.65) |
| Median [Min, Max] | 1.00 [0.310, 2.88] | 2.86 [0.530, 9.20] | 2.20 [0.310, 9.20] |
| pct | |||
| Mean (SD) | 29.2 (37.0) | 29.4 (35.7) | 29.4 (36.0) |
| Median [Min, Max] | 9.28 [0.0700, 100] | 9.74 [0.0500, 102] | 9.39 [0.0500, 102] |
lar6$lactate = factor(lar6$lactate)
m1 = glm(tuvong ~ lactate, family=binomial, data=lar6)
library(epiDisplay)
## Loading required package: foreign
## Loading required package: survival
## Loading required package: MASS
## Loading required package: nnet
##
## Attaching package: 'epiDisplay'
## The following object is masked from 'package:pROC':
##
## ci
logistic.display(m1)
##
## Logistic regression predicting tuvong
##
## OR(95%CI) P(Wald's test) P(LR-test)
## lactate: ref.=0.9 0.007
## 1.1 1 (0,Inf) 1
## 1.2 1 (0,Inf) 1
## 1.4 1 (0,Inf) 1
## 1.5 1 (0,Inf) 1
## 1.6 2322860230.78 (0,Inf) 0.999
## 1.7 1 (0,Inf) 1
## 1.79 5395697890075397120 (0,Inf) 0.999
## 1.8 1 (0,Inf) 1
## 2 1 (0,Inf) 1
## 2.02 1 (0,Inf) 1
## 2.1 4645720461.57 (0,Inf) 0.999
## 2.2 1 (0,Inf) 1
## 2.3 4645720461.57 (0,Inf) 0.999
## 2.4 1 (0,Inf) 1
## 2.5 1 (0,Inf) 1
## 2.51 1 (0,Inf) 1
## 2.6 5395697927948590080 (0,Inf) 0.999
## 2.68 5395698065841612800 (0,Inf) 0.999
## 2.7 1 (0,Inf) 1
## 2.9 1 (0,Inf) 1
## 3 5395698060265626624 (0,Inf) 0.999
## 3.07 1 (0,Inf) 1
## 3.1 1 (0,Inf) 1
## 3.2 1 (0,Inf) 1
## 3.3 5395697890441723904 (0,Inf) 0.999
## 3.35 5395698060040463360 (0,Inf) 0.999
## 3.4 2322860230.78 (0,Inf) 0.999
## 3.59 5395697927298518016 (0,Inf) 0.999
## 3.6 5395698084420107264 (0,Inf) 0.999
## 3.7 5395697894085093376 (0,Inf) 0.999
## 3.8 1 (0,Inf) 1
## 3.84 5395697890970952704 (0,Inf) 0.999
## 3.85 1 (0,Inf) 1
## 3.88 1 (0,Inf) 1
## 3.9 1 (0,Inf) 1
## 3.99 5.39569793201e+18 (0,Inf) 0.999
## 4 5395697925960803328 (0,Inf) 0.999
## 4.1 4645720461.57 (0,Inf) 0.999
## 4.2 5395697892051069952 (0,Inf) 0.999
## 4.32 5395698054680631296 (0,Inf) 0.999
## 4.5 2322860230.78 (0,Inf) 0.999
## 4.7 5395697920761379840 (0,Inf) 0.999
## 4.82 5395697927666838528 (0,Inf) 0.999
## 4.9 1 (0,Inf) 1
## 5.1 5395698092017350656 (0,Inf) 0.999
## 5.15 1 (0,Inf) 1
## 5.2 5395697892209715200 (0,Inf) 0.999
## 5.23 1 (0,Inf) 1
## 5.43 1 (0,Inf) 1
## 5.67 1 (0,Inf) 1
## 6 2322860230.78 (0,Inf) 0.999
## 6.1 2322860230.78 (0,Inf) 0.999
## 6.12 5395697925426016256 (0,Inf) 0.999
## 6.2 5395698086778476544 (0,Inf) 0.999
## 6.3 1 (0,Inf) 1
## 6.5 5395697928549856256 (0,Inf) 0.999
## 6.52 5395697929102240768 (0,Inf) 0.999
## 6.6 5395697893473091584 (0,Inf) 0.999
## 6.69 1 (0,Inf) 1
## 6.8 2322860230.78 (0,Inf) 0.999
## 6.83 5395697890708676608 (0,Inf) 0.999
## 6.86 5395697892494610432 (0,Inf) 0.999
## 6.9 1 (0,Inf) 1
## 7.1 5395698058852728832 (0,Inf) 0.999
## 7.18 5395697893856440320 (0,Inf) 0.999
## 7.3 5395697925696495616 (0,Inf) 0.999
## 7.7 5395697926181979136 (0,Inf) 0.999
## 7.76 5395697927070556160 (0,Inf) 0.999
## 7.84 5395697893087327232 (0,Inf) 0.999
## 7.9 5395697927023514624 (0,Inf) 0.999
## 8 5395698091665132544 (0,Inf) 0.999
## 8.05 1 (0,Inf) 1
## 8.1 5395697924982705152 (0,Inf) 0.999
## 8.56 5395697924860673024 (0,Inf) 0.999
## 8.6 5395697927556538368 (0,Inf) 0.999
## 8.67 5395698059706379264 (0,Inf) 0.999
## 8.8 5395697889792764928 (0,Inf) 0.999
## 8.98 5395697889967589376 (0,Inf) 0.999
## 9.01 5395698093273519104 (0,Inf) 0.999
## 9.1 5395698070710020096 (0,Inf) 0.999
## 9.32 5395698093565506560 (0,Inf) 0.999
## 9.7 5395697891957868544 (0,Inf) 0.999
## 9.75 5395697924977299456 (0,Inf) 0.999
## 10.2 5395698082254351360 (0,Inf) 0.999
## 10.5 5395697893417270272 (0,Inf) 0.999
## 10.6 5395698089636974592 (0,Inf) 0.999
## 10.9 5395697925550194688 (0,Inf) 0.999
## 11.45 5395697926578095104 (0,Inf) 0.999
## 12.2 5395697923692836864 (0,Inf) 0.999
## 12.3 5395698090118892544 (0,Inf) 0.999
## 12.8 5395698055814307840 (0,Inf) 0.999
## 13.03 5395697928296130560 (0,Inf) 0.999
## 13.2 5395697893200196608 (0,Inf) 0.999
## 14.1 5395697925682079744 (0,Inf) 0.999
## 14.2 5395698093245761536 (0,Inf) 0.999
## 14.3 5395697890597341184 (0,Inf) 0.999
## 15.4 5395697891039731712 (0,Inf) 0.999
## 17.5 5395697892787211264 (0,Inf) 0.999
## 20.82 5395697892481191936 (0,Inf) 0.999
##
## Log-likelihood = -14.0464
## No. of observations = 127
## AIC value = 228.0928
summary(m1)
##
## Call:
## glm(formula = tuvong ~ lactate, family = binomial, data = lar6)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.157e+01 2.923e+04 -0.001 0.999
## lactate1.1 -3.404e-06 4.134e+04 0.000 1.000
## lactate1.2 -3.401e-06 4.134e+04 0.000 1.000
## lactate1.4 -3.401e-06 4.134e+04 0.000 1.000
## lactate1.5 -3.404e-06 4.134e+04 0.000 1.000
## lactate1.6 2.157e+01 2.923e+04 0.001 0.999
## lactate1.7 -3.401e-06 3.375e+04 0.000 1.000
## lactate1.79 4.313e+01 4.134e+04 0.001 0.999
## lactate1.8 -3.401e-06 4.134e+04 0.000 1.000
## lactate2 -3.401e-06 3.580e+04 0.000 1.000
## lactate2.02 -3.401e-06 4.134e+04 0.000 1.000
## lactate2.1 2.226e+01 2.923e+04 0.001 0.999
## lactate2.2 -3.403e-06 3.580e+04 0.000 1.000
## lactate2.3 2.226e+01 2.923e+04 0.001 0.999
## lactate2.4 -3.401e-06 4.134e+04 0.000 1.000
## lactate2.5 -3.401e-06 4.134e+04 0.000 1.000
## lactate2.51 -3.401e-06 4.134e+04 0.000 1.000
## lactate2.6 4.313e+01 4.134e+04 0.001 0.999
## lactate2.68 4.313e+01 4.134e+04 0.001 0.999
## lactate2.7 -3.401e-06 4.134e+04 0.000 1.000
## lactate2.9 -3.401e-06 4.134e+04 0.000 1.000
## lactate3 4.313e+01 4.134e+04 0.001 0.999
## lactate3.07 -3.401e-06 4.134e+04 0.000 1.000
## lactate3.1 -3.401e-06 4.134e+04 0.000 1.000
## lactate3.2 -3.401e-06 4.134e+04 0.000 1.000
## lactate3.3 4.313e+01 3.580e+04 0.001 0.999
## lactate3.35 4.313e+01 4.134e+04 0.001 0.999
## lactate3.4 2.157e+01 2.923e+04 0.001 0.999
## lactate3.59 4.313e+01 4.134e+04 0.001 0.999
## lactate3.6 4.313e+01 3.580e+04 0.001 0.999
## lactate3.7 4.313e+01 3.580e+04 0.001 0.999
## lactate3.8 -3.401e-06 4.134e+04 0.000 1.000
## lactate3.84 4.313e+01 4.134e+04 0.001 0.999
## lactate3.85 -3.401e-06 4.134e+04 0.000 1.000
## lactate3.88 -3.401e-06 4.134e+04 0.000 1.000
## lactate3.9 -3.401e-06 4.134e+04 0.000 1.000
## lactate3.99 4.313e+01 4.134e+04 0.001 0.999
## lactate4 4.313e+01 4.134e+04 0.001 0.999
## lactate4.1 2.226e+01 2.923e+04 0.001 0.999
## lactate4.2 4.313e+01 3.580e+04 0.001 0.999
## lactate4.32 4.313e+01 4.134e+04 0.001 0.999
## lactate4.5 2.157e+01 2.923e+04 0.001 0.999
## lactate4.7 4.313e+01 3.580e+04 0.001 0.999
## lactate4.82 4.313e+01 4.134e+04 0.001 0.999
## lactate4.9 -3.401e-06 4.134e+04 0.000 1.000
## lactate5.1 4.313e+01 4.134e+04 0.001 0.999
## lactate5.15 -3.401e-06 4.134e+04 0.000 1.000
## lactate5.2 4.313e+01 4.134e+04 0.001 0.999
## lactate5.23 -3.402e-06 4.134e+04 0.000 1.000
## lactate5.43 -3.401e-06 4.134e+04 0.000 1.000
## lactate5.67 -3.401e-06 4.134e+04 0.000 1.000
## lactate6 2.157e+01 2.923e+04 0.001 0.999
## lactate6.1 2.157e+01 2.923e+04 0.001 0.999
## lactate6.12 4.313e+01 4.134e+04 0.001 0.999
## lactate6.2 4.313e+01 4.134e+04 0.001 0.999
## lactate6.3 -3.402e-06 4.134e+04 0.000 1.000
## lactate6.5 4.313e+01 4.134e+04 0.001 0.999
## lactate6.52 4.313e+01 4.134e+04 0.001 0.999
## lactate6.6 4.313e+01 4.134e+04 0.001 0.999
## lactate6.69 -3.401e-06 4.134e+04 0.000 1.000
## lactate6.8 2.157e+01 2.923e+04 0.001 0.999
## lactate6.83 4.313e+01 4.134e+04 0.001 0.999
## lactate6.86 4.313e+01 4.134e+04 0.001 0.999
## lactate6.9 -3.401e-06 3.580e+04 0.000 1.000
## lactate7.1 4.313e+01 4.134e+04 0.001 0.999
## lactate7.18 4.313e+01 4.134e+04 0.001 0.999
## lactate7.3 4.313e+01 3.580e+04 0.001 0.999
## lactate7.7 4.313e+01 4.134e+04 0.001 0.999
## lactate7.76 4.313e+01 4.134e+04 0.001 0.999
## lactate7.84 4.313e+01 4.134e+04 0.001 0.999
## lactate7.9 4.313e+01 4.134e+04 0.001 0.999
## lactate8 4.313e+01 3.580e+04 0.001 0.999
## lactate8.05 -3.401e-06 4.134e+04 0.000 1.000
## lactate8.1 4.313e+01 4.134e+04 0.001 0.999
## lactate8.56 4.313e+01 4.134e+04 0.001 0.999
## lactate8.6 4.313e+01 4.134e+04 0.001 0.999
## lactate8.67 4.313e+01 4.134e+04 0.001 0.999
## lactate8.8 4.313e+01 4.134e+04 0.001 0.999
## lactate8.98 4.313e+01 4.134e+04 0.001 0.999
## lactate9.01 4.313e+01 4.134e+04 0.001 0.999
## lactate9.1 4.313e+01 4.134e+04 0.001 0.999
## lactate9.32 4.313e+01 4.134e+04 0.001 0.999
## lactate9.7 4.313e+01 4.134e+04 0.001 0.999
## lactate9.75 4.313e+01 4.134e+04 0.001 0.999
## lactate10.2 4.313e+01 3.580e+04 0.001 0.999
## lactate10.5 4.313e+01 4.134e+04 0.001 0.999
## lactate10.6 4.313e+01 4.134e+04 0.001 0.999
## lactate10.9 4.313e+01 3.375e+04 0.001 0.999
## lactate11.45 4.313e+01 4.134e+04 0.001 0.999
## lactate12.2 4.313e+01 4.134e+04 0.001 0.999
## lactate12.3 4.313e+01 4.134e+04 0.001 0.999
## lactate12.8 4.313e+01 4.134e+04 0.001 0.999
## lactate13.03 4.313e+01 4.134e+04 0.001 0.999
## lactate13.2 4.313e+01 4.134e+04 0.001 0.999
## lactate14.1 4.313e+01 4.134e+04 0.001 0.999
## lactate14.2 4.313e+01 4.134e+04 0.001 0.999
## lactate14.3 4.313e+01 4.134e+04 0.001 0.999
## lactate15.4 4.313e+01 4.134e+04 0.001 0.999
## lactate17.5 4.313e+01 4.134e+04 0.001 0.999
## lactate20.82 4.313e+01 4.134e+04 0.001 0.999
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 165.122 on 126 degrees of freedom
## Residual deviance: 28.093 on 27 degrees of freedom
## AIC: 228.09
##
## Number of Fisher Scoring iterations: 20
temp <- glm(tuvong ~ sex + age + hatb + mach + nhietdo + nhiptho + sp02 + lactate + albumin + lar + pct, family="binomial", data=lar6)
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
search <- step(temp)
## Start: AIC=220
## tuvong ~ sex + age + hatb + mach + nhietdo + nhiptho + sp02 +
## lactate + albumin + lar + pct
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Df Deviance AIC
## - lactate 99 106.46 128.46
## - age 1 0.00 218.00
## - albumin 1 0.00 218.00
## - mach 1 0.00 218.00
## - nhietdo 1 0.00 218.00
## - hatb 1 0.00 218.00
## - lar 1 0.00 218.00
## - pct 1 0.00 218.00
## - sex 1 0.00 218.00
## - nhiptho 1 0.00 218.00
## - sp02 1 0.00 218.00
## <none> 0.00 220.00
##
## Step: AIC=128.46
## tuvong ~ sex + age + hatb + mach + nhietdo + nhiptho + sp02 +
## albumin + lar + pct
##
## Df Deviance AIC
## - hatb 1 106.47 126.47
## - sex 1 106.49 126.49
## - nhiptho 1 106.50 126.50
## - sp02 1 106.55 126.55
## - albumin 1 106.78 126.78
## - pct 1 107.01 127.01
## - mach 1 107.16 127.16
## <none> 106.46 128.46
## - nhietdo 1 108.87 128.87
## - age 1 112.53 132.53
## - lar 1 143.91 163.91
##
## Step: AIC=126.47
## tuvong ~ sex + age + mach + nhietdo + nhiptho + sp02 + albumin +
## lar + pct
##
## Df Deviance AIC
## - sex 1 106.50 124.50
## - nhiptho 1 106.52 124.52
## - sp02 1 106.55 124.55
## - albumin 1 106.79 124.79
## - pct 1 107.02 125.02
## - mach 1 107.18 125.18
## <none> 106.47 126.47
## - nhietdo 1 108.88 126.88
## - age 1 112.53 130.53
## - lar 1 144.95 162.95
##
## Step: AIC=124.5
## tuvong ~ age + mach + nhietdo + nhiptho + sp02 + albumin + lar +
## pct
##
## Df Deviance AIC
## - nhiptho 1 106.55 122.55
## - sp02 1 106.60 122.60
## - albumin 1 106.80 122.80
## - pct 1 107.03 123.03
## - mach 1 107.25 123.25
## <none> 106.50 124.50
## - nhietdo 1 108.89 124.89
## - age 1 112.86 128.86
## - lar 1 146.26 162.26
##
## Step: AIC=122.55
## tuvong ~ age + mach + nhietdo + sp02 + albumin + lar + pct
##
## Df Deviance AIC
## - sp02 1 106.66 120.66
## - albumin 1 106.86 120.86
## - pct 1 107.11 121.11
## - mach 1 107.26 121.26
## <none> 106.55 122.55
## - nhietdo 1 108.98 122.98
## - age 1 112.92 126.92
## - lar 1 146.71 160.71
##
## Step: AIC=120.66
## tuvong ~ age + mach + nhietdo + albumin + lar + pct
##
## Df Deviance AIC
## - albumin 1 107.05 119.05
## - pct 1 107.27 119.27
## - mach 1 107.30 119.30
## <none> 106.66 120.66
## - nhietdo 1 109.25 121.25
## - age 1 113.30 125.30
## - lar 1 147.76 159.76
##
## Step: AIC=119.05
## tuvong ~ age + mach + nhietdo + lar + pct
##
## Df Deviance AIC
## - mach 1 107.52 117.52
## - pct 1 107.63 117.63
## <none> 107.05 119.05
## - nhietdo 1 109.81 119.81
## - age 1 113.78 123.78
## - lar 1 150.60 160.60
##
## Step: AIC=117.51
## tuvong ~ age + nhietdo + lar + pct
##
## Df Deviance AIC
## - pct 1 108.18 116.18
## <none> 107.52 117.52
## - nhietdo 1 111.04 119.04
## - age 1 114.67 122.67
## - lar 1 150.62 158.62
##
## Step: AIC=116.18
## tuvong ~ age + nhietdo + lar
##
## Df Deviance AIC
## <none> 108.18 116.18
## - nhietdo 1 112.25 118.25
## - age 1 116.45 122.45
## - lar 1 151.54 157.54
summary(search)
##
## Call:
## glm(formula = tuvong ~ age + nhietdo + lar, family = "binomial",
## data = lar6)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 12.19400 9.03510 1.350 0.17714
## age 0.04613 0.01648 2.799 0.00512 **
## nhietdo -0.46509 0.23897 -1.946 0.05163 .
## lar 1.29603 0.26702 4.854 1.21e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 165.12 on 126 degrees of freedom
## Residual deviance: 108.18 on 123 degrees of freedom
## AIC: 116.18
##
## Number of Fisher Scoring iterations: 6
m2 = glm(tuvong ~ lar + age + nhietdo, family=binomial, data=lar6)
logistic.display(m2)
##
## Logistic regression predicting tuvong
##
## crude OR(95%CI) adj. OR(95%CI) P(Wald's test)
## lar (cont. var.) 3.4 (2.09,5.54) 3.65 (2.17,6.17) < 0.001
##
## age (cont. var.) 1.04 (1.01,1.07) 1.05 (1.01,1.08) 0.005
##
## nhietdo (cont. var.) 0.67 (0.47,0.95) 0.63 (0.39,1) 0.052
##
## P(LR-test)
## lar (cont. var.) < 0.001
##
## age (cont. var.) 0.004
##
## nhietdo (cont. var.) 0.044
##
## Log-likelihood = -54.0899
## No. of observations = 127
## AIC value = 116.1798
summary(m2)
##
## Call:
## glm(formula = tuvong ~ lar + age + nhietdo, family = binomial,
## data = lar6)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 12.19400 9.03510 1.350 0.17714
## lar 1.29603 0.26702 4.854 1.21e-06 ***
## age 0.04613 0.01648 2.799 0.00512 **
## nhietdo -0.46509 0.23897 -1.946 0.05163 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 165.12 on 126 degrees of freedom
## Residual deviance: 108.18 on 123 degrees of freedom
## AIC: 116.18
##
## Number of Fisher Scoring iterations: 6
m3= glm(tuvong ~ lar + age, family=binomial, data=lar6)
logistic.display(m3)
##
## Logistic regression predicting tuvong
##
## crude OR(95%CI) adj. OR(95%CI) P(Wald's test) P(LR-test)
## lar (cont. var.) 3.4 (2.09,5.54) 3.69 (2.19,6.23) < 0.001 < 0.001
##
## age (cont. var.) 1.04 (1.01,1.07) 1.05 (1.02,1.08) 0.003 0.002
##
## Log-likelihood = -56.1248
## No. of observations = 127
## AIC value = 118.2495
summary(m3)
##
## Call:
## glm(formula = tuvong ~ lar + age, family = binomial, data = lar6)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -5.35423 1.34454 -3.982 6.83e-05 ***
## lar 1.30676 0.26654 4.903 9.46e-07 ***
## age 0.04658 0.01586 2.936 0.00332 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 165.12 on 126 degrees of freedom
## Residual deviance: 112.25 on 124 degrees of freedom
## AIC: 118.25
##
## Number of Fisher Scoring iterations: 6
mod1 = glm(tuvong ~ lar, data=lar6)
library(pROC)
lar6$pred1 = predict(mod1, newdata=lar6, type="response")
ROC1 = roc(lar6$tuvong, lar6$pred1)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
auc(ROC1)
## Area under the curve: 0.8253
ci.auc(ROC1)
## 95% CI: 0.7541-0.8966 (DeLong)
plot.roc(ROC1, print.auc=TRUE, auc.polygon=TRUE, grid=c(0.1, 0.2), grid.col=c("green", "red"),
max.auc.polygon=TRUE, auc.polygon.col="lightgrey", print.thres=TRUE)
mod = glm(tuvong ~ lar + age, data=lar6)
library(pROC)
lar6$pred = predict(mod, newdata=lar6, type="response")
ROC = roc(lar6$tuvong, lar6$pred)
## Setting levels: control = 0, case = 1
## Setting direction: controls < cases
auc(ROC)
## Area under the curve: 0.8566
ci.auc(ROC)
## 95% CI: 0.7917-0.9216 (DeLong)
plot.roc(ROC, print.auc=TRUE, auc.polygon=TRUE, grid=c(0.1, 0.2), grid.col=c("green", "red"),
max.auc.polygon=TRUE, auc.polygon.col="lightgrey", print.thres=TRUE)
df <- data.frame(lar6$sex, lar6$age, lar6$hatb, lar6$mach, lar6$nhietdo, lar6$nhiptho, lar6$sp02, lar6$albumin, lar6$lar, lar6$pct, lar6$tuvong)
head(df)
## lar6.sex lar6.age lar6.hatb lar6.mach lar6.nhietdo lar6.nhiptho lar6.sp02
## 1 0 87 60 103 36.8 30 94
## 2 1 70 102 90 38.5 35 90
## 3 1 69 123 62 37.0 20 82
## 4 1 71 163 98 36.0 25 97
## 5 0 66 60 112 36.5 33 85
## 6 1 78 63 130 36.4 32 85
## lar6.albumin lar6.lar lar6.pct lar6.tuvong
## 1 2.15 0.98 3.33 1
## 2 2.05 2.20 2.03 1
## 3 2.94 0.31 5.02 0
## 4 2.50 4.36 100.00 1
## 5 1.73 3.53 1.56 1
## 6 2.80 1.68 17.06 1
attach(df)
names(df)
## [1] "lar6.sex" "lar6.age" "lar6.hatb" "lar6.mach" "lar6.nhietdo"
## [6] "lar6.nhiptho" "lar6.sp02" "lar6.albumin" "lar6.lar" "lar6.pct"
## [11] "lar6.tuvong"
xvars <- df[,1:10]
y <- lar6$tuvong
library(BMA)
## Loading required package: leaps
## Loading required package: robustbase
##
## Attaching package: 'robustbase'
## The following object is masked from 'package:survival':
##
## heart
## Loading required package: inline
## Loading required package: rrcov
## Scalable Robust Estimators with High Breakdown Point (version 1.7-5)
bma.search <- bic.glm(xvars, y, strict=F, OR=20, glm.family="binomial")
summary(bma.search)
##
## Call:
## bic.glm.data.frame(x = xvars, y = y, glm.family = "binomial", strict = F, OR = 20)
##
##
## 18 models were selected
## Best 5 models (cumulative posterior probability = 0.6703 ):
##
## p!=0 EV SD model 1 model 2
## Intercept 100 2.023e+00 10.460886 -5.354e+00 1.219e+01
## lar6.sex.x 4.7 3.551e-03 0.108391 . .
## lar6.age.x 92.7 4.261e-02 0.019626 4.658e-02 4.613e-02
## lar6.hatb.x 4.7 4.158e-05 0.001911 . .
## lar6.mach.x 8.3 -9.065e-04 0.004260 . .
## lar6.nhietdo.x 39.9 -1.853e-01 0.273646 . -4.651e-01
## lar6.nhiptho.x 4.8 2.850e-04 0.005059 . .
## lar6.sp02.x 5.1 -5.451e-04 0.006201 . .
## lar6.albumin.x 5.2 1.069e-02 0.112666 . .
## lar6.lar.x 100.0 1.306e+00 0.269604 1.307e+00 1.296e+00
## lar6.pct.x 7.7 -5.602e-04 0.002815 . .
##
## nVar 2 3
## BIC -4.884e+02 -4.877e+02
## post prob 0.312 0.212
## model 3 model 4 model 5
## Intercept -3.891e+00 -5.034e+00 1.755e+01
## lar6.sex.x . . .
## lar6.age.x 4.396e-02 4.343e-02 .
## lar6.hatb.x . . .
## lar6.mach.x -1.227e-02 . .
## lar6.nhietdo.x . . -5.167e-01
## lar6.nhiptho.x . . .
## lar6.sp02.x . . .
## lar6.albumin.x . . .
## lar6.lar.x 1.329e+00 1.368e+00 1.227e+00
## lar6.pct.x . -7.919e-03 .
##
## nVar 3 3 2
## BIC -4.851e+02 -4.848e+02 -4.842e+02
## post prob 0.058 0.051 0.038
imageplot.bma(bma.search)
Giải thích: Có 3 cách để phân tích tìm ra mô hình tiên lượng tốt nhất trên bệnh nhân nhiễm khuẩn huyết - Phân tích ngược - Phân tích xuôi - Tìm chỉ số AIC
Phân tích ngược là sẽ lấy hết tất cả các biến tiên lượng vào để tìm mối liên hệ với biến phụ thuộc/ Sau đó sẽ đánh giá mô hình nào hay nhất Phân tích xuôi là lấy 1 chỉ số tiên lương chạy trước sau đó bỏ từng biến tiên lượng vào. Hai cách này làm rất lâu. Do đó hiện tại mình sẽ tìm mô hình tốt nhất bằng Bayesian Model Average (BMA) hay hàm step #Hàm step
m1 = glm(tuvong ~ lactate, family=binomial, data=lar6)
library(epiDisplay)
logistic.display(m1)
##
## Logistic regression predicting tuvong
##
## OR(95%CI) P(Wald's test) P(LR-test)
## lactate: ref.=0.9 0.007
## 1.1 1 (0,Inf) 1
## 1.2 1 (0,Inf) 1
## 1.4 1 (0,Inf) 1
## 1.5 1 (0,Inf) 1
## 1.6 2322860230.78 (0,Inf) 0.999
## 1.7 1 (0,Inf) 1
## 1.79 5395697890075397120 (0,Inf) 0.999
## 1.8 1 (0,Inf) 1
## 2 1 (0,Inf) 1
## 2.02 1 (0,Inf) 1
## 2.1 4645720461.57 (0,Inf) 0.999
## 2.2 1 (0,Inf) 1
## 2.3 4645720461.57 (0,Inf) 0.999
## 2.4 1 (0,Inf) 1
## 2.5 1 (0,Inf) 1
## 2.51 1 (0,Inf) 1
## 2.6 5395697927948590080 (0,Inf) 0.999
## 2.68 5395698065841612800 (0,Inf) 0.999
## 2.7 1 (0,Inf) 1
## 2.9 1 (0,Inf) 1
## 3 5395698060265626624 (0,Inf) 0.999
## 3.07 1 (0,Inf) 1
## 3.1 1 (0,Inf) 1
## 3.2 1 (0,Inf) 1
## 3.3 5395697890441723904 (0,Inf) 0.999
## 3.35 5395698060040463360 (0,Inf) 0.999
## 3.4 2322860230.78 (0,Inf) 0.999
## 3.59 5395697927298518016 (0,Inf) 0.999
## 3.6 5395698084420107264 (0,Inf) 0.999
## 3.7 5395697894085093376 (0,Inf) 0.999
## 3.8 1 (0,Inf) 1
## 3.84 5395697890970952704 (0,Inf) 0.999
## 3.85 1 (0,Inf) 1
## 3.88 1 (0,Inf) 1
## 3.9 1 (0,Inf) 1
## 3.99 5.39569793201e+18 (0,Inf) 0.999
## 4 5395697925960803328 (0,Inf) 0.999
## 4.1 4645720461.57 (0,Inf) 0.999
## 4.2 5395697892051069952 (0,Inf) 0.999
## 4.32 5395698054680631296 (0,Inf) 0.999
## 4.5 2322860230.78 (0,Inf) 0.999
## 4.7 5395697920761379840 (0,Inf) 0.999
## 4.82 5395697927666838528 (0,Inf) 0.999
## 4.9 1 (0,Inf) 1
## 5.1 5395698092017350656 (0,Inf) 0.999
## 5.15 1 (0,Inf) 1
## 5.2 5395697892209715200 (0,Inf) 0.999
## 5.23 1 (0,Inf) 1
## 5.43 1 (0,Inf) 1
## 5.67 1 (0,Inf) 1
## 6 2322860230.78 (0,Inf) 0.999
## 6.1 2322860230.78 (0,Inf) 0.999
## 6.12 5395697925426016256 (0,Inf) 0.999
## 6.2 5395698086778476544 (0,Inf) 0.999
## 6.3 1 (0,Inf) 1
## 6.5 5395697928549856256 (0,Inf) 0.999
## 6.52 5395697929102240768 (0,Inf) 0.999
## 6.6 5395697893473091584 (0,Inf) 0.999
## 6.69 1 (0,Inf) 1
## 6.8 2322860230.78 (0,Inf) 0.999
## 6.83 5395697890708676608 (0,Inf) 0.999
## 6.86 5395697892494610432 (0,Inf) 0.999
## 6.9 1 (0,Inf) 1
## 7.1 5395698058852728832 (0,Inf) 0.999
## 7.18 5395697893856440320 (0,Inf) 0.999
## 7.3 5395697925696495616 (0,Inf) 0.999
## 7.7 5395697926181979136 (0,Inf) 0.999
## 7.76 5395697927070556160 (0,Inf) 0.999
## 7.84 5395697893087327232 (0,Inf) 0.999
## 7.9 5395697927023514624 (0,Inf) 0.999
## 8 5395698091665132544 (0,Inf) 0.999
## 8.05 1 (0,Inf) 1
## 8.1 5395697924982705152 (0,Inf) 0.999
## 8.56 5395697924860673024 (0,Inf) 0.999
## 8.6 5395697927556538368 (0,Inf) 0.999
## 8.67 5395698059706379264 (0,Inf) 0.999
## 8.8 5395697889792764928 (0,Inf) 0.999
## 8.98 5395697889967589376 (0,Inf) 0.999
## 9.01 5395698093273519104 (0,Inf) 0.999
## 9.1 5395698070710020096 (0,Inf) 0.999
## 9.32 5395698093565506560 (0,Inf) 0.999
## 9.7 5395697891957868544 (0,Inf) 0.999
## 9.75 5395697924977299456 (0,Inf) 0.999
## 10.2 5395698082254351360 (0,Inf) 0.999
## 10.5 5395697893417270272 (0,Inf) 0.999
## 10.6 5395698089636974592 (0,Inf) 0.999
## 10.9 5395697925550194688 (0,Inf) 0.999
## 11.45 5395697926578095104 (0,Inf) 0.999
## 12.2 5395697923692836864 (0,Inf) 0.999
## 12.3 5395698090118892544 (0,Inf) 0.999
## 12.8 5395698055814307840 (0,Inf) 0.999
## 13.03 5395697928296130560 (0,Inf) 0.999
## 13.2 5395697893200196608 (0,Inf) 0.999
## 14.1 5395697925682079744 (0,Inf) 0.999
## 14.2 5395698093245761536 (0,Inf) 0.999
## 14.3 5395697890597341184 (0,Inf) 0.999
## 15.4 5395697891039731712 (0,Inf) 0.999
## 17.5 5395697892787211264 (0,Inf) 0.999
## 20.82 5395697892481191936 (0,Inf) 0.999
##
## Log-likelihood = -14.0464
## No. of observations = 127
## AIC value = 228.0928
summary(m1)
##
## Call:
## glm(formula = tuvong ~ lactate, family = binomial, data = lar6)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.157e+01 2.923e+04 -0.001 0.999
## lactate1.1 -3.404e-06 4.134e+04 0.000 1.000
## lactate1.2 -3.401e-06 4.134e+04 0.000 1.000
## lactate1.4 -3.401e-06 4.134e+04 0.000 1.000
## lactate1.5 -3.404e-06 4.134e+04 0.000 1.000
## lactate1.6 2.157e+01 2.923e+04 0.001 0.999
## lactate1.7 -3.401e-06 3.375e+04 0.000 1.000
## lactate1.79 4.313e+01 4.134e+04 0.001 0.999
## lactate1.8 -3.401e-06 4.134e+04 0.000 1.000
## lactate2 -3.401e-06 3.580e+04 0.000 1.000
## lactate2.02 -3.401e-06 4.134e+04 0.000 1.000
## lactate2.1 2.226e+01 2.923e+04 0.001 0.999
## lactate2.2 -3.403e-06 3.580e+04 0.000 1.000
## lactate2.3 2.226e+01 2.923e+04 0.001 0.999
## lactate2.4 -3.401e-06 4.134e+04 0.000 1.000
## lactate2.5 -3.401e-06 4.134e+04 0.000 1.000
## lactate2.51 -3.401e-06 4.134e+04 0.000 1.000
## lactate2.6 4.313e+01 4.134e+04 0.001 0.999
## lactate2.68 4.313e+01 4.134e+04 0.001 0.999
## lactate2.7 -3.401e-06 4.134e+04 0.000 1.000
## lactate2.9 -3.401e-06 4.134e+04 0.000 1.000
## lactate3 4.313e+01 4.134e+04 0.001 0.999
## lactate3.07 -3.401e-06 4.134e+04 0.000 1.000
## lactate3.1 -3.401e-06 4.134e+04 0.000 1.000
## lactate3.2 -3.401e-06 4.134e+04 0.000 1.000
## lactate3.3 4.313e+01 3.580e+04 0.001 0.999
## lactate3.35 4.313e+01 4.134e+04 0.001 0.999
## lactate3.4 2.157e+01 2.923e+04 0.001 0.999
## lactate3.59 4.313e+01 4.134e+04 0.001 0.999
## lactate3.6 4.313e+01 3.580e+04 0.001 0.999
## lactate3.7 4.313e+01 3.580e+04 0.001 0.999
## lactate3.8 -3.401e-06 4.134e+04 0.000 1.000
## lactate3.84 4.313e+01 4.134e+04 0.001 0.999
## lactate3.85 -3.401e-06 4.134e+04 0.000 1.000
## lactate3.88 -3.401e-06 4.134e+04 0.000 1.000
## lactate3.9 -3.401e-06 4.134e+04 0.000 1.000
## lactate3.99 4.313e+01 4.134e+04 0.001 0.999
## lactate4 4.313e+01 4.134e+04 0.001 0.999
## lactate4.1 2.226e+01 2.923e+04 0.001 0.999
## lactate4.2 4.313e+01 3.580e+04 0.001 0.999
## lactate4.32 4.313e+01 4.134e+04 0.001 0.999
## lactate4.5 2.157e+01 2.923e+04 0.001 0.999
## lactate4.7 4.313e+01 3.580e+04 0.001 0.999
## lactate4.82 4.313e+01 4.134e+04 0.001 0.999
## lactate4.9 -3.401e-06 4.134e+04 0.000 1.000
## lactate5.1 4.313e+01 4.134e+04 0.001 0.999
## lactate5.15 -3.401e-06 4.134e+04 0.000 1.000
## lactate5.2 4.313e+01 4.134e+04 0.001 0.999
## lactate5.23 -3.402e-06 4.134e+04 0.000 1.000
## lactate5.43 -3.401e-06 4.134e+04 0.000 1.000
## lactate5.67 -3.401e-06 4.134e+04 0.000 1.000
## lactate6 2.157e+01 2.923e+04 0.001 0.999
## lactate6.1 2.157e+01 2.923e+04 0.001 0.999
## lactate6.12 4.313e+01 4.134e+04 0.001 0.999
## lactate6.2 4.313e+01 4.134e+04 0.001 0.999
## lactate6.3 -3.402e-06 4.134e+04 0.000 1.000
## lactate6.5 4.313e+01 4.134e+04 0.001 0.999
## lactate6.52 4.313e+01 4.134e+04 0.001 0.999
## lactate6.6 4.313e+01 4.134e+04 0.001 0.999
## lactate6.69 -3.401e-06 4.134e+04 0.000 1.000
## lactate6.8 2.157e+01 2.923e+04 0.001 0.999
## lactate6.83 4.313e+01 4.134e+04 0.001 0.999
## lactate6.86 4.313e+01 4.134e+04 0.001 0.999
## lactate6.9 -3.401e-06 3.580e+04 0.000 1.000
## lactate7.1 4.313e+01 4.134e+04 0.001 0.999
## lactate7.18 4.313e+01 4.134e+04 0.001 0.999
## lactate7.3 4.313e+01 3.580e+04 0.001 0.999
## lactate7.7 4.313e+01 4.134e+04 0.001 0.999
## lactate7.76 4.313e+01 4.134e+04 0.001 0.999
## lactate7.84 4.313e+01 4.134e+04 0.001 0.999
## lactate7.9 4.313e+01 4.134e+04 0.001 0.999
## lactate8 4.313e+01 3.580e+04 0.001 0.999
## lactate8.05 -3.401e-06 4.134e+04 0.000 1.000
## lactate8.1 4.313e+01 4.134e+04 0.001 0.999
## lactate8.56 4.313e+01 4.134e+04 0.001 0.999
## lactate8.6 4.313e+01 4.134e+04 0.001 0.999
## lactate8.67 4.313e+01 4.134e+04 0.001 0.999
## lactate8.8 4.313e+01 4.134e+04 0.001 0.999
## lactate8.98 4.313e+01 4.134e+04 0.001 0.999
## lactate9.01 4.313e+01 4.134e+04 0.001 0.999
## lactate9.1 4.313e+01 4.134e+04 0.001 0.999
## lactate9.32 4.313e+01 4.134e+04 0.001 0.999
## lactate9.7 4.313e+01 4.134e+04 0.001 0.999
## lactate9.75 4.313e+01 4.134e+04 0.001 0.999
## lactate10.2 4.313e+01 3.580e+04 0.001 0.999
## lactate10.5 4.313e+01 4.134e+04 0.001 0.999
## lactate10.6 4.313e+01 4.134e+04 0.001 0.999
## lactate10.9 4.313e+01 3.375e+04 0.001 0.999
## lactate11.45 4.313e+01 4.134e+04 0.001 0.999
## lactate12.2 4.313e+01 4.134e+04 0.001 0.999
## lactate12.3 4.313e+01 4.134e+04 0.001 0.999
## lactate12.8 4.313e+01 4.134e+04 0.001 0.999
## lactate13.03 4.313e+01 4.134e+04 0.001 0.999
## lactate13.2 4.313e+01 4.134e+04 0.001 0.999
## lactate14.1 4.313e+01 4.134e+04 0.001 0.999
## lactate14.2 4.313e+01 4.134e+04 0.001 0.999
## lactate14.3 4.313e+01 4.134e+04 0.001 0.999
## lactate15.4 4.313e+01 4.134e+04 0.001 0.999
## lactate17.5 4.313e+01 4.134e+04 0.001 0.999
## lactate20.82 4.313e+01 4.134e+04 0.001 0.999
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 165.122 on 126 degrees of freedom
## Residual deviance: 28.093 on 27 degrees of freedom
## AIC: 228.09
##
## Number of Fisher Scoring iterations: 20
temp <- glm(tuvong ~ sex + age + hatb + mach + nhietdo + nhiptho + sp02 + lactate + albumin + lar + pct, family="binomial", data=lar6)
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
search <- step(temp)
## Start: AIC=220
## tuvong ~ sex + age + hatb + mach + nhietdo + nhiptho + sp02 +
## lactate + albumin + lar + pct
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
## Df Deviance AIC
## - lactate 99 106.46 128.46
## - age 1 0.00 218.00
## - albumin 1 0.00 218.00
## - mach 1 0.00 218.00
## - nhietdo 1 0.00 218.00
## - hatb 1 0.00 218.00
## - lar 1 0.00 218.00
## - pct 1 0.00 218.00
## - sex 1 0.00 218.00
## - nhiptho 1 0.00 218.00
## - sp02 1 0.00 218.00
## <none> 0.00 220.00
##
## Step: AIC=128.46
## tuvong ~ sex + age + hatb + mach + nhietdo + nhiptho + sp02 +
## albumin + lar + pct
##
## Df Deviance AIC
## - hatb 1 106.47 126.47
## - sex 1 106.49 126.49
## - nhiptho 1 106.50 126.50
## - sp02 1 106.55 126.55
## - albumin 1 106.78 126.78
## - pct 1 107.01 127.01
## - mach 1 107.16 127.16
## <none> 106.46 128.46
## - nhietdo 1 108.87 128.87
## - age 1 112.53 132.53
## - lar 1 143.91 163.91
##
## Step: AIC=126.47
## tuvong ~ sex + age + mach + nhietdo + nhiptho + sp02 + albumin +
## lar + pct
##
## Df Deviance AIC
## - sex 1 106.50 124.50
## - nhiptho 1 106.52 124.52
## - sp02 1 106.55 124.55
## - albumin 1 106.79 124.79
## - pct 1 107.02 125.02
## - mach 1 107.18 125.18
## <none> 106.47 126.47
## - nhietdo 1 108.88 126.88
## - age 1 112.53 130.53
## - lar 1 144.95 162.95
##
## Step: AIC=124.5
## tuvong ~ age + mach + nhietdo + nhiptho + sp02 + albumin + lar +
## pct
##
## Df Deviance AIC
## - nhiptho 1 106.55 122.55
## - sp02 1 106.60 122.60
## - albumin 1 106.80 122.80
## - pct 1 107.03 123.03
## - mach 1 107.25 123.25
## <none> 106.50 124.50
## - nhietdo 1 108.89 124.89
## - age 1 112.86 128.86
## - lar 1 146.26 162.26
##
## Step: AIC=122.55
## tuvong ~ age + mach + nhietdo + sp02 + albumin + lar + pct
##
## Df Deviance AIC
## - sp02 1 106.66 120.66
## - albumin 1 106.86 120.86
## - pct 1 107.11 121.11
## - mach 1 107.26 121.26
## <none> 106.55 122.55
## - nhietdo 1 108.98 122.98
## - age 1 112.92 126.92
## - lar 1 146.71 160.71
##
## Step: AIC=120.66
## tuvong ~ age + mach + nhietdo + albumin + lar + pct
##
## Df Deviance AIC
## - albumin 1 107.05 119.05
## - pct 1 107.27 119.27
## - mach 1 107.30 119.30
## <none> 106.66 120.66
## - nhietdo 1 109.25 121.25
## - age 1 113.30 125.30
## - lar 1 147.76 159.76
##
## Step: AIC=119.05
## tuvong ~ age + mach + nhietdo + lar + pct
##
## Df Deviance AIC
## - mach 1 107.52 117.52
## - pct 1 107.63 117.63
## <none> 107.05 119.05
## - nhietdo 1 109.81 119.81
## - age 1 113.78 123.78
## - lar 1 150.60 160.60
##
## Step: AIC=117.51
## tuvong ~ age + nhietdo + lar + pct
##
## Df Deviance AIC
## - pct 1 108.18 116.18
## <none> 107.52 117.52
## - nhietdo 1 111.04 119.04
## - age 1 114.67 122.67
## - lar 1 150.62 158.62
##
## Step: AIC=116.18
## tuvong ~ age + nhietdo + lar
##
## Df Deviance AIC
## <none> 108.18 116.18
## - nhietdo 1 112.25 118.25
## - age 1 116.45 122.45
## - lar 1 151.54 157.54
summary(search)
##
## Call:
## glm(formula = tuvong ~ age + nhietdo + lar, family = "binomial",
## data = lar6)
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 12.19400 9.03510 1.350 0.17714
## age 0.04613 0.01648 2.799 0.00512 **
## nhietdo -0.46509 0.23897 -1.946 0.05163 .
## lar 1.29603 0.26702 4.854 1.21e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 165.12 on 126 degrees of freedom
## Residual deviance: 108.18 on 123 degrees of freedom
## AIC: 116.18
##
## Number of Fisher Scoring iterations: 6
Chọn mô hình nào có AIC thấp nhất các tất cả các biến phải có ý nghĩa thống kế –> Do đó trên hình trên cho chúng ta thấy khi phối hợp Lar và tuổi có AUC cao #Hàm BMA
df <- data.frame(lar6$sex, lar6$age, lar6$hatb, lar6$mach, lar6$nhietdo, lar6$nhiptho, lar6$sp02, lar6$albumin, lar6$lar, lar6$pct, lar6$tuvong)
head(df)
## lar6.sex lar6.age lar6.hatb lar6.mach lar6.nhietdo lar6.nhiptho lar6.sp02
## 1 0 87 60 103 36.8 30 94
## 2 1 70 102 90 38.5 35 90
## 3 1 69 123 62 37.0 20 82
## 4 1 71 163 98 36.0 25 97
## 5 0 66 60 112 36.5 33 85
## 6 1 78 63 130 36.4 32 85
## lar6.albumin lar6.lar lar6.pct lar6.tuvong
## 1 2.15 0.98 3.33 1
## 2 2.05 2.20 2.03 1
## 3 2.94 0.31 5.02 0
## 4 2.50 4.36 100.00 1
## 5 1.73 3.53 1.56 1
## 6 2.80 1.68 17.06 1
attach(df)
## The following objects are masked from df (pos = 8):
##
## lar6.age, lar6.albumin, lar6.hatb, lar6.lar, lar6.mach,
## lar6.nhietdo, lar6.nhiptho, lar6.pct, lar6.sex, lar6.sp02,
## lar6.tuvong
names(df)
## [1] "lar6.sex" "lar6.age" "lar6.hatb" "lar6.mach" "lar6.nhietdo"
## [6] "lar6.nhiptho" "lar6.sp02" "lar6.albumin" "lar6.lar" "lar6.pct"
## [11] "lar6.tuvong"
xvars <- df[,1:10]
y <- lar6$tuvong
library(BMA)
bma.search <- bic.glm(xvars, y, strict=F, OR=20, glm.family="binomial")
summary(bma.search)
##
## Call:
## bic.glm.data.frame(x = xvars, y = y, glm.family = "binomial", strict = F, OR = 20)
##
##
## 18 models were selected
## Best 5 models (cumulative posterior probability = 0.6703 ):
##
## p!=0 EV SD model 1 model 2
## Intercept 100 2.023e+00 10.460886 -5.354e+00 1.219e+01
## lar6.sex.x 4.7 3.551e-03 0.108391 . .
## lar6.age.x 92.7 4.261e-02 0.019626 4.658e-02 4.613e-02
## lar6.hatb.x 4.7 4.158e-05 0.001911 . .
## lar6.mach.x 8.3 -9.065e-04 0.004260 . .
## lar6.nhietdo.x 39.9 -1.853e-01 0.273646 . -4.651e-01
## lar6.nhiptho.x 4.8 2.850e-04 0.005059 . .
## lar6.sp02.x 5.1 -5.451e-04 0.006201 . .
## lar6.albumin.x 5.2 1.069e-02 0.112666 . .
## lar6.lar.x 100.0 1.306e+00 0.269604 1.307e+00 1.296e+00
## lar6.pct.x 7.7 -5.602e-04 0.002815 . .
##
## nVar 2 3
## BIC -4.884e+02 -4.877e+02
## post prob 0.312 0.212
## model 3 model 4 model 5
## Intercept -3.891e+00 -5.034e+00 1.755e+01
## lar6.sex.x . . .
## lar6.age.x 4.396e-02 4.343e-02 .
## lar6.hatb.x . . .
## lar6.mach.x -1.227e-02 . .
## lar6.nhietdo.x . . -5.167e-01
## lar6.nhiptho.x . . .
## lar6.sp02.x . . .
## lar6.albumin.x . . .
## lar6.lar.x 1.329e+00 1.368e+00 1.227e+00
## lar6.pct.x . -7.919e-03 .
##
## nVar 3 3 2
## BIC -4.851e+02 -4.848e+02 -4.842e+02
## post prob 0.058 0.051 0.038
imageplot.bma(bma.search)
Kết luận hiện tại: Lactate/alumin có gía trị tiên lượng tốt hơn lactate, albumin đơn độc Và khi phân tích hồi quy đa biến logistic ta thấy mô hình tốt nhất là LAR với độ tuổi