Re: [R] Problem with R "density" function

2014-05-14 Thread Andrews, Chris
M To: DHIMAN BHADRA; r-help@r-project.org Subject: Re: [R] Problem with R "density" function Hi, Have you tried using a different bandwidth rather than the number of points, the default bandwidth gives ... x <- rnorm(1) dd <- density(x,kernel="epanechnikov",

Re: [R] Problem with R "density" function

2014-05-14 Thread Martyn Byng
..@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of DHIMAN BHADRA Sent: 14 May 2014 10:36 To: r-help@r-project.org Subject: [R] Problem with R "density" function Hello, My friend has the following issue with R. I will be glad to receive any response. Thanks, Dhiman Bhadra Hello

[R] Problem with R "density" function

2014-05-14 Thread DHIMAN BHADRA
Hello, My friend has the following issue with R. I will be glad to receive any response. Thanks, Dhiman Bhadra Hello everyone, I am trying to use the 'density' function available with the base package of R to estimate the density of a data set for subsequent use. I just noticed that with even 100

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

[R] density function

2012-06-26 Thread pilaw
Hello, I need density function so that I can find expected value (using integration). I use density(): f= density(data) but f isn't a function and I can't get values and integrate it This is very urget, so please help. Greetings Peter -- View this message in context: http://r.789695.n4.nabble

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

[R] density function always evaluating to zero

2011-12-03 Thread napps22
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 problem? Here is my code #generate data x1 <- runif(100

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
ilto:r-help-bounces@r- > project.org] On Behalf Of Gonçalo Ferraz > Sent: Thursday, September 08, 2011 9:36 AM > To: r-help@r-project.org > Subject: [R] Density function: Area under density plot is not equal to > 1. Why? > > Hi, I have a vector 'data' of 58 probability v

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

2011-09-08 Thread Gonçalo Ferraz
Hi, I have a vector 'data' of 58 probability values (bounded between 0 and 1) and want to draw a probability density function of these values. For this, I used the commands: data <- runif(58) a <- density(data, from=0, to=1) plot(a, type="l",lwd=3) But then, when I try to approximate the area

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

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

2011-08-31 Thread alex46015
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),20)), xlim = c(-4,4))# But right now the estimated probab

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: di

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)

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

2010-11-02 Thread Nicola Sturaro Sommacal (Quantide srl)
Hello! Someone know what are the difference between R and S-PLUS in the density() function? For example, I would like to reply this simple S-PLUS code in R, but I don't understand which parameter I should modify to get the same results. S-PLUS CODE: density(1:1000, width = 4) R-CODE: density(1: