Reputation: 815
I have asked this question elsewhere
I want to verify if my data follows a normal or any other type of distribution (like cauchy for example).
I really want to understand how to use qqplot
=]
Even though the qqnorm
works well:
qqnorm(data);qqline(data)
When I try the qqplot
:
qqplot(data, "normal")
qqplot(data, "cauchy")
it generates an error:
Error in plot.window(...) : valores finitos são necessários para 'ylim'
In addition it creates the warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
Upvotes: 1
Views: 2215
Reputation: 42090
You should read the documentation for qqplot
. The second argument to qqplot
should be another data vector, not a string. If you want to compare your data to a specific distribution, you can follow the technique used in qqnorm
and generate a vector of quantiles for any distribution. Let's say x is the data we want to plot:
x <- rcauchy(5000)
Since x has 5000 elements, we want to generate 5000 evenly-spaced quantiles from our target distribution. First, let's try the normal distribution:
y.norm <- qnorm(ppoints(length(x)))
qqplot(x, y.norm)
Now let's try the same thing with the Cauchy distribution.
y.cauchy <- qcauchy(ppoints(length(x)))
qqplot(x, y.cauchy)
(Note that the Cauchy distribution in particular will not behave very well in QQ plots, so this may not actually help you with your real goal.)
Upvotes: 2