R-users
E-mail: r-help@r-project.org
Hi! R-users.
http://finzi.psych.upenn.edu/R/library/mvpart/html/xpred.rpart.html
says:
data(car.test.frame)
fit <- rpart(Mileage ~ Weight, car.test.frame)
xmat <- xpred.rpart(fit)
xerr <- (xmat - car.test.frame$Mileage)^2
apply(xerr, 2, sum) # cross-validated error estimate
# approx same result as rel. error from printcp(fit)
apply(xerr, 2, sum)/var(car.test.frame$Mileage)
printcp(fit)
I carried out the R object:
function ()
{
#
library(mvpart)
xx1 <- c(1,2,3,4,5,6,7,8,9,10)
xx2 <- c(5,2,1,4,3,6,2,8,2,2)
xx3 <- c(9,8,3,7,2,3,1,9,1,6)
yy <- c(1,8,2,7,4,3,1,2,2,8)
data1 <- data.frame(x1=xx1, x2=xx2, x3=xx3, y=yy)
set.seed(345)
rpart.out1 <- rpart(y~., data=data1)
re1 <- rpart.out1$cptable[,"rel error"]
print("re1")
print(re1)
xmat <- xpred.rpart(rpart.out1)
xerr <- (xmat - yy)^2
re2 <- apply(xerr, 2, sum)/var(yy)
print("re2")
print(re2)
}
The result is:
"re1"
1 2 3
1.00000000 0.08891993 0.03258845
"re2"
0.72777002 0.16019126 0.02373425
11.11111 14.32524 13.12762
Apparently, "re1" is not close to "re2". I would like to
know why.
--
***** r.otasuke@gmail.com *****
http://cse.naro.affrc.go.jp/takezawa/intro.html
[[alternative HTML version deleted]]