Re: [R] density function

2012-06-27 Thread Greg Snow
Here are 2 approaches: Use logspline density estimates (logspline package) rather than kernel density estimates, this can give you a function to pass to integrate or other tools, the estimates may be a little different from the kernel density estimates. If you need to use kernel density estimates

Re: [R] density function

2012-06-27 Thread Rui Barradas
Hello, Maybe the link below is of some use. http://stats.stackexchange.com/questions/14061/area-under-the-pdf-in-kernel-density-estimation-in-r Hope this helps, Rui Barradas Em 27-06-2012 01:13, pilaw escreveu: Hello, I need density function so that I can find expected value (using integra

Re: [R] density function always evaluating to zero

2011-12-04 Thread Sarah Goslee
I didn't try out your extensive code, but here's one potentially serious problem: You only pass two arguments to f(), alpha and h, but within f you nonetheless use x1 and y and several other things. This is bad practice, and dangerous: you should pass all the necessary arguments to f(), not rely o

Re: [R] density function always evaluating to zero

2011-12-04 Thread napps22
Sorry that was my poor copying and pasting. Here's the correct R code. The problem does seem to be with the function I define as f. # Model selection example in a bayesian framework # two competiting non-nested models # M0: y_t = alpha * x1^2 + e_t # M1: y_t = beta * x1^4 + e_t # where e_t ~ iidN(

Re: [R] density function always evaluating to zero

2011-12-03 Thread David Winsemius
On Dec 3, 2011, at 5:42 PM, napps22 wrote: Dear R users, I'm trying to carry out monte carlo integration of a posterior density function which is the product of a normal and a gamma distribution. The problem I have is that the density function always returns 0. How can I solve this proble

Re: [R] Density function: Area under density plot is not equal to 1. Why?

2011-09-08 Thread peter dalgaard
On Sep 8, 2011, at 19:03 , Albyn Jones wrote: > Look at > >area <- sum(a$y)*(a$x[1]-a$y[2]) > > The problem appears to be "a$x[1]-a$y[2]"; that is not the length of > the base of an approximating rectangle, whatever it is :-) I would assume that that is just a typo for a$x[1]-a$x[2], which

Re: [R] Density function: Area under density plot is not equal to 1. Why?

2011-09-08 Thread Jean-Christophe BOUËTTÉ
Is your "data" supposed to be observations, or values of the density of the underlying law? Also, could you explain the rationale behind : sum(a$y)*(a$x[1]-a$y[2]) because it is not immediately clear to the reader. 2011/9/8 Gonçalo Ferraz : > Hi, I have a vector 'data' of 58 probability values (b

Re: [R] Density function: Area under density plot is not equal to 1. Why?

2011-09-08 Thread Albyn Jones
Look at area <- sum(a$y)*(a$x[1]-a$y[2]) The problem appears to be "a$x[1]-a$y[2]"; that is not the length of the base of an approximating rectangle, whatever it is :-) albyn On Thu, Sep 08, 2011 at 11:36:23AM -0400, Gonçalo Ferraz wrote: > Hi, I have a vector 'data' of 58 probability value

Re: [R] Density function: Area under density plot is not equal to 1. Why?

2011-09-08 Thread Greg Snow
For bounded density estimation look at the logspline package instead of the regular density function. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-hel

Re: [R] density function cannot work well on UNIX R version 2.13.

2011-08-31 Thread David Winsemius
On Aug 31, 2011, at 1:04 PM, alex46...@yahoo.com wrote: Hi, there, I found density function cannot work well on UNIX.R version 2.13.1 (2011-07-08), Platform: i386-pc-solaris2.10 (32-bit) Here is an example from R doucments which can work well on other version. plot(density(c(-20,rep(0,98

Re: [R] density() function: differences with S-PLUS

2010-11-04 Thread William Dunlap
Dunlap Spotfire, TIBCO Software wdunlap tibco.com From: mailingl...@sturaro.net [mailto:mailingl...@sturaro.net] On Behalf Of Nicola Sturaro Sommacal (Quantide srl) Sent: Thursday, November 04, 2010 2:36 AM To: William Dunlap Subject: R

Re: [R] density() function: differences with S-PLUS

2010-11-04 Thread Nicola Sturaro Sommacal (Quantide srl)
-- > > From: r-help-boun...@r-project.org > > [mailto:r-help-boun...@r-project.org] On Behalf Of Nicola > > Sturaro Sommacal (Quantide srl) > > Sent: Wednesday, November 03, 2010 3:34 AM > > To: Joshua Wiley > > Cc: r-help@r-project.org > > Subject: Re: [R] dens

Re: [R] density() function: differences with S-PLUS

2010-11-03 Thread Nicola Sturaro Sommacal (Quantide srl)
; [mailto:r-help-boun...@r-project.org] On Behalf Of Nicola > > Sturaro Sommacal (Quantide srl) > > Sent: Wednesday, November 03, 2010 3:34 AM > > To: Joshua Wiley > > Cc: r-help@r-project.org > > Subject: Re: [R] density() function: differences with S-PLUS >

Re: [R] density() function: differences with S-PLUS

2010-11-03 Thread Nicola Sturaro Sommacal (Quantide srl)
Dear Joshua, first of all, thank you very much for reply. I hoped that someone who's familiar with both S+ and R can reply to me, because I spent some hours to looking for a solution. If someone else would try, this is the SPLUS code and output, while below there is the R code. I obtain the same

Re: [R] density() function: differences with S-PLUS

2010-11-02 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Nicola > Sturaro Sommacal (Quantide srl) > Sent: Tuesday, November 02, 2010 3:05 AM > To: r-help@r-project.org > Subject: [R] density() function: differences with S-PLUS > > Hel

Re: [R] density() function: differences with S-PLUS

2010-11-02 Thread Joshua Wiley
Dear Nicola, There are undoubtedly people here who are familiar with both S+ and R, but they may not always be around or get to every question. In that case there are (at least) two good options for you: 1) Say what you want mathematically (something of a universal language) or statistically 2)