rodeo.local.bw1: A KDE bw selection for one dim

Description Usage Arguments Value Examples

View source: R/my_kde.R

Description

A KDE bw selection for one dim

Usage

1
rodeo.local.bw1(xx, x, h.init = 1.3/log(log(n)), beta = 0.9, cn = log(n)/n)

Arguments

xx

the point to be estimated

x

data points

h.init

initial smooth parameter

beta

learning rate, default 0.9

cn

a turning parameter, default log(n)/n

Value

h selected by this method

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Not run: 
set.seed(111)
n <- 200
Num.Cmp <- 8
pro <- rep(1/8, Num.Cmp)
multi <- sample(1:Num.Cmp, n, replace = T, prob=pro)
mu <- 3 * ((2/3)^(1:Num.Cmp) - 1)
sigma <- (2/3)^(1:Num.Cmp)
x <- NULL
for (ii in 1:Num.Cmp) {
  com_txt <- paste("com", ii, " <- rnorm(length(which(multi==", ii, ")), 
               mean=", mu[ii], ", sd=", sigma[ii], ")",sep="")
  eval(parse(text=com_txt))
  com_txt <- paste("x <- c(x, com", ii, ")", sep="")
  eval(parse(text=com_txt))
}

# true density function, y is h, and z is v.
y <- seq(-3, 1, 0.01)
z <- rep(0, length(y))
for (ii in 1:Num.Cmp) {
  z <- z + pro[ii] * dnorm(y, mean=mu[ii], sd=sigma[ii])
}
t <- seq(-3, 1, 0.05)
h <- unlist(base::lapply(X=t, FUN=rodeo.local.bw1, x=x))
plot(t, h, "l", main="Bandwidth of Rodeo", xlab="x", ylab="h")

## End(Not run)

DawnGnius/SC19086 documentation built on Jan. 3, 2020, 2:10 a.m.