Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: smoother
See also: denbwcrit denbbwcrit denbwsel denrot denxest Rdenxest

Quantlet: denxbwcrit
Description: an exact variant of denbwcrit. All kernel estimates of the integrated squared densities or density derivatives are computed exactly using Rdenxest.


Usage: {hopt, ch} = denbwcrit(crit, x ,h {,K})
crit string, criterion for bandwidth selection: "lscv" = Least Squares Cross Validation, "bcv" = Biased Cross Validation, "scv" = Smoothed Cross Validation, "jmp" = Jones, Marron and Park Cross Validation, "pm" = Park and Marron Plug-in, "sj" = Sheather and Jones Plug-in.
x n x 1 vector, the data
h p x 1 vector, bandwidth grid
K optional string, determining the kernel function which is used; default = "gau".
hopt scalar, optimal bandwidth. (If negative in case of "pm" or "sj", denbwcrit needs to be run again with different h range.)
ch p x 2 vector, the criterion function for h values.


n = 500
example = "Marron_Wand_7"
h = grid(0.01, 0.02, 25) ; bandwidth grid
xgrid = grid(-3.1, 0.05, 125) ; appropriate for MW examples
; generate variates
{w, mu, sigma} = normalmixselect(example)
x = normalmix(n, w, mu, sigma)
; find bandwidths
{hopt, ch} = denxbwcrit("sj", x, h)
hrot = denrot(x, "gau")
; compute density estimates
fh1 = denxest(x, hrot, "gau", xgrid)
fh2 = denxest(x, hopt, "gau", xgrid)
fx = normalmixdens(xgrid, w, mu, sigma)
; plotting
disp = createdisplay(2,2)
p1 = setmask(ch, "line", "green")
p2 = setmask(fx, "line", "thin", "red")
p3 = setmask(fh1, "line", "blue")
p4 = setmask(fh2, "line", "blue")
show(disp, 1, 2, p1, gryline(0, h))
show(disp, 1, 1, p2)
show(disp, 2, 1, p2, p3)
show(disp, 2, 2, p2, p4)
setgopt(disp,1,1,"title",string("Example: %s",example))
setgopt(disp,1,2,"title","SJ-criterion function")
setgopt(disp,2,1,"title",string("KDE with h_NR = %f", hrot))
setgopt(disp,2,2,"title",string("KDE with h_SJ = %f", hopt))

Shows a graphic with four windows representing: a bimodal
normal mixture density, the criterion function of the
Sheather-and-Jones bandwidth selector, a KDE using
Silverman's normal reference bandwidth, and a KDE
using the optimal Sheather-and-Jones one.

Contents of _tmp
[1,]  0.19536  0.48772

Author: J.-U. Scheer, 20020915 license MD*Tech
(C) MD*TECH Method and Data Technologies, 05.02.2006