3
$\begingroup$

I have some data (a set of numbers) and I want to compare them with the normal distribution using QQ-plot. The only statistical tool that I am aware of is Octave but Octave doesn't draw the reference line.

enter image description here

As can be seen in the above picture the x-axis has a range from - 3 to 3 but the y-axis has a range from 20 to 140. I think drawing a 45 degree slope line would be wrong.

How can I draw such a reference line in Octave? Or does there exist any easy tool that would draw a QQ-plot with that reference line?

$\endgroup$
3
$\begingroup$

This is easy in R:

x <- rnorm(1000, 100, 10)  #Creates some data; this has is normal with mean 100 sd 10
qqnorm(x)         #qq
qqline(x)         #adds line
| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks alot :) , .. in one of my number sets the reference line was horizontal is that ok ? $\endgroup$ – Ahmed Kotb Mar 18 '12 at 20:07
  • $\begingroup$ I think that's a problem $\endgroup$ – Peter Flom Mar 18 '12 at 20:08
  • $\begingroup$ a problem in the integers (that they don't follow the normal dist) OR a problem in drawing them ? $\endgroup$ – Ahmed Kotb Mar 18 '12 at 20:23
  • $\begingroup$ It's OK that they aren't normal (that's part of the reason to use a qq plot). A horizontal line though.... what are your data? $\endgroup$ – Peter Flom Mar 18 '12 at 20:39
  • $\begingroup$ just a bunch of numbers that are very close to each other dl.dropbox.com/u/8045913/faculty_stuff/tcp_wired_lan_client.txt $\endgroup$ – Ahmed Kotb Mar 18 '12 at 20:46
5
$\begingroup$

Here is one possible Octave solution to your question: (largely inspired from the corresponding Matlab function)

randn("state",255)
x = normrnd(10, 2, 200, 1);
[q, s] = qqplot(x);

% compute the y=x line
dx = prctile(q, 75) - prctile(q, 25);
dy = prctile(s, 75) - prctile(s, 25);
b = dy./dx;                                % slope
xc = (prctile(q, 25) + prctile(q, 75))/2;  % center points
yc = (prctile(s, 25) + prctile(s, 75))/2;  % ...
ymax = yc + b.*(max(q)-xc);
ymin = yc - b.*(xc-min(q));

plot(q, s, "Linestyle", "none", "Marker", "+")
line([min(q); max(q)], [ymin; ymax])

enter image description here

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.