Tree-based method는 종속변수가 continuous variable의 경우에도 사용할수 있다. 예를 들어 mtcars 데이타를 이용하여 설명하고자 한다. mtcars 데이타는 1974년 US motor magazine에 실린 32종의 자동차의 배기량에 대한 데이타이다.
tail(mtcars)
mpg cyl disp hp drat wt qsec vs am gear carb
Porsche 914-2 26.0 4 120.3 91 4.43 2.140 16.7 0 1 5 2
Lotus Europa 30.4 4 95.1 113 3.77 1.513 16.9 1 1 5 2
Ford Pantera L 15.8 8 351.0 264 4.22 3.170 14.5 0 1 5 4
Ferrari Dino 19.7 6 145.0 175 3.62 2.770 15.5 0 1 5 6
Maserati Bora 15.0 8 301.0 335 3.54 3.570 14.6 0 1 5 8
Volvo 142E 21.4 4 121.0 109 4.11 2.780 18.6 1 1 4 2
str(mtcars)
'data.frame': 32 obs. of 11 variables:
$ mpg : num 21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
$ cyl : num 6 6 4 6 8 6 8 4 4 6 ...
$ disp: num 160 160 108 258 360 ...
$ hp : num 110 110 93 110 175 105 245 62 95 123 ...
$ drat: num 3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
$ wt : num 2.62 2.88 2.32 3.21 3.44 ...
$ qsec: num 16.5 17 18.6 19.4 17 ...
$ vs : num 0 0 1 1 0 1 0 1 1 1 ...
$ am : num 1 1 1 0 0 0 0 0 0 0 ...
$ gear: num 4 4 4 3 3 3 3 4 4 4 ...
$ carb: num 4 4 1 1 2 1 4 2 2 4 ...
이 데이타의 연비(mpg)에 대한 tree-based analysis를 해보면 다음과 같다.
library(party)
cartree=ctree(mpg~.,data=mtcars)
plot(cartree)
연비는 공차중량(wt) 및 배기량(disp)에 따라 달라진다. 이들 변수들의 상관관계를 보기위해 parallel plot을 그려보면 다음과 같다.
library(lattice)
parallelplot(~mtcars[,c(3,4,1,6,3)])
즉 연비는 공차중량 및 배기량과 역상관관계를 보이며(parallel plot에서 최대값과 최소값이 교차함) 공차중량과 배기량은 순의 상관관계를 보인다.
이들 변수들의 r값을 corrplot으로 나타내면 다음과 같다.
library(corrplot)
M=cor(mtcars[,c(3,1,4,6)])
corrplot.mixed(M,lower="color",upper="number")
GBSG2(German Breast cancer Study Group 2) 데이타는 임파절 양성인 유방암 환자 686명 7개의 예후인자에 관한 데이타로 TH.data 패키지에 있다.
data("GBSG2", package = "TH.data")
head(GBSG2)
horTh age menostat tsize tgrade pnodes progrec estrec time cens
1 no 70 Post 21 II 3 48 66 1814 1
2 yes 56 Post 12 II 7 61 77 2018 1
3 yes 58 Post 35 II 9 52 271 712 1
4 yes 59 Post 17 II 4 60 29 1807 1
5 no 73 Post 35 II 1 26 65 772 1
6 no 32 Pre 57 III 24 0 13 448 1
이중 pnodes 변수는 양성인 임파절 수이고 horTh는 호르몬치료로써 no 또는 yes의 두개의 범주를 갖는 factor이다. progrec은 progesterone recptor의 수로 fmol 단위로 되어있다.
library(survival)
stree <- ctree(Surv(time, cens) ~ ., data = GBSG2)
plot(stree)
Schumacher 등은 concored reponse의 recursive partitioning을 이용하여 다음과 같은 논문을 발표하였다. Schumacher M, Holla ̈nder N, Schwarzer G, Sauerbrei W (2001). “Prognostic Factor Studies.” In J Crowley (ed.), Statistics in Oncology, pp. 321–378. Marcel Dekker, New York, Basel.
새로운 환자가 발생했을때 median survival은 tree response로 계산할 수 있다. 다음의 4명의 환자 예를 들면
GBSG2[c(1,2,6,8),c(1,6,7)]
horTh pnodes progrec
1 no 3 48
2 yes 7 61
6 no 24 0
8 no 1 192
1번째 환자는 pnodes는 3이고 hormonal therapy를 받지 않았으므로 Node3에 해당하는 생존을 보이고(중앙값 2093) 2번째 환자는 pnodes는 7이고 progesterone receptor는 61로 Node 7에 해당하는 생존을 보인다(중앙값 1701).
treeresponse(stree, newdata = GBSG2[c(1,2,6,8),])
[[1]]
Call: survfit(formula = y ~ 1, weights = weights)
records n.max n.start events median 0.95LCL 0.95UCL
248 248 248 88 2093 1814 NA
[[2]]
Call: survfit(formula = y ~ 1, weights = weights)
records n.max n.start events median 0.95LCL 0.95UCL
166 166 166 77 1701 1174 2018
[[3]]
Call: survfit(formula = y ~ 1, weights = weights)
records n.max n.start events median 0.95LCL 0.95UCL
144 144 144 103 624 525 797
[[4]]
Call: survfit(formula = y ~ 1, weights = weights)
records n.max n.start events median 0.95LCL 0.95UCL
248 248 248 88 2093 1814 NA