Đánh giá Relative Importance của các biến số trong mô hình (outcome là biến nhị phân). Kỹ thuật này sử dụng hàm varImp {caret}.

head (d)
##   id fu.days                   status          drug   age    sex ascites
## 1  1     400                    death penicillamine 21464 female       1
## 2  2    4500                 censored penicillamine 20617 female       0
## 3  3    1012                    death penicillamine 25594   male       0
## 4  4    1925                    death penicillamine 19994 female       0
## 5  5    1504 censored due to liver tx       placebo 13918 female       0
## 6  6    2503                    death       placebo 24201 female       0
##   hepatom spiders edema bili chol albumin copper alk.phos   sgot trig
## 1       1       1   1.0 14.5  261    2.60    156   1718.0 137.95  172
## 2       1       1   0.0  1.1  302    4.14     54   7394.8 113.52   88
## 3       0       0   0.5  1.4  176    3.48    210    516.0  96.10   55
## 4       1       1   0.5  1.8  244    2.54     64   6121.8  60.63   92
## 5       1       1   0.0  3.4  279    3.53    143    671.0 113.15   72
## 6       1       0   0.0  0.8  248    3.98     50    944.0  93.00   63
##   platelet protime stage
## 1      190    12.2     4
## 2      221    10.6     3
## 3      151    12.0     4
## 4      183    10.3     4
## 5      136    10.9     3
## 6       NA    11.0     3
library (caret)
d$outcome [d$status=='death']=1
d$outcome [d$status!='death']=0
d= na.omit (d)
attach(d)

mod_fit= train(outcome ~ drug + age + sex + ascites + bili + chol + albumin, data=d, method="glm", family="binomial")
varImp(mod_fit)
## glm variable importance
## 
##             Overall
## bili        100.000
## age          70.557
## sexmale      45.645
## ascites      40.792
## albumin      32.698
## drugplacebo   4.455
## chol          0.000