1
votes

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

1
Please remember to dput() your sample data. Also cross-posting is actually not allowed.Hack-R
I'm voting to close this question as off-topic because it's cross-posted at CrossValidatedHack-R
I don't think this should be closed. This is a programming question with a well-defined answer, and the CV folks kind of implicitly sent the asker here by indicating that programming questions were off-topic for CV. Whether the answer to the programming question will help with the underlying statistical analysis is another matter.Ryan C. Thompson
If anything, it's the CV question that should be closed.Hong Ooi

1 Answers

2
votes

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