From: o ha wang <wyerliang_at_yahoo.com>

Date: Sun, 24 Feb 2008 13:28:09 -0800 (PST)

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 24 Feb 2008 - 21:31:00 GMT

Date: Sun, 24 Feb 2008 13:28:09 -0800 (PST)

Thanks!

Yes, you were right. I loaded package 'tree'.

I tried 'tree' and 'rpart' respectively, it looks like results for regression tree are same, and very similar for classification tree. (more biref using 'rpart' than using 'tree').

But my problems are still not been solved using rpart.

- how to put number (n, ie. class counts) and probability (yprob) on the plot for classification tree. There are only 0/1 on the plot. n and yprob can be seen using 'myfit' but not on the plot.
- The notation of Numbers are overlapped for regression tree.

please see my rpart code:

library (rpart)

myfit <- rpart (y ~ x1 + x2 + x3 + x4 )
plot (myfit)); text (myfit, all= TRUE, cex=0.5, pretty=0)
myfit

summary(myfit)

thanks, xiao yue

Uwe Ligges <ligges_at_statistik.tu-dortmund.de> wrote:

o ha wang wrote:

> Hi all,

*>
**> Can anyone who is familar with CART tell me what I missed in my tree code?
**>
**> library (MASS)
**> myfit <- tree (y ~ x1 + x2 + x3 + x4 )
*

There is not function tree() in MASS. I guess you have loaded package
"tree"?

Note that the author and maintainer of the tree package suggests to use
package rpart instead.

> # tree.screens () # useless

*> plot(myfit); text (myfit, all= TRUE, cex=0.5, pretty=0)
**> # tile.tree (myfit, fgl$type) # useless
**> # close.screen (all= TRUE) # useless
**>
**>
**> My current tree plot resulted from above code shows as:
**> 1. overlapped #s caused by unsuitable length of branch.
**> 2. no misclassification rates: 'misclass.tree' only brings up the error of ' misclassification error rate is appropriate for factor responses only', but my response y is 0/1 data.
*

If you data is 0/1, you should make it a factor otherwise the cose will assume you want a regression rather than a classification tree.

It indicates which items go into the left branch.

Uwe Ligges

*>
*

> thanks,

*> xiao yue
**>
**>
**> ---------------------------------
**>
**> [[alternative HTML version deleted]]
**>
**> ______________________________________________
**> R-help_at_r-project.org mailing list
**> https://stat.ethz.ch/mailman/listinfo/r-help
**> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
**> and provide commented, minimal, self-contained, reproducible code.
*

[[alternative HTML version deleted]]

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 24 Feb 2008 - 21:31:00 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Sun 24 Feb 2008 - 23:30:16 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*