Library: | smoother |
See also: | denest |
Macro: | 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, the data. | |
h | scalar or p x 1 vector, bandwidth. If not given, the rule of thumb bandwidth computed by denrotp is used (Scott's rule of thumb). | |
K | string, kernel function on [-1,1]^p. If not given, the product Quartic kernel "qua" is used. | |
Output: | ||
d | ||
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.dat") ; 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.
Library: | smoother |
See also: | denest |