0

I use the qqnorm function to calculate normal scores in R:

x <- 1:10
y <- qqnorm(x)$x

How are these kind of normal scores calculated?

Glen_b
  • 257,508
  • 32
  • 553
  • 939
user28725
  • 35
  • 3
  • You would be better on an R-specific site. You could also try reading the documentation for qqnorm right to the end which gives you a clue. – mdewey Mar 08 '17 at 10:28
  • As well as the indicated duplicate, additional details are discussed [here](http://stats.stackexchange.com/questions/96042/regression-how-do-i-know-if-my-residuals-are-normally-distributed). – Glen_b Mar 08 '17 at 16:53

1 Answers1

1

You can look at the exact calculation used by functions in R by combing a number of calls. You can follow some easy steps to "get at" most. This is outlined below, with skipped code lines (for brevity) indicated with ... on their own lines.

First, try to call up the function without parentheses, as such: qqnorm. This yields the following:

> qqnorm
function (y, ...) 
UseMethod("qqnorm")
<bytecode: 0x00000000094f9250>
<environment: namespace:stats>

This tells us that qqnorm uses a method. To look at what methods are available, we can use methods().

> methods(qqnorm)
[1] qqnorm.default*
see '?methods' for accessing help and source code

Having identified the method, we can then use getAnywhere() to examine the source code.

> getAnywhere(qqnorm.default)
A single object matching ‘qqnorm.default’ was found
It was found in the following places
  registered S3 method for qqnorm from namespace stats
  namespace:stats
with value

function (y, ylim, main = "Normal Q-Q Plot", xlab = "Theoretical Quantiles", 
    ylab = "Sample Quantiles", plot.it = TRUE, datax = FALSE, 
    ...) 
{
    if (has.na <- any(ina <- is.na(y))) {
        yN <- y
...
Alex Firsov
  • 370
  • 1
  • 12