s-news
[Top] [All Lists]

Re: Continuous curve over barplot, corrected

To: David Parkhurst <parkhurs@ariel.ucs.indiana.edu>
Subject: Re: Continuous curve over barplot, corrected
From: Sundar Dorai-Raj <sundar.dorai-raj@PDF.COM>
Date: Wed, 27 Oct 2004 06:01:29 -0500
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <001401c4bbc9$80abf470$6400a8c0@parkhursthome>
Organization: PDF Solutions, Inc.
References: <001401c4bbc9$80abf470$6400a8c0@parkhursthome>
Reply-to: sundar.dorai-raj@PDF.COM
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)


David Parkhurst wrote:
Duh. A few minutes ago, I sent the wrong code, and what I sent does work. Thanks to those who told me so! What I WANT to do (using Professional Edition Version 6.2.1 for Microsoft Windows : 2003) is to plot these dbinom values: x<-60:100
y<-dbinom(x,100,0.7)
as a barplot, and then to overlay the normal densities below as a continuous curve. Any suggestions? yy<-dnorm(x,70,sqrt(21))
Thanks.
Dave Parkhurst

Dave,

Would the following work for you?

p <- 0.7
n <- 20
x <- 0:n
px <- dbinom(x, n, p)
z <- seq(min(x), max(x), length = 200)
pz <- dnorm(z, n * p, sqrt(n * p * (1 - p)))
barplot(px, x - 0.5, histo = TRUE, ylim = range(px, pz), col = 0)
lines(z, pz)

--sundar


<Prev in Thread] Current Thread [Next in Thread>