An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120217/a550a80f/attachment.pl>
QQ plot
4 messages · nandan amar, Rolf Turner
On 17/02/12 21:32, nandan amar wrote:
Hello, I am having two data set original and predicted. I want to dind QQ-plot fot it. I tried in following manner :
qq(original~predicted)
and error was : Error in qq.formula(o ~ p) : y must have exactly 2 levels There is an option "qtype" which dosent make any difference. What is the correct way for plotting QQ-plot or am I missing something.
To start with, you are missing telling us that the function qq() is
from the *lattice* package.
Secondly you are missing reading the error message. What
does it *say*? Think about it.
It says that (rather strangely, it seems to me) that the left hand
side of the formula must be a factor with two levels. Obviously
then you must combine your observations into a single vector
and create a factor indicating to which of the two samples each
entry of that vector belongs. Something like:
y <- c(original,predicted)
f <- factor(rep(c("o","p"),c(length(original),length(predicted))))
require(lattice)
print(qq(f ~ y))
Alternatively you could save hassle and use base graphics:
qqplot(original,predicted)
cheers,
Rolf Turner
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120217/9ff40c78/attachment.pl>
On 18/02/12 00:15, nandan amar wrote:
Thanks a lot Turner. Latter I also tried following : oo<-quantile(original, probs = seq(0, 1, 0.01), type = 8) pp<-quantile(predicted, probs = seq(0, 1, 0.01), type = 8) plot(oo,pp) But plot for above and following (as you suggested) are not same. What may be the error ?
The error is that you didn't look at the code of qqplot() to see what
it's actually doing. (Type: "qqplot" without the quote marks.)
It's not doing what you did, so naturally the results are different.
I have not the time nor the inclination to think through the implications
of what you did and what qqplot() does in respect of the information
content of the two approaches. I suspect that they will usually, if not
always, give *similar* results.
cheers,
Rolf Turner