[R] Overlaying graphs
paul at datavore.com
Thu Sep 4 16:10:49 CEST 2003
My apologies for the last email that only contained the message and not my
reply. Here is what I meant to send.
----- Original Message -----
From: "Richard A. O'Keefe" <ok at cs.otago.ac.nz>
To: <paul at datavore.com>
Sent: Thursday, September 04, 2003 2:56 AM
Subject: Re: [R] Overlaying graphs
> I do not know how to overlay the curve graphic on top of hist graphic.
> Do you know about the "add=TRUE" option for plot()?
I learned about it from one of the list members and it worked ok for me.
This is the recipe I finally came up with:
fat <- read.table("fat.dat", header=TRUE)
mu <- mean(fat$height)
sdev <- sd(fat$height)
hist(fat$height, br=20, freq=FALSE, col="lightblue",
border="black", xlab="Male Height in Inches",
main = paste("Histogram of" , "Male Height"))
curve(dnorm(x, mu, sdev), add=TRUE, from=64, to=78, col="red", lwd=5)
> I am hoping to show visually that the normal curve overlays the obtained
> probability distribution when plotted on the same graph. Unfortunately, I
> an not sure how to overlay them. Can anyone point me in the right
> or show me the code.
> This is a bad way to do it anyway. What you want is a qqnorm plot.
> See ?qqnorm.
Yes qqnorm looks like a better tool for this particular job. It does not
appear to be very general in the sense that you could visually inspect
whether poissson distributed data conforms to a theoretical poisson
I guess this leads to two more questions:
1. Is the Anderson-Darling goodness-of-fit test the recommended analytic
test for determining whether a normal distribution conforms to a theoretical
2. Does R have a suite of "best-fit" tools for finding the best
fitting-probability distribution for any observed probability distribution?
More information about the R-help