Chapter 7: Scales of density estimates. Code

We consider the density shown in 2D three-modal density and generate a sample of size 200 from this density.

dendat<-sim.data(n=200,seed=5,type="mulmod")

We visualize a scale of kernel estimates. We calculate the sequence of estimates using the function ``lstseq.kern''.

h1<-0.85                    # the lowest h-value
h2<-2.3                     # the upper h-value
lkm<-100                    # number of estimates
base<-10                    # logarithmic spacing
hseq<-hgrid(h1,h2,lkm,base) # vector of h values
N<-c(30,30)                 # the size of the grid

estiseq<-lstseq.kern(dendat,hseq,N,kernel="epane",lstree=TRUE) 

Mode graph

We make a mode graph from the sequence of kernel estimates.

mt<-modegraph(estiseq,hseq)
plotmodet(mt,coordi=1)  
plotmodet(mt,coordi=2)  

Branching map

We make a map of branches from the sequence of kernel estimates.

bm<-branchmap(estiseq)
plotbranchmap(bm)

Scale and shape table

We plot the scale and shape visualization table.

scaletable(estiseq,shift=0.1,ptext=0.001,ptextst=0.3,
           bm=bm,levnum=NULL)