a*********n 发帖数: 1331 | | a**j 发帖数: 60 | 2
Using R:
#dendogram for unsplitted efron2004 data set
install.packages("care")
library("care")
install.packages("rpart")
library("rpart")
install.packages("partykit")
library("partykit")
data(efron2004)
attach(efron2004)
efron2004
efron2004_rpart<-rpart(y~x[,1]+x[,2]+x[,3]+x[,4]+x[,5]+x[,6]+x[,7]+x[,8]+x[,
9]+x[,10], data=efron2004, control=rpart.control(numsplit=10))
plot(as.party(efron2004_rpart),main = "Dendogram of Y~ Xis for Efron data
sets", font.main = 4)
#dendograms for splitted efron2004 data set based on y< or >= mean(y)
x<-efron2004$x[,1:10]
y<-efron2004$y[,1]
new<-cbind(x,y)
xs<-subset(new, new[,11]
xl<-subset(new, new[,11]>=median(new[,11]))
xs_rpart<-rpart(xs[,11]~xs[,1]+xs[,2]+xs[,3]+xs[,4]+xs[,5]+xs[,6]+xs[,7]+xs[
,8]+xs[,9]+xs[,10], control=rpart.control(numsplit=10))
xl_rpart<-rpart(xl[,11]~xl[,1]+xl[,2]+xl[,3]+xl[,4]+xl[,5]+xl[,6]+xl[,7]+xl[
,8]+xl[,9]+xl[,10], control=rpart.control(numsplit=10))
plot(as.party(xs_rpart), main = "Dendogram of Y~ X for Y
sets", font.main = 1)
plot(as.party(xl_rpart), main = "Dendogram of Y~ X for Y>=median(y) Efron
data sets", font.main = 1)
ycatg_rpart<-rpart(ycatg~x[,1]+x[,2]+x[,3]+x[,4]+x[,5]+x[,6]+x[,7]+x[,8]+x[,
9]+x[,10], data=efron2004, control=rpart.control(numsplit=10))
plot(as.party(ycatg_rpart),main = "Dendogram of Y~ Xis for Efron data sets",
font.main = 4)
【在 a*********n 的大作中提到】 : 求指点。 : 有tutorial吗?
| a**j 发帖数: 60 | 3
【在 a*********n 的大作中提到】 : 求指点。 : 有tutorial吗?
| a*********n 发帖数: 1331 | 4 谢谢。 接包子
【在 a**j 的大作中提到】
| a**j 发帖数: 60 | |
|