[R] Help interpreting density().

From: <rkevinburton_at_charter.net>
Date: Mon, 28 Jul 2008 21:14:46 -0700

I issue the following:

> d <- density(rnorm(1000))
> d

and get:


        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


        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.


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. Received on Tue 29 Jul 2008 - 04:20:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 Jul 2008 - 07:32:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive