-1

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:

  • a density estimate (triangular kernels ofc)
Joris Meys
  • 106,551
  • 31
  • 221
  • 263
Amanda
  • 1
  • 2
    Give a small reproducible example and what you've tried so far. That way, you have better chance of harvesting a (good) answer. – Roman Luštrik Aug 19 '11 at 09:37
  • A reproducible example is what is explained here : http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example . What you need, is a good look at some help files, like `?density` and `?kernel`. – Joris Meys Aug 19 '11 at 12:11

1 Answers1

0

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)

Four bandwidths to triangular kernel density plot

IRTFM
  • 258,963
  • 21
  • 364
  • 487