Re: [R] density with weights missing values

2021-07-13 Thread Göran Broström
2.5 weighted.mean(c(1, 2, 3, NA), weights=c(1, 1, 1, 1)) [1] NA weighted.mean(c(1, 2, 3, NA), weights=c(1, 1, 1, 1), na.rm=TRUE) [1] 2 Von: Richard O'Keefe Gesendet: Montag, 12. Juli 2021 13:18 An: Matthias Gondan Betreff: Re: [R] density with weights missing values Does your copy of

Re: [R] density with weights missing values

2021-07-13 Thread Matthias Gondan
. Best wishes, Matthias PS. Sorry for the HTML email. I’ve given up trying to fix such behavior. Von: Martin Maechler Gesendet: Dienstag, 13. Juli 2021 09:09 An: Matthias Gondan Cc: r-help@r-project.org Betreff: Re: [R] density with weights missing values >>>>> Matthias Gonda

Re: [R] density with weights missing values

2021-07-13 Thread Martin Maechler
d then in your report mention both density() and weighted.mean(), i.e., a cleaned up version of the union of your first 2 e-mails.. Thank you for thinking about this and concisely reporting it. Martin > Von: Richard O'Keefe > Gesendet: Montag, 12. Juli 2021 13:18 > An: Ma

Re: [R] density with weights missing values

2021-07-12 Thread Duncan Murdoch
On 12/07/2021 1:22 p.m., matthias-gondan wrote: You're right, of course. Extrapolating your argument a bit, the whole practice of na.rm is questionable, since there's always a reason for missingness (that is not in x and rarely elsewhere in the data)Best wishes Matthias For what it's worth, I

Re: [R] density with weights missing values

2021-07-12 Thread Jeff Newmiller
12.07.21 18:44 (GMT+01:00) An: >r-help@r-project.org, matthias-gondan , Bert >Gunter Cc: r-help@r-project.org Betreff: Re: >[R] density with weights missing values Sure, you might think that.But >most likely the reason this code has not been corrected is that when >you give weights

Re: [R] density with weights missing values

2021-07-12 Thread matthias-gondan
er Datum: 12.07.21 18:44 (GMT+01:00) An: r-help@r-project.org, matthias-gondan , Bert Gunter Cc: r-help@r-project.org Betreff: Re: [R] density with weights missing values Sure, you might think that.But most likely the reason this code has not been corrected is that when you give weights for mi

Re: [R] density with weights missing values

2021-07-12 Thread Jeff Newmiller
dan Cc: r-help@r-project.org >Betreff: Re: [R] density with weights missing values The behavior is as >documented AFAICS.na.rmlogical; if TRUE, missing values are removed >from x. If FALSE anymissing values cause an error.The default is >FALSE.weightsnumeric vector of non-negative obse

Re: [R] density with weights missing values

2021-07-12 Thread Bert Gunter
eighted.mean(c(1, 2, 3, 4), weights=c(1, 1, 1, 1)) > > [1] 2.5 > > > weighted.mean(c(1, 2, 3, NA), weights=c(1, 1, 1, 1)) > > [1] NA > > > weighted.mean(c(1, 2, 3, NA), weights=c(1, 1, 1, 1), na.rm=TRUE) > > [1] 2 > > > > > > > > > >

Re: [R] density with weights missing values

2021-07-12 Thread matthias-gondan
thing?  Ursprüngliche Nachricht Von: Bert Gunter Datum: 12.07.21 16:25 (GMT+01:00) An: Matthias Gondan Cc: r-help@r-project.org Betreff: Re: [R] density with weights missing values The behavior is as documented AFAICS.na.rmlogical; if TRUE, missing values are removed from x. If FALSE anymissing v

Re: [R] density with weights missing values

2021-07-12 Thread Bert Gunter
ghts=c(1, 1, 1, 1)) > [1] 2.5 > > weighted.mean(c(1, 2, 3, NA), weights=c(1, 1, 1, 1)) > [1] NA > > weighted.mean(c(1, 2, 3, NA), weights=c(1, 1, 1, 1), na.rm=TRUE) > [1] 2 > > > > > Von: Richard O'Keefe > Gesendet: Montag, 12. Juli 2021 13:18 > An:

Re: [R] density with weights missing values

2021-07-12 Thread Matthias Gondan
a.rm=TRUE) [1] 2 Von: Richard O'Keefe Gesendet: Montag, 12. Juli 2021 13:18 An: Matthias Gondan Betreff: Re: [R] density with weights missing values Does your copy of R say that the weights must add up to 1? ?density doesn't say that in mine. But it does check. On Mon, 12 Jul 2021

[R] density with weights missing values

2021-07-12 Thread Matthias Gondan
Dear R users, This works as expected: • plot(density(c(1,2, 3, 4, 5, NA), na.rm=TRUE)) This raises an error • plot(density(c(1,2, 3, 4, 5, NA), na.rm=TRUE, weights=c(1, 1, 1, 1, 1, 1))) • plot(density(c(1,2, 3, 4, 5, NA), na.rm=TRUE, weights=c(1, 1, 1, 1, 1, NA))) This seems to work (it trigge

Re: [R] density vs. mass for discrete probability functions

2019-03-16 Thread Rui Barradas
Hello, Yes, there is even an old discussion on this on r-devel, dated August, 10 2013. See [1]. [1] https://r-project.markmail.org/search/?q=broken-link-in-docs-for-Binormial-functions#query:broken-link-in-docs-for-Binormial-functions+page:1+mid:rf6tbiokcdyai6el+state:results Hope this he

Re: [R] density vs. mass for discrete probability functions

2019-03-16 Thread Stefan Schreiber
Thank you Peter and Spencer. That clears things up. Also since no one responded the second part of my question, I'm still wondering if it was noted that there is a hyperlink in the dbinom help file (?dbinom) that isn't directing correctly? Stefan On Fri, Mar 15, 2019, 07:37 peter dalgaard, wrote

Re: [R] density vs. mass for discrete probability functions

2019-03-15 Thread JLucke
PM To r-help@r-project.org, cc Subject [R] density vs. mass for discrete probability functions Dear R users, While experimenting with the dbinom() function and reading its documentation (?dbinom) it reads that "dbinom gives the density" but shouldn't it be called "ma

Re: [R] density vs. mass for discrete probability functions

2019-03-15 Thread Spencer Graves
On 2019-03-15 08:37, peter dalgaard wrote: Mathematically, you can bring discrete and continuous distributions on a common footing by defining probability functions as densities wrt. counting measure. You don't really need Radon-Nikodym derivatives to understand the idea, just the fact that

Re: [R] density vs. mass for discrete probability functions

2019-03-15 Thread peter dalgaard
Mathematically, you can bring discrete and continuous distributions on a common footing by defining probability functions as densities wrt. counting measure. You don't really need Radon-Nikodym derivatives to understand the idea, just the fact that sums can be interpreted as integrals wrt counti

Re: [R] density vs. mass for discrete probability functions

2019-03-15 Thread Spencer Graves
On 2019-03-14 19:43, Stefan Schreiber wrote: Dear R users, While experimenting with the dbinom() function and reading its documentation (?dbinom) it reads that "dbinom gives the density" but shouldn't it be called "mass" instead of "density"? I assume that it has something to do with keeping

[R] density vs. mass for discrete probability functions

2019-03-15 Thread Stefan Schreiber
Dear R users, While experimenting with the dbinom() function and reading its documentation (?dbinom) it reads that "dbinom gives the density" but shouldn't it be called "mass" instead of "density"? I assume that it has something to do with keeping the function for "density" consistent across discr

Re: [R] Density plot error

2016-09-19 Thread Jeff Newmiller
You desperately need to read the Posting Guide mentioned at the bottom of every posting on this list. Avoid attachments (your code did not come through), keep sample data size minimal, don't reply to other topic messages (start a fresh email thread so your message doesn't get buried in other peo

[R] Density plot error

2016-09-19 Thread najad zamirah zaki via R-help
Hi, I'm Najad, a student at the University of Glasgow. I really need help with a script of mine to plot density plot for my data. I kept on having an error saying need at least 2 points to select a bandwidth automaticallyI've tried to replace the NaN in my data to zero but still the same. I'm no

Re: [R] density plot not smooth

2015-03-18 Thread Fix Ace
Thank you very much! I do need to learn more about R!! On Tuesday, March 17, 2015 9:26 PM, William Dunlap wrote: Fix Ace wrote    What is the default "n"? 512:   > length(density(rnorm(10^6))$x)   [1] 512   > args(density.default)    function (x, bw = "nrd0", adjust = 1, kernel = c(

Re: [R] density plot not smooth

2015-03-18 Thread S Ellison
> I have a dataset with 6187 elements, ranged from 3 to 104028. When I tried to > examine only small range of data, I found that the plot was not smooth (as > shown below): > plot(density(test$V2), xlim=c(0,1000)) > > >  Is there away to make it smoother? For small ranges, use 'from' and 'to' i

Re: [R] density plot not smooth

2015-03-17 Thread Fix Ace
Thank you for the email. What is the default "n"? Thanks! On Tuesday, March 17, 2015 4:06 PM, William Dunlap wrote: Increasing the value of 'n' given to density will give an estimate at more points so it will look smoother.  Try n=2^18. Bill Dunlap TIBCO Software wdunlap tibco.com

Re: [R] density plot not smooth

2015-03-17 Thread William Dunlap
Fix Ace wrote What is the default "n"? 512: > length(density(rnorm(10^6))$x) [1] 512 > args(density.default) function (x, bw = "nrd0", adjust = 1, kernel = c("gaussian", "epanechnikov", "rectangular", "triangular", "biweight", "cosine", "optcosine"), weights = NULL, w

Re: [R] density plot not smooth

2015-03-17 Thread William Dunlap
Increasing the value of 'n' given to density will give an estimate at more points so it will look smoother. Try n=2^18. Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Mar 17, 2015 at 12:06 PM, Fix Ace wrote: > > > I have a dataset with 6187 elements, ranged from 3 to 104028. When I > tr

[R] density plot not smooth

2015-03-17 Thread Fix Ace
I have a dataset with 6187 elements, ranged from 3 to 104028. When I tried to examine only small range of data, I found that the plot was not smooth (as shown below): plot(density(test$V2), xlim=c(0,1000))  Is there away to make it smoother? Thanks a lot!!     ___

Re: [R] Density plots for Chi-square and F-distribution on my data

2015-02-19 Thread varin sacha
uot; Envoyé le : Jeudi 19 février 2015 17h51 Objet : Re: [R] Density plots for Chi-square and F-distribution on my data I think you might do well to consult a local statistical expert, as you appear to be out of your statistical depth here. Also, is this homework? If so, this is not a homework

Re: [R] Density plots for Chi-square and F-distribution on my data

2015-02-19 Thread Bert Gunter
I think you might do well to consult a local statistical expert, as you appear to be out of your statistical depth here. Also, is this homework? If so, this is not a homework site (although posters sometimes get help anyway). Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467

[R] Density plots for Chi-square and F-distribution on my data

2015-02-19 Thread varin sacha
Dear R-helpers, I want to compute the density plot (probability plot) of the Chi-square distribution. My 2 categorical variables are gender (male, female) and colors of the eyes (blue, green and brown). The sample size n = 100. The proportions are the following : male and blue eyes : 10% male

Re: [R] density in hist does not come as 1

2014-05-19 Thread Pascal Oettli
Hello, What you are doing wrong? Correctly read the help page. >From the help page: "if FALSE, probability densities, component density, are plotted (so that the histogram has a *total area of one*)" > sum(check$density * diff(check$breaks)) [1] 1 HTH, Pascal On Tue, May 20, 2014 at 3:06 PM, v

[R] density in hist does not come as 1

2014-05-19 Thread vikram ranga
Dear List, I am trying to make a histogram with following data: dput(a) c(1, 0, 1.5, 1, 0, 0, 0, 1, 1.5, 0, 0, 1, 0, 0, 0, 1, 1, 2, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0.5, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1.5, 0, 0, 0, 0, 1, 0, 0, 0.5, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1,

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 or Boxplot with median and mean

2014-01-22 Thread Alaios
Thanks Jim.. once again your rock On Wednesday, January 22, 2014 9:51 AM, Jim Lemon wrote: On 01/22/2014 07:37 PM, Alaios wrote: > Hi there, > I would like to be able to draw a density plot or a box plot where the median > and the median and the mean would be visible. > > If I decide a de

Re: [R] Density or Boxplot with median and mean

2014-01-22 Thread Jim Lemon
On 01/22/2014 07:37 PM, Alaios wrote: Hi there, I would like to be able to draw a density plot or a box plot where the median and the median and the mean would be visible. If I decide a density plot I need to put two big marks one for the median and one for the mean, which I do not know how I

[R] Density or Boxplot with median and mean

2014-01-22 Thread Alaios
Hi there, I would like to be able to draw a density plot or a box plot where the median and the median and the mean would be visible. If I decide a density plot I need to put two big marks one for the median and one for the mean, which I do not know how I can achieve to put marks in a density p

Re: [R] density of hist(freq = FALSE) inversely affected by data magnitude

2013-01-23 Thread William Dunlap
ng -- rather use freq=FALSE Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: J Toll [mailto:jct...@gmail.com] > Sent: Tuesday, January 22, 2013 5:32 PM > To: William Dunlap > Cc: r-help > Subject: Re: [R] density of hist(freq = FAL

Re: [R] density of hist(freq = FALSE) inversely affected by data magnitude

2013-01-22 Thread J Toll
Bill, Thank you. I got it. That can require a fair amount of work to interpret the density, especially with odd or irregular bin sizes. Thanks again, James On Tue, Jan 22, 2013 at 5:33 PM, William Dunlap wrote: > The probability density function is not unitless - it is the derivative of th

Re: [R] density of hist(freq = FALSE) inversely affected by data magnitude

2013-01-22 Thread William Dunlap
ilto:r-help-boun...@r-project.org] On > Behalf > Of J Toll > Sent: Tuesday, January 22, 2013 2:48 PM > To: r-help > Subject: [R] density of hist(freq = FALSE) inversely affected by data > magnitude > > Hi, > > I have a couple of observations, a question or two, and

[R] density of hist(freq = FALSE) inversely affected by data magnitude

2013-01-22 Thread J Toll
Hi, I have a couple of observations, a question or two, and perhaps a suggestion related to the plotting of density on the y-axis within the hist() function when freq=FALSE. I was using the function and trying to develop an intuitive understanding of what the density is telling me. After reading

Re: [R] Density

2012-08-09 Thread David L Carlson
, August 09, 2012 8:55 AM To: dcarl...@tamu.edu Cc: r-help Subject: Re: [R] Density Hi David,    Thanks a lot for the reply.    I might not have stated the problem clearly. Let me try again.      Given a set of observations X, I want to find out the estimated density values for the observations X?

Re: [R] Density

2012-08-09 Thread William Dunlap
CO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of li li > Sent: Thursday, August 09, 2012 6:55 AM > To: dcarl...@tamu.edu > Cc: r-help > Subject: Re: [R] Density > >

Re: [R] Density

2012-08-09 Thread li li
amp;M University > College Station, TX 77843-4352 > > > > -Original Message- > > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > > project.org] On Behalf Of li li > > Sent: Wednesday, August 08, 2012 9:03 PM > > To: r-help > > Subject: [R]

Re: [R] Density

2012-08-08 Thread David L Carlson
352 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of li li > Sent: Wednesday, August 08, 2012 9:03 PM > To: r-help > Subject: [R] Density > > Dear all, >Given a set of observations X, I wa

[R] Density

2012-08-08 Thread li li
Dear all, Given a set of observations X, I want to evaluate the kernel density estimator at these observed values. If I do the following, I do not get the those estimated values directly. Can anyone familiar with this give an idea on how to find out the estimated density values for X? > X <- rn

Re: [R] Density plots

2012-08-03 Thread Ayyappa Chaturvedula
; College Station, TX 77843-4352 > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- >> project.org] On Behalf Of Ayyappa Chaturvedula >> Sent: Friday, August 03, 2012 10:37 AM >> To: r-help@r-project.org >> Subjec

Re: [R] Density plots

2012-08-03 Thread David L Carlson
ofessor of Anthropology Texas A&M University College Station, TX 77843-4352 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Ayyappa Chaturvedula > Sent: Friday, August 03, 2012 10:37 AM > To: r-help@r-project.org

[R] Density plots

2012-08-03 Thread Ayyappa Chaturvedula
Dear group, I need help on two problems: 1. I am trying to plot density plots for each individual in 8 occasions. I can do this by subject wiht the code below: par(mfrow=c(4,2)) plot(density(all8scenarios$SIMCONC[all8scenarios$ID==1&all8scenarios$WSEQ==0])) plot(density(all8scenarios$SIMCONC[all

Re: [R] density

2012-07-26 Thread Bert Gunter
t;> Associate Professor of Anthropology >> Texas A&M University >> College Station, TX 77843-4352 >> >> > -Original Message- >> > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- >> > project.org] On Behalf Of Michael Young >>

Re: [R] density

2012-07-26 Thread li li
M University > College Station, TX 77843-4352 > > > -Original Message- > > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > > project.org] On Behalf Of Michael Young > > Sent: Wednesday, July 25, 2012 9:53 PM > > To: li li > > Cc: r-h

Re: [R] density

2012-07-26 Thread David L Carlson
-Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Michael Young > Sent: Wednesday, July 25, 2012 9:53 PM > To: li li > Cc: r-help > Subject: Re: [R] density > > I can't help you decide which band

Re: [R] density

2012-07-25 Thread Michael Young
I can't help you decide which bandwidth method to use, but here's how you view the density source code... methods("density") density.default On Wed, Jul 25, 2012 at 5:56 PM, li li wrote: > > Hi all, > I have a question regarding the density function which gives the > kernel density estimator.

[R] density

2012-07-25 Thread li li
Hi all, I have a question regarding the density function which gives the kernel density estimator. I want to decide the bandwidth when using gaussian kernel, given a set of observations. I am not familiar with different methods for bandwidth determination. Below are the different ways in R on

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 plot on a log scale

2012-06-14 Thread John Kane
t, price)) + geom_point(alpha = 1/10) p http://had.co.nz/ggplot2/geom_point.html John Kane Kingston ON Canada > -Original Message- > From: j...@bitwrit.com.au > Sent: Thu, 14 Jun 2012 21:39:36 +1000 > To: field.c...@gmail.com > Subject: Re: [R] density plot on a log s

Re: [R] density plot on a log scale

2012-06-14 Thread Jim Lemon
On 06/14/2012 07:08 PM, field.cady wrote: I'm working with a large dataset - large enough that when I do a scatter plot the points all blur together, so I want to plot their density by color - a heat map or something like that. I've used smoothScatter for tasks like this, but the problem is that

[R] density plot on a log scale

2012-06-14 Thread field.cady
I'm working with a large dataset - large enough that when I do a scatter plot the points all blur together, so I want to plot their density by color - a heat map or something like that. I've used smoothScatter for tasks like this, but the problem is that my current dataset really only looks good o

Re: [R] density plots using density.lf, data.frame and sort.int errors

2012-05-31 Thread R. Michael Weylandt
My guess (unconfirmed) is that read.table() gives you a data frame but density.lf expects an atomic (= not a list = not a data frame) vector. Perhaps try density.lf(x[,1]) to just send the column -- the "drop" behavior should make sure this is an atomic vector. If that doesn't help, please do prov

[R] density plots using density.lf, data.frame and sort.int errors

2012-05-31 Thread Andrea S Sequeira
Dear R help group: I am attempting to produce a density plot from a list of 2 values using the density.lf function and would appreciate any help, I hope I have done my homework reading the documentation but I still seem to be missing something basic. I have read the data as a table using read.

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

[R] Density over time intervals

2011-11-23 Thread Willi Richert
Hello R community, I have recorded online/offline timestamps per user that looks like this: username,online_time,offline_time a,2011-11-01 16:16:56.692572+01,2011-11-01 21:06:16.388903+01 a,2011-11-01 21:07:14.204367+01,2011-11-01 21:34:21.47081+01 a,2011-11-01 21:38:09.501356+01,2011-11-01 21:53

[R] Density over time intervals

2011-11-23 Thread Willi Richert
Hi, I have recorded online/offline timestamps per user that looks like this: username,online_time,offline_time a,2011-11-01 16:16:56.692572+01,2011-11-01 21:06:16.388903+01 a,2011-11-01 21:07:14.204367+01,2011-11-01 21:34:21.47081+01 a,2011-11-01 21:38:09.501356+01,2011-11-01 21:53:45.272321+

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 plot with frequency units

2011-08-16 Thread r student
Let me ask another way. Is there a way to create a histogram with a fitted line, but without bars? Or, perhaps draw the bars with invisible lines? Thanks. On Tue, Aug 16, 2011 at 7:29 AM, Jeff Newmiller wrote: > This is a nonsensical request. It is like saying you want to plot the speed > of

Re: [R] density plot with frequency units

2011-08-16 Thread Jeff Newmiller
This is a nonsensical request. It is like saying you want to plot the speed of a falling object but you want the units of speed to be meters. --- Jeff Newmiller The . . Go Live... DCN: Basics: ##.#. ##.#. Live Go... Li

[R] density plot with frequency units

2011-08-16 Thread r student
I would like to create a kernal density plot, but rather than show density units on the vertical axis I would like frequencies. I know histograms do this but I don't want the bars, just the density curve. Thanks! __ R-help@r-project.org mailing list h

Re: [R] density plot for weighted data

2011-08-02 Thread Thomas Lumley
On Wed, Aug 3, 2011 at 5:11 AM, r student wrote: > Like below? > > plot(density(oh$FINCP,weights=oh$PWGTP/sum(oh$PWGTP))) > Yes If you are doing lots of analyses with weighted data you might want to look at the survey package. It also has a density estimator, in svysmooth(), which works very mu

Re: [R] density plot for weighted data

2011-08-02 Thread r student
Like below? plot(density(oh$FINCP,weights=oh$PWGTP/sum(oh$PWGTP))) On Tue, Aug 2, 2011 at 10:06 AM, David Winsemius wrote: > > On Aug 2, 2011, at 12:51 PM, r student wrote: > >> I'm trying to create a density plot using census data, where the >> weights don't sum to 1. >> >> >>> plot(density

Re: [R] density plot for weighted data

2011-08-02 Thread David Winsemius
On Aug 2, 2011, at 1:11 PM, r student wrote: Like below? plot(density(oh$FINCP,weights=oh$PWGTP/sum(oh$PWGTP))) I don't understand why you are asking for approval. You are the one with the data and know where they came from. We have none of that background. -- David. On Tue, Aug 2, 20

Re: [R] density plot for weighted data

2011-08-02 Thread David Winsemius
On Aug 2, 2011, at 12:51 PM, r student wrote: I'm trying to create a density plot using census data, where the weights don't sum to 1. plot(density(oh$FINCP,weights=oh$PWGTP)) Warning message: In density.default(oh$FINCP, weights = oh$PWGTP) : sum(weights) != 1 -- will not get true dens

[R] density plot for weighted data

2011-08-02 Thread r student
I'm trying to create a density plot using census data, where the weights don't sum to 1. >plot(density(oh$FINCP,weights=oh$PWGTP)) Warning message: In density.default(oh$FINCP, weights = oh$PWGTP) : sum(weights) != 1 -- will not get true density How would I go about doing this? Thanks!

Re: [R] density plot of simulated exponential distributed data

2011-04-28 Thread Juanjuan Chai
I tried logspline function using a lower bound 0 for my data, it works like a charm. When the I changed the xlim only positive part, the vertical line was also gone. That's exactly what I expected. Thanks. -JJ Greg Snow wrote: You might want to use the logspline package instead of the density

Re: [R] density plot of simulated exponential distributed data

2011-04-27 Thread Breheny, Patrick
help-boun...@r-project.org] On Behalf Of Greg Snow Sent: Wednesday, April 27, 2011 1:55 PM To: Juanjuan Chai; r-help@r-project.org Subject: Re: [R] density plot of simulated exponential distributed data You might want to use the logspline package instead of the density function, it allow

Re: [R] density plot of simulated exponential distributed data

2011-04-27 Thread Greg Snow
p-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Juanjuan Chai > Sent: Tuesday, April 26, 2011 4:19 PM > To: r-help@r-project.org > Subject: [R] density plot of simulated exponential distributed data > > Hi all, > > I tried to plot the den

Re: [R] density plot of simulated exponential distributed data

2011-04-26 Thread Dennis Murphy
Hi: Try this (and note the use of vectorization rather than a loop): rate <- 3 dta <- -log(1 - runif(1000))/rate hist(dta, nclass = 30, probability = TRUE) x <- c(0.001, seq(0, 3, by = 0.01)) lines(x, dexp(x, rate = 3)) This is the difference in timings between the vectorized and iterative metho

[R] density plot of simulated exponential distributed data

2011-04-26 Thread Juanjuan Chai
Hi all, I tried to plot the density curve using the data from simulation. I am sure that the data should be exponentially distributed, but the plot of density curve always starts from (0,0) which is not the case for exponential distribution. Is there any way around this, to keep the curve

Re: [R] Density estimation and plots

2011-04-13 Thread Jim Silverton
I have two columns of data, one is a subset of the other. All the data lie beteen 0 and 1 inclusive. I want to fit both densities on the same graph. I would also like the ability to extract the fitted values of both smoothed density (using the best method of course). For example, if h = c( runif(1

Re: [R] Density plot with lattice?

2010-12-21 Thread Dennis Murphy
Hi: Try this: densityplot( ~ height | voice.part, data = singer, layout = c(2, 4), xlab = "Height (inches)", bw = 5) densityplot( ~ height | voice.part, data = singer, layout = c(2, 4), xlab = "Height (inches)", bw = 5, plot.points = FALSE) The plot.points argument is a

[R] Density plot with lattice?

2010-12-21 Thread Marie-Hélène Hachey
Hi, Is it possible to remove the points at the base of a density plot?I would like to keep only the curves of the plot, not the points. Thank you. Marie-Helene HacheyM.Sc. studentUniversite Laval, Quebec __ R-h

Re: [R] density at particular values

2010-11-21 Thread Ted Harding
On 21-Nov-10 19:11:20, William Dunlap wrote: >> -Original Message- >> From: r-help-boun...@r-project.org >> [mailto:r-help-boun...@r-project.org] On Behalf Of Shant Ch >> Sent: Saturday, November 20, 2010 6:34 PM >> To: David Winsemius >> Cc: r-h

Re: [R] density at particular values

2010-11-21 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Shant Ch > Sent: Saturday, November 20, 2010 6:34 PM > To: David Winsemius > Cc: r-help@r-project.org > Subject: Re: [R] density at particular values >

Re: [R] density at particular values

2010-11-20 Thread Bill.Venables
rate(). Bill Venables. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius Sent: Sunday, 21 November 2010 3:21 PM To: Shant Ch Cc: r-help@r-project.org Subject: Re: [R] density at particular values On Nov 20, 2010, at 9

Re: [R] density at particular values

2010-11-20 Thread David Winsemius
From: David Winsemius To: Shant Ch Cc: r-help@r-project.org Sent: Sat, November 20, 2010 8:54:32 PM Subject: Re: [R] density at particular values On Nov 20, 2010, at 8:07 PM, Shant Ch wrote: > Hello everyone! > > I want to use density function of R to compute the density at x(=0, sa

Re: [R] density at particular values

2010-11-20 Thread Jorge Ivan Velez
sity given as y. > > I want to find the density of the given data at x=1. I basically want the > value > of y(=density) for x=1 i.e. kernel density at x=1. > > Shant > > > > > > > > > > > > > > > From: David Winsemius > >

Re: [R] density at particular values

2010-11-20 Thread Shant Ch
vid Winsemius Cc: r-help@r-project.org Sent: Sat, November 20, 2010 8:54:32 PM Subject: Re: [R] density at particular values On Nov 20, 2010, at 8:07 PM, Shant Ch wrote: > Hello everyone! > > I want to use density function of R to compute the density at x(=0, say). But >it > is gi

Re: [R] density at particular values

2010-11-20 Thread David Winsemius
On Nov 20, 2010, at 8:07 PM, Shant Ch wrote: Hello everyone! I want to use density function of R to compute the density at x(=0, say). But it is giving me the 5-number summary and mean of the data and densities at that point. I just want the densities at different values specified by me.

[R] density at particular values

2010-11-20 Thread Shant Ch
Hello everyone! I want to use density function of R to compute the density at x(=0, say). But it is giving me the 5-number summary and mean of the data and densities at that point. I just want the densities at different values specified by me. Can anyone let me know how can I find that? For

  1   2   >