Eugene Kanshin
2012-Oct-01 13:46 UTC
[R] calculating probability from the density function
Hello, I have a data x with normal (or very close to normal) distribution, I can plot a density distribution with density(x,...). My question is is there any way to calculate an area under this distribution (=probability) for particular range of x values, let's say for x from 0 to 2? I was not able to find any kind of simple procedure to do this. Thanks in advance for your help, Evgeny. [[alternative HTML version deleted]]
Forget density(). Smooth the ecdf instead. ?lowess ?smooth.spline ?monotone.smooth (in package fda, for monotone smoothing, which may be preferable) ?locfit (in package locfit) ... and many many others -- Bert On Mon, Oct 1, 2012 at 6:46 AM, Eugene Kanshin <kanshined1 at gmail.com> wrote:> Hello, > I have a data x with normal (or very close to normal) distribution, I can > plot a density distribution with density(x,...). My question is is there > any way to calculate an area under this distribution (=probability) for > particular range of x values, let's say for x from 0 to 2? I was not able > to find any kind of simple procedure to do this. > Thanks in advance for your help, > Evgeny. > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.-- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
David Winsemius
2012-Oct-01 16:16 UTC
[R] calculating probability from the density function
On Oct 1, 2012, at 6:46 AM, Eugene Kanshin wrote:> Hello, > I have a data x with normal (or very close to normal) distribution, I can > plot a density distribution with density(x,...). My question is is there > any way to calculate an area under this distribution (=probability) for > particular range of x values, let's say for x from 0 to 2? I was not able > to find any kind of simple procedure to do this.? pnorm -- David Winsemius, MD Alameda, CA, USA
You may find it easier to use the logspline density fits (logspline package) rather than the kernel density estimators for this. On Mon, Oct 1, 2012 at 7:46 AM, Eugene Kanshin <kanshined1 at gmail.com> wrote:> Hello, > I have a data x with normal (or very close to normal) distribution, I can > plot a density distribution with density(x,...). My question is is there > any way to calculate an area under this distribution (=probability) for > particular range of x values, let's say for x from 0 to 2? I was not able > to find any kind of simple procedure to do this. > Thanks in advance for your help, > Evgeny. > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.-- Gregory (Greg) L. Snow Ph.D. 538280 at gmail.com