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?
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It only takes a minute to sign up.
Sign up to join this communityI 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?
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
...