Library: | smoother |
See also: | denest denrotp |
Quantlet: | denestp | |
Description: | estimates a p-dimensional density by kernel density estimation. The computation uses WARPing. |
Usage: | fh = denestp(x {,h {,K} {,d} }) | |
Input: | ||
x | n x p matrix of user-defined data | |
h | optional, scalar or p x 1 vector, representing the bandwidth. If not given, the rule of thumb bandwidth computed by denrotp is used (Scott's rule of thumb). | |
K | optional, string, kernel function on [-1,1]^p. If not given, the product Quartic kernel "qua" is used. | |
d | optional, scalar, discretization binwidth. d[i] must be smaller than h[i]. If not given, the minimum of h/3 and (max(x)-min(x))'/r, with r=100 for p=1 and r=(1000^(1/p)) for p>1 is used. | |
Output: | ||
fh | m x (p+1) matrix, the first p columns constitute a grid and the last column contains the density estimate on that grid. |
library("smoother") library("plot") ; x = read("geyser") ; read data fh = denestp(x) ; estimate density ; fh = setmask(fh,"surface") plot(fh) ; graph density estimate setgopt(plotdisplay,1,1,"title","ROTATE!")
The kernel density estimate for the Geyser data is computed using the Quartic kernel and bandwidth according to Scott's rule of thumb (default). The display shows the surface of the resulting function.
library("smoother") library("plot") ; x = read("bank2") ; read data x = x[,4:6] ; columns 4 to 6 d =(max(x)-min(x))'./7 ; large binwidth! fh = denestp(x,1.5,"qua",d) ; estimate density ; c =(max(fh[,4])-min(fh[,4])).*(1:4)./5 ; levels cfh= grcontour3(fh,c,1:4) ; contours plot(cfh) ; graph contours setgopt(plotdisplay,1,1,"title","ROTATE!")
The kernel density estimate for the last three variables of the Swiss banknote data is computed using the Quartic kernel and bandwidth h=1.5. The display shows a contour plot of the resulting function.