; load library xclust and plot
library("xclust")
library("plot")
; set random seed
randomize(1)
; read swiss banknote data
dendat=read("bank2")
; select the last three variables
dendat=dendat[,4:6]
; choose 9 bins in each dimension
binlkm=9
; compute density estimate
regdat=dentoreg(dendat,binlkm)
; compute CART and tree
type=#(1,1,1)
opt=cartsplitopt("minsize",80,"mindev",0,"mincut",1)
tr=cartsplit(regdat.ind,regdat.dep,type,opt)
; compute cuts and show with colored datapoints
g=cartregr(tr, dendat, "node")
{gcat,gind}=groupcol(g, rows(g))
setmaskp(dendat, gind)
plotcart2(dendat, tr)