Re: [R] Quantiles and QQ plots

From: <Bill.Venables_at_csiro.au>
Date: Sat, 1 Dec 2007 16:54:09 +1000

 

-----Original Message-----
From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] On Behalf Of alfieim29
Sent: Saturday, 1 December 2007 9:26 AM
To: r-help_at_r-project.org
Subject: [R] Quantiles and QQ plots

I have 20 variables:

5,9,6,1,5,9,7,4,5,6,3,2,4,8,9,6,1,8,4,8

[WNV] I think you have 20 values, not variables.

How do I calculate the corresponding quantiles from a normal distribution
with the same mean and variance as the sample?

[WNV] There is some ambiguity about this, but a simple way to do it
would be

x <- c(5,9,6,1,5,9,7,4,5,6,3,2,4,8,9,6,1,8,4,8)
n <- length(x)
p <- (1:n - 0.5)/n
z <- qnorm(p, mean(x), sd(x))[order(order(x))]




Also, how do I draw a QQ plot of the data?

[WNV] having done all this you can now just

plot(z, x)

but a much simpler way is

qqnorm(x)
qqline(x)

and don't bother calculating all that stuff!

Thanks for any help!

-- 
View this message in context:
http://www.nabble.com/Quantiles-and-QQ-plots-tf4925742.html#a14097909
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

______________________________________________
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.
Received on Sat 01 Dec 2007 - 07:01:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 01 Dec 2007 - 09:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.