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

______________________________________________
R-help@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.

Reply via email to