[R] Overlaying graphs

Paul Meagher paul at datavore.com
Thu Sep 4 17:45:50 CEST 2003


From: "Spencer Graves" <spencer.graves at PDF.COM>

>   Your observation that qqnorm "does not appear to be very general" is
> rebutted by Venables and Ripley (2002) Modern Applied Statistics with S,
> 4th ed. (Springer, p.108):  "One of the best ways to compare the
> distribution of a sample x with a distribution is to use a Q-Q plot. ...
> This idea can be applied quite generally.  For example, to test a sample
> against a t9 distribution, we might use
>
>   plot( qt(ppoints(x), 9), sort(x) )

Thanks for enlightening me on this issue.  I will look into the generaltiy
of the Q-Q plot further.  I only have a copy of MASS(1994) available.

>   Before I consider the "best-fitting probability distribution", I want
> to know something about the nature of the application and what the
> numbers claim to represent:  { lots of useful rules-of-thumb snipped }

As I am sure you are aware it is possible to buy canned software that is
supposed to find the best fitting theoretical distribution for your data.
My sense is that the "R Way", if there is one,  is to advocate a mixture of
exploratory data analysis, knowledge about the random variable being
studied, and various statistical tests to confirm hypothesis generated from
EDA and prior knowledge.   My hidden agenda was really to find out if people
on this list think that you can "can" the process of finding the best
fitting theoretical distribution for your data, and if so, what that
"canned" process consists of.

My limited experience with seeing Palisade's best-fit software was that it
suggested a gamma distribution as the best fit.  I thought that this
probabily isn't that helpful because the gamma distribution has so many
parameters that it would likely show up at the top of the list of best
candidates in most cases.  It probably is useful, however, to have a tool
that will generate estimates of your distribution parameters and do some
perfunctory goodness-of-fit testing to rule out certain probability
distributions as candidates.

Regards,
Paul Meagher

> hope this helps.  spencer graves
>
> Paul Meagher wrote:
> > 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)
> > par (fin=c(4,4))
> > 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
> >
> > direction
> >
> >>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
> > distribution.
> >
> > 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
> > normal distribution.
> >
> > 2. Does R have a suite of "best-fit" tools for finding the best
> > fitting-probability distribution for any observed probability
distribution?
> >
> > Regards,
> > Paul Meagher
> >
> >
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
>
>




More information about the R-help mailing list