Using the biofam dataset
library(TraMineR)
data(biofam)
lab <- c("P","L","M","LM","C","LC","LMC","D")
biofam.seq <- seqdef(biofam[,10:25], states=lab)
head(biofam.seq)
Sequence
1167 P-P-P-P-P-P-P-P-P-LM-LMC-LMC-LMC-LMC-LMC-LMC
514 P-L-L-L-L-L-L-L-L-L-L-LM-LMC-LMC-LMC-LMC
1013 P-P-P-P-P-P-P-L-L-L-L-L-LM-LMC-LMC-LMC
275 P-P-P-P-P-L-L-L-L-L-L-L-L-L-L-L
2580 P-P-P-P-P-L-L-L-L-L-L-L-L-LMC-LMC-LMC
773 P-P-P-P-P-P-P-P-P-P-P-P-P-P-P-P
I can fit and display a regression tree:
seqt <- seqtree(biofam.seq~sex + birthyr, data=biofam)
seqtreedisplay(seqt, type="I", border=NA, withlegend= TRUE, legend.fontsize=2, legendtext = "Biofam Regression Tree")
Then I can identify the leaf memberships:
seqt$fitted[,1]
This, however, is where I get confused. How do I know which leaf number corresponds to which leaf in the plot? The graph does not seem to display it, and running print(seqt)
does not seem to give leaf numbers either.
What I would like to achieve is to separate out the sequences in each leaf, so that I can run descriptives on each leaf separately. How can I accomplish this?