|
|
Multivariate adaptive histogramsPackage "delt" implements methods for estimating multivariate densities. The methods include multivariate adaptive histograms (greedy histograms and CART-histograms), bootstrap aggregation of adaptive histograms, and stagewise minimization estimators. Package "delt" is an R package. R is a language and environment for statistical computing and graphics which can be downloaded from R archive network . Package "delt" depends on package "denpro". The density estimates of package "delt" may be visualized using the visualization tools of package "denpro". See the page for denpro . The packages are designed by Jussi Klemelä. I am grateful for bug reports. ContentsIntroduction:Multivariate adaptive histograms are histograms with data-dependent partitions. These estimates are formed by minimizing a (complexity penalized) likelihood criterion or an L2 error criterion. Greedy histograms are constructed by applying a greedy optimization to find the partition of the histogram. CART-histogram are constructed by applying a greedy optimization followed by a complexity penalized pruning. A bootstrap aggregation of adaptive histograms is constructed by generating bootstrap samples to make several adaptive histograms and then taking an average of them. A stagewise minimization estimator is a convex combination of greedy histograms. Literature:Stagewise minimization is described in "Density estimation with stagewise optimization of the empirical risk" . Installation instructions:The programs are provided as an R-package.
Documentation:Below is a listing of the functions, that are included in the package. Greedy histograms
In R use the command help(func) to get online manual for "func". Tutorial:library(delt) # load the library Short tutorialGenerate the datadendat<-sim.data(n=500,seed=5,type="mulmodII")Calculate the estimates eva<-eval.greedy(dendat,leaf=16) eva<-eval.cart(dendat,leaf=16) eva<-eval.bagg(dendat,B=3,leaf=12,prune="on") eva<-eval.stage(dendat,leaf=10,M=3)Draw the estimates lst<-leafsfirst(eva) plotvolu(lst) dp<-draw.pcf(eva,pnum=c(60,60)) persp(dp$x,dp$y,dp$z,theta=-20,phi=30) CART-histogramsEstimation of a mixture of 2 dimensional Gaussians# generate data dendat<-sim.data(n=400,noisedim=0,seed=11,type="fssk") # estimate eva<-eval.cart(dendat,leaf=15) # we get the same estimate also with the commands bt<-densplit(dendat) treeseq<-prune(bt) treeseq$leafs eva<-eval.pick(treeseq,leaf=15) # plot the estimate dp<-draw.pcf(eva,pnum=c(80,80),corona=2) persp(dp$x,dp$y,dp$z,ticktype="detailed",xlab="x",ylab="y",zlab="", phi=25,theta=-50) # level set trees lst<-leafsfirst(eva) plotvolu(lst) plotbary(lst,coordi=1) # binary tree plots lr<-lefrig2par(eva) plottree(lr,modelabel=F) mb<-makebina(eva) library(tree) plot.tree(mb) library(maptree) draw.tree(mb) Projection pursuit example# generate data dendat<-sim.data(n=225,noisedim=3,seed=11,type="fssk") # grow tree bt<-densplit(dendat,minobs=5) treeseq<-prune(bt) treeseq$leafs leafnum<-19 eva<-eval.pick(treeseq,leafnum) # level set trees lst<-leafsfirst(eva) plotvolu(lst) plotbary(lst,coordi=4,modlabret=TRUE) # slices sl<-slicing(eva,c(0,0,0),d1=1,d2=2) dp<-draw.pcf(sl,pnum=c(60,60)) persp(dp$x,dp$y,dp$z,theta=-50,phi=25, xlab="x",ylab="y",zlab="",ticktype="detailed") Bootstrap aggregationEstimation of a mixture of 2 dimensional Gaussians
# generate data
dendat<-sim.data(n=400,noisedim=0,seed=11,type="fssk")
# estimate the density
seed<-1
seedf<-10
sample="worpl"
prune="on"
B<-5
leaf<-20
eva<-eval.bagg(dendat,B=B,leaf=leaf,
seed=seed,seedf=seedf,sample=sample,prune=prune)
# level set trees
lst<-leafsfirst(eva)
td<-treedisc(lst,eva,ngrid=50)
plotvolu(td)
plotbary(td,coordi=1,modlabret=TRUE)
Projection pursuit example
#generate data
dendat<-sim.data(n=400,noisedim=3,seed=11,type="fssk")
# estimate the density
seed<-1
seedf<-10
sample="baggworpl"
prune="on"
B<-5
leaf<-20
eva<-eval.bagg(dendat,B=B,leaf=leaf,
seed=seed,seedf=seedf,sample=sample,prune=prune)
# level set trees
lst<-leafsfirst(eva)
td<-treedisc(lst,eva,ngrid=50)
plotvolu(td)
plotvolu(td,xlim=c(100000,250000))
plotbary(td,coordi=1,modlabret=TRUE)
# slices
sl<-slicing(eva,c(0,0,0),d1=1,d2=2)
dp<-draw.pcf(sl,pnum=c(60,60))
persp(dp$x,dp$y,dp$z,theta=-50,phi=25,
xlab="x",ylab="y",zlab="",ticktype="detailed")
Data structures of the packageSee the page for denpro for the definition of a piecewise constant function and for the definition of an evaluation tree. |