On Tue, 2010-09-07 at 19:26 -0300, Alexandre F. Souza wrote:
> Dear friends,
> 
>      I am sudying R's mvpart package, that implements Multivariate
> Regression Trees, aiming at applying it to a biogeographical dataset of
> tree speces in southern South America.
> 
>    My doubt is how to access plot identities after the tree is produced.
> For us it is rather important, but I could not find them with neither
> 'summary(fit)'[where fit is the object containing the mvpart(...)
> command] nor just 'fit'. This piece of information is likely to be
> somewhere in the package documentation (Package 'mvpart' or ?mvpart),
> but I did not succeed in finding it.

What are "plot identities"?

Just so we are clear; here's the example from ?mvpart

data(spider)
head(spider)
  arct.lute pard.lugu zora.spin pard.nigr pard.pull aulo.albi troc.terr
1         0         2         1         0         0         0         5
2         0         3         1         1         0         0         4
3         0         3         1         0         0         0         4
4         0         2         2         1         0         0         5
5         0         1         1         0         0         0         4
6         0         2         0         0         0         0         5
  alop.cune pard.mont alop.acce alop.fabr arct.peri water sand moss reft twigs
1         0         0         0         0         0     9    0    1    1     9
2         1         0         0         0         0     7    0    3    0     9
3         1         0         0         0         0     8    0    1    0     9
4         1         0         0         0         0     8    0    1    0     9
5         0         0         0         0         0     9    0    1    2     9
6         1         0         0         0         0     8    0    0    2     9
  herbs
1     5
2     2
3     0
4     0
5     5
6     5

So we have samples as rows, species and env data as columns.

Are you asking how to find out which of the samples (1,2,...,n in the
above data) are in which nodes on the final pruned tree? If so, you need
to dig a little in the help. ?mvpart tells us that the object returned
by the function is an object of class "rpart" (Value) and points us
to ?rpart (See Also), which tells us nothing new except for the
reference to ?rpart.object (again in See Also), which describes objects
of class "rpart" and which yields the answer you want.

Following on the above example:
> foo <- mvpart(data.matrix(spider[,1:12]) ~ herbs +reft + moss + sand +
+ twigs + water, spider, xv="p")
> foo
n= 28 

node), split, n, deviance, yval
      * denotes terminal node

1) root 28 1417.9640 1.663690  
  2) herbs< 8.5 20  515.5500 1.054167  
    4) twigs< 3.5 11  194.5455 1.045455 *
    5) twigs>=3.5 9  115.5556 1.064815 *
  3) herbs>=8.5 8  167.0000 3.187500 *

So there are three terminal nodes, with IDs "3", "4", "5". ?rpart.object
tells us that component "where" of the fitted tree contains the node
identifier:

> with(foo, where)
 [1] 4 4 4 4 4 4 5 4 4 5 4 5 5 5 5 5 5 3 3 3 3 3 3 3 3 3 3 3

Is that what you are after?

G

> 
>    Do anyone knows how to solve this?
> 
>    Thank you in advance and all the best,
> 
>    Alexandre
> 
> 
> Dr. Alexandre F. Souza 
> Programa de Pós-Graduação em Biologia: Diversidade e Manejo da Vida
> Silvestre
> Universidade do Vale do Rio dos Sinos (UNISINOS)
> Av. UNISINOS 950 - C.P. 275, São Leopoldo 93022-000, RS  - Brasil
> Telefone: (051)3590-8477 ramal 1263
> Skype: alexfadigas
> [email protected]
> http://www.unisinos.br/laboratorios/lecopop
> 

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

Reply via email to