开发者

Constant bandwidth in kernel density estimate (R)

开发者 https://www.devze.com 2023-03-29 11:20 出处:网络
I\'m having some difficulties with R right now. What I have: a vector with minimal values for each triangular kernel

I'm having some difficulties with R right now.

What I have:

  • a vector with minimal values for each triangular kernel
  • a vector with maximal values
  • a vector with the "middle" point (where the pick of each triangular should be)

What I need:


See if you can build on this example of varying bandwidth specifications to the base density function with a triagular kernel:

data("faithful", package = "datasets") 
x <- faithful$waiting 
opar <- par(mfcol= c(2,2))
for (bw in c(3,6,12,18) ) {
  hist(x, xlab = "Waiting interval", ylab = "Eruption Freq", 
  probability = TRUE, main = "Density plot: Triangular kernel", 
  border = "gray", sub= bquote("Bandwidth = "*.(bw) ) ) 
  lines(density(x, width = bw, window = "triangular"), lty=3, col="red")
  }
par(opar)

Constant bandwidth in kernel density estimate (R)

0

精彩评论

暂无评论...
验证码 换一张
取 消