Library: | xclust |
See also: | dentoreg cartsplit cartsplitopt cartcv leafnum maketr pred prederr prune prunecv pruneseq prunetot ssr volumes |
Quantlet: | denvalues | |
Description: | given a binary tree produced by cartsplit, normalizes the mean values of the leaves so that the function represented by the binary tree integrates to one. |
Usage: | y = denvalues (tr, dendat) | |
Input: | ||
tr | list of vectors, data structure which represents a binary tree, produced by cartsplit. It contains the vectors tr.val, tr.vec, tr.mean, tr.ssr, tr.nelem, tr.endpoint. See cartsplit for detailed description. | |
dendat | n x p matrix, data matrix of i.i.d. observations. Data with which the density tree was estimated. | |
Output: | ||
y | k x 1 vector, it has as many elements k as there are elements in the vectors forming the tree tr. In the positions which correspond to the leaf nodes there are normalised values of vector tr.mean. Values are normalised in such a way that the function represented by the binary tree integrates to one. In nonterminal positions, the values are +Inf. |
; loads the library xclust library("xclust") ; generates the density data randomize(1) dendat=uniform(10)~(uniform(10)+1) ; transforms the density data to a regression data regdat=dentoreg(dendat,4) ; estimates the density tree tr=cartsplit(regdat.ind,regdat.dep,#(1,1)) ; normalises the density estimate cval=denvalues(tr,dendat) cval tr.mean=cval
Contents of cval [ 1,] +INF [ 2,] +INF [ 3,] +INF [ 4,] 0.18356 [ 5,] 0.35149 [ 6,] +INF [ 7,] 0.46195 [ 8,] 0.55068 [ 9,] +INF [10,] +INF [11,] +INF [12,] 0.18356 [13,] 0.18356 [14,] +INF [15,] 0.18356 [16,] 0.35149 [17,] +INF [18,] 0.46195 [19,] +INF [20,] 0.18356 [21,] 0.35149