I am a beginner in R, so please don't step on me if this is too simple. I have two data sets datax and datay for which I created a qqplot qqplot(datax,datay) but now I want a line that indicates the perfect match so that I can see how much the plot diverts from the ideal. This ideal however is not normal, so I think qqnorm and qqline cannot be applied. Perhaps you can help? Ralf
You are going to have to define the question a little better. Also, please provide a reproducible example. On Thu, Jun 24, 2010 at 4:44 PM, Ralf B <ralf.bierig at gmail.com> wrote:> I am a beginner in R, so please don't step on me if this is too > simple. I have two data sets datax and datay for which I created a > qqplot > > qqplot(datax,datay) > > but now I want a line that indicates the perfect match so that I can > see how much the plot diverts from the ideal. This ideal however is > not normal, so I think qqnorm and qqline cannot be applied. > > Perhaps you can help? > > Ralf > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Stephen Sefick ____________________________________ | Auburn University | | Department of Biological Sciences | | 331 Funchess Hall | | Auburn, Alabama | | 36849 | |___________________________________| | sas0025 at auburn.edu | | http://www.auburn.edu/~sas0025 | |___________________________________| Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
The line for the perfect match would be abline(0,1) if you want to allow affine transformations, then it gets a bit harder. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Ralf B > Sent: Thursday, June 24, 2010 3:45 PM > To: r-help at r-project.org > Subject: [R] Simple qqplot question > > I am a beginner in R, so please don't step on me if this is too > simple. I have two data sets datax and datay for which I created a > qqplot > > qqplot(datax,datay) > > but now I want a line that indicates the perfect match so that I can > see how much the plot diverts from the ideal. This ideal however is > not normal, so I think qqnorm and qqline cannot be applied. > > Perhaps you can help? > > Ralf > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code.
?qqplot ## note the "Value" section ?abline z <- qqplot(datax,datay) abline(reg=lm(z$y ~ z$x)) As the help for abline says, you can fit any line you like, perhaps a simple resistant one would be better as in ?line, in which case use abline(reg= line(z$x, z$y)) ## note x's and y's are reversed from previous Cheers, Bert Gunter Nonclinical Biostatistics 467-7374 http://devo.gene.com/groups/devo/depts/ncb/home.shtml -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Ralf B Sent: Thursday, June 24, 2010 2:45 PM To: r-help at r-project.org Subject: [R] Simple qqplot question I am a beginner in R, so please don't step on me if this is too simple. I have two data sets datax and datay for which I created a qqplot qqplot(datax,datay) but now I want a line that indicates the perfect match so that I can see how much the plot diverts from the ideal. This ideal however is not normal, so I think qqnorm and qqline cannot be applied. Perhaps you can help? Ralf ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Sorry, missed the two variable thing. Go with the lm solution then, and you can tweak the plot yourself (the confidence intervals are easily obtained via predict(lm.object, interval="prediction") ). The function qq.plot uses robust regression, but in your case normal regression will do. Regarding the shapes : this just indicates both tails are shorter than expected, so you have a kurtosis greater than 3 (or positive, depending whether you do the correction or not) Cheers Joris On Fri, Jun 25, 2010 at 4:10 AM, Ralf B <ralf.bierig at gmail.com> wrote:> Short rep: I have two distributions, data and data2; each build from > about 3 million data points; they appear similar when looking at > densities and histograms. I plotted qqplots for further eye-balling: > > qqplot(data, data2, xlab = "1", ylab = "2") > > and get an almost perfect diagonal line which means they are in fact > very alike. Now I tried to check normality using qqnorm -- and I think > I am doing something wrong here: > > qqnorm(data, main = "Q-Q normality plot for 1") > qqnorm(data2, main = "Q-Q normality plot for 2") > > I am getting perfect S-shaped curves (??) for both distributions. Am I > something missing here? > > | > | ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? * ?* ? * ?* > | ? ? ? ? ? ? ? ? ? ? ? ? ? * > | ? ? ? ? ? ? ? ? ? ? ? ?* > | ? ? ? ? ? ? ? ? ? ?* > | ? ? ? ? ? ? ? * > | ? ? ? ? ? ?* > | ? ? ? ? * > | * * * > |--------------------------------------------- > > Thanks, Ralf >-- Joris Meys Statistical consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control tel : +32 9 264 59 87 Joris.Meys at Ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php