3
$\begingroup$

The help for the pnorm function states:

It says that pnorm gives the "distribution function", but it seems that it gives the quantile,

for example, pnorm(q = 0, 0, 1) returns 0.5, which suggests that q=0 refers to the 50th quantile of a N(0,1). I understand what the "normal probability density function" is, but not why pnorm is called a 'distribution function'.

The R help says that the q argument is a "vector of quantiles", but it appears in practice that q represents an observed value.

What I want to know is, if I observe '2', what does pnorm(2) say about my assumption that it came from a N(0,1) distribution?

$\endgroup$
  • 2
    $\begingroup$ Not all distributions have a density function. All of them have a cumulative distribution function (CDF), which thereby deserves to be called "distribution function." Everything else can be derived from it. In particular, its inverse is the quantile function. $\endgroup$ – whuber Jun 29 '12 at 20:48
  • 6
    $\begingroup$ The statement "R help says that the q argument is a vector of probabilities ..." is incorrect. The documentation under ?pnorm clearly says that the argument q is a vector of quantiles. $\endgroup$ – atiretoo Jun 30 '12 at 21:28
  • $\begingroup$ @gung I have made the fix. $\endgroup$ – Abe Jul 6 '12 at 20:18
  • $\begingroup$ @atiretoo I have fixed this typo, but I am still confused about why pnorm(q=2) would work if q is a quantile. $\endgroup$ – Abe Jul 6 '12 at 20:19
  • 1
    $\begingroup$ A percentile is a value of a variable corresponding to a certain percent (which is a value of the cumulative distribution function). Thus the q=2 in an expression like pnorm(q=2) refers to a value of a standard normal distribution. The result, 0.977 = 97.7%, says that 97.7% of a normal distribution lies at or below $2$. $\endgroup$ – whuber Jul 6 '12 at 20:48
5
$\begingroup$

pnorm is giving you the cumulative probability distribution at a specified value of $x$. This is the cumulative probability for a standard normal distribution. So in your example the quantity I call $x$ is specified as $0$ and $0.5$ as the answer is $P[X\leq 0]$ for a random variable $X$ with a $N(0,1)$ distribution.If you took $x=1.96$ you would get $0.975$ because a standard normal distribution has probability $0.025$ in the upper right tail above $1.96$.

$\endgroup$
  • 1
    $\begingroup$ So, if I want to calculate the two-tailed probability of observing x from a standard normal, it would be ifelse(pnorm(x) > 0.5, 2*(1-pnorm(x)), 2*pnorm(x))? I was hoping for something a little more straight forward; perhaps that there is another base function for that. $\endgroup$ – Abe Jun 29 '12 at 21:09
  • 2
    $\begingroup$ Michael: your 2*(1-pnorm(x)) only makes sense for non-negative $x$ $\endgroup$ – Henry Jun 29 '12 at 22:47
  • 2
    $\begingroup$ as @Henry points out, it should be 2*(1-pnorm(abs(x))) or 2*pnorm(-abs(x)) $\endgroup$ – Macro Jun 29 '12 at 22:50
  • 2
    $\begingroup$ Or 2*pnorm(abs(x),lower=FALSE) ... all of these come up with the same answer. The answer by @Abe is less efficient because it calls pnorm 3 times to get the same result. I wonder if the OP regards 'the two tailed probability of observing abs(x) or greater as the answer to "what does pnorm(2) say about my assumption ..."? A strict answer to the question as posed is nothing. $\endgroup$ – atiretoo Jun 30 '12 at 21:35
  • 1
    $\begingroup$ @Macro: Your second version should be much, much more accurate if the absolute value of $x$ is of any appreciable size. $\endgroup$ – cardinal Jul 2 '12 at 18:14

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.