1.12 Statistical tables in R


Statistical table functions in R can be used to find p-values for test statistics. See Section 24, User Defined Functions, for an example of creating a function to directly give a two-tailed p-value from a t-statistic.

The standard normal (z) distribution

The pnorm( ) function gives the area, or probability, below a z-value:

> pnorm(1.96)

[1] 0.9750021

To find a two-tailed area (corresponding to a 2-tailed p-value) for a positive z-value:

> 2*(1-pnorm(1.96))

[1] 0.04999579

The qnorm( ) function gives critical z-values corresponding to a given lower-tailed area:

> qnorm(.05)

[1] -1.644854

To find a critical value for a two-tailed 95% confidence interval:

> qnorm(1-.05/2)

[1] 1.959964

The t distribution

The pt( ) function gives the area, or probability, below a t-value. For example, the area below t=2.50 with 25 d.f. is

> pt(2.50,25)

[1] 0.9903284

To find a two-tailed p-value for a positive t-value:

> 2*(1-pt(2.50,25))

[1] 0.01934313

The qt( ) function gives critical t-values corresponding to a given lower-tailed area:

> qt(.05,25)

[1] -1.708141

To find the critical t-value for a 95% confidence interval with 25 degrees freedom:

> qt(1-.05/2,25)

[1] 2.059539

The chi-square distribution

The pchisq( ) function gives the lower tail area for a chi-square value:

> pchisq(3.84,1)

[1] 0.9499565

For the chi-square test, we are usually interested in upper-tail areas as p-values. To find the p-value corresponding to a chi-square value of 4.50 with 1 d.f.:

> 1-pchisq(4.50,1)

[1] 0.03389485