Displaying 1 result from an estimated 1 matches for "hcrit".
Did you mean:
scrit
2003 Jul 17
0
Silverman modality test
...returns how many modes there are in the kernel density estimate of
# vector x, with window width h.
{
modes <- density (x, bw=h)
modes <- diff (diff (modes$y) / abs (diff (modes$y)))
modes <- rep(1, length(modes))[modes==-2]
modes <- sum (modes)
return (modes)
}
hcrit <- function (x, n, e=.0001)
# Returns the minimal window width such that the kernel density estimate
# of x has n modes.
{
minw <- min (abs (diff (x)))
maxw <- (max (x) - min (x))/2
winN <- maxw
winN1 <- minw
while (abs(winN-winN1)>e)
{
modes <- nbmodes (x...