-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org] On Behalf Of Michael Young
Sent: Wednesday, July 25, 2012 9:53 PM
To: li li
Cc: r-help
Subject: Re: [R] density
I can't help you decide which bandwidth method to use, but here's how
you view the density source code...
methods("density")
density.default
On Wed, Jul 25, 2012 at 5:56 PM, li li <hannah.hlx at gmail.com> wrote:
Hi all,
I have a question regarding the density function which gives the
kernel density estimator.
I want to decide the bandwidth when using gaussian kernel, given a
of
observations. I am not familiar with different methods for bandwidth
determination. Below are the different ways in R on deciding the
bandwidth.
Can anyone give an idea on which ones are preferred.
Also, how can I take a look at the source code for the density
Thank you very much.
Hannah
x <- rnorm(1000)
[1] 0.2890085
Warning message:
In bw.bcv(x) : minimum occurred at one end of the range
density(x, give.Rkern=T, kernel="gaussian")
density(x, kernel="gaussian")
Call:
density.default(x = x, kernel = "gaussian")
Data: x (1000 obs.); Bandwidth 'bw' = 0.2283
x y
Min. :-3.974672 Min. :0.0000199
1st Qu.:-1.987712 1st Qu.:0.0076405
Median :-0.000752 Median :0.0529498
Mean :-0.000752 Mean :0.1256971
3rd Qu.: 1.986208 3rd Qu.:0.2552411
Max. : 3.973168 Max. :0.3883532
[[alternative HTML version deleted]]