[R] Help interpreting density().
rkevinburton at charter.net
rkevinburton at charter.net
Tue Jul 29 10:08:52 CEST 2008
Sorry, poor example. I started with normal deviates and jumped without thinking to Poisson. The main crux of the question is how does the output of density relate to the parameters that describe some of the standard distributions (mean and std for normal, lambda for Poisson, n and p for Binomial, alpha and beta for Beta, etc.).
Thank you.
Kevin
---- Bill.Venables at csiro.au wrote:
> You should read the documentation more carefully. The bw is not
> "essentially the sd". To quote the documentation the bw is "the
> smoothing bandwidth to be used. The kernels are scaled such that this is
> the standard deviation of the smoothing kernel." That is a very
> different thing.
>
> You are confusing the standard deviation of the distribution with the
> standard deviation of the gaussian smoothing kernels.
>
> In the second case, density(rpois(1000, 0)), you are getting the kernel
> density for a sample of 1000 zeros. So there is just one distinct
> smoothing kernel and the bw is a default used for this case. If you
>
> plot(density(rpois(1000, 0)))
>
> you will see what that smoothing kernel looks like.
>
>
> Bill Venables
> CSIRO Laboratories
> PO Box 120, Cleveland, 4163
> AUSTRALIA
> Office Phone (email preferred): +61 7 3826 7251
> Fax (if absolutely necessary): +61 7 3826 7304
> Mobile: +61 4 8819 4402
> Home Phone: +61 7 3286 7700
> mailto:Bill.Venables at csiro.au
> http://www.cmis.csiro.au/bill.venables/
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of rkevinburton at charter.net
> Sent: Tuesday, 29 July 2008 2:15 PM
> To: r-help at r-project.org
> Subject: [R] Help interpreting density().
>
> I issue the following:
>
> > d <- density(rnorm(1000))
> > d
>
> and get:
>
> Call:
> density.default(x = rnorm(1000))
>
> Data: rnorm(1000) (1000 obs.); Bandwidth 'bw' = 0.2235
>
> x y
> Min. :-3.5157 Min. :2.416e-05
> 1st Qu.:-1.6892 1st Qu.:1.129e-02
> Median : 0.1373 Median :7.267e-02
> Mean : 0.1373 Mean :1.367e-01
> 3rd Qu.: 1.9639 3rd Qu.:2.693e-01
> Max. : 3.7904 Max. :4.014e-01
>
> The documentation indicates that the bw is essentially the sd. Yet I
> have specified an sd of 1? How am I to interpret the ranges of the
> values? x ranges almost from -4 to +4 and y ranges from 0 to 0.4. The
> mean x is .1 which isn't too awfully close to what I would expect (0.0).
> Then there is:
>
> > d <- density(rpois(1000,0))
> > d
>
> Call:
> density.default(x = rpois(1000, 0))
>
> Data: rpois(1000, 0) (1000 obs.); Bandwidth 'bw' = 0.2261
>
> x y
> Min. :-0.6782 Min. :0.01979
> 1st Qu.:-0.3391 1st Qu.:0.14073
> Median : 0.0000 Median :0.57178
> Mean : 0.0000 Mean :0.73454
> 3rd Qu.: 0.3391 3rd Qu.:1.32830
> Max. : 0.6782 Max. :1.76436
>
> Here I am getting the mean that I expect from a Poisson distribuition
> but y ranges from 0 to 1.75. Again I am not sure what these numbers
> mean. How can I map the output to the standard distirbution description
> parameters?
>
> Thank you.
>
> Kevin
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
More information about the R-help
mailing list