[R] Problem with party and ordered factors

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Fri Feb 2 20:00:14 CET 2007


> I've got an ordered factor as response. As far as i know i have to use
> scores to be able to use this ordered factor.

If you want to exploit the ordering in the statistical tests (used for
variable selection in CTree), a natural approach is to use a
linear-by-linear test with scores assigned to the ordered levels of your
factor. That's what the example below does.

> But if i do so i get a tree
> which predicts all observations as the first level of my ordered factor.

That is not due to the factor being ordered. It results simply from the
fact that more than half of the observations have "Never" in the variable

> There i got the same problem. I execute the following code:
> > data("mammoexp", package = "party")
> > mtree <- ctree(ME ~ ., data = mammoexp, scores = list(ME = 1:3, SYMPT =
> 1:4, DECT = 1:3))
> > plot(mtree)

If you look at this picture, you can see that majority voting in each node
will result in the prediction "Never".

> So now i'm stuck. Am i doing anything wrong?

If you want to see how the distribution in each node changes, you can
look at

> I'm using R 2.4.1 and all packages are uptodate.

Not anymore, I just uploaded a new "party" version to CRAN ;-))

Best wishes,

More information about the R-help mailing list