1 Introduction

R has a set of statistical lookup functions for test of significance etc. The Annexes of the old statistics books are no longer necessary once these functions are mastered. However, that can be more difficult than it sounds. This vignette was written to help with pnorm, the R function to supply p-values.

2 qnorm

Before going into pnorm, it is useful to review the related function qnorm. qnorm returns quantile or the level of significance for any value. It can be thought of as a distance on the horizontal axis of the normal curve. If we enter 0.975 into qnorm, it will return the 1.96. If we take the area plus or minus 1.96 quantiles from the mean, it will include 95 percent of the area of the normal curve.

library(stats)
qnorm(0.975)
## [1] 1.959964

Here we see value of z for a test of significance for a one-tailed test. This would allow the construction a two tailed 95 percent confidence interval.

3 pnorm

Now suppose an estimation procedure had produced 1.95, how could it be determined that the pvalue has been 0.05? The pnorm function was designed to perform this role. It will return a value between 0 and 1. This represents the area under the standardized normal curve to the left of the value.

pnorm(1.959964)
## [1] 0.975
2*(1- pnorm(1.959964))
## [1] 0.05

On a more practical level, if there was a question concerning what is the probability that a random value is larger than observed ration of the estimate of the standard error, how would we do this?

3.1 More Detailed Look at pnorm

First, if we look at the function in more detail, it is noted that both a mean and a standard error can be added. In the above example, these were not supplied and were assumed to be 0 and 1. Thus if someone supplied a value of 1.95, it would be seen as well away from the mean and would have .025 of the area under the curve. If a value of zero had been supplied then 0.5 would be returned.

This is a more specialized case of the wiki definition of a p-value

  • In null hypothesis significance testing, the p-value is the probability of obtaining test results at least as extreme as the results actually observed*
# return half of curve
pnorm(1,1,1)
## [1] 0.5

Now with a more realistic example, suppose we were supplied a statistical effect of 5 percent that has a standard error of 0.03. If we ask for the mean back we still get half of the curve.

# estimated mean and standard error
meanHat = 0.05
seHat = 0.03
pnorm(0.05,meanHat,seHat)
## [1] 0.5

However, if we provide a quantile of mean divided by the standard error.

pnorm(meanHat/seHat,meanHat/seHat,seHat)
## [1] 0.5