# Finding percentage points in R

We'll often want to find percentage points of distributions. Let Z be a standard normal r.v. (i.e. normal with mean zero and variance 1). Then the upper P% point is defined to be the value Z(P%) such that
P[Z > Z(P%)] = P/100.

For example, the upper 5% point of Z is the value Z(5%) = 1.645 (3dp) since
P[Z > 1.645] = 0.05.

(Note that we have to convert back and forth between probabilities and percentages.)

We will denote other percentage points by the name of the distribution (so, t, χ2 or F) with ``degrees of freedom'' parameters given as subscripts and the percentage value given in brackets. So the upper 1% point of a t distribution with 3 degrees of freedom is denoted by t3(1%) and so on.

We get percentage points either from statistical tables (like those on handout 1) or using `R`. For example, from handout 1 we can find the following:

• t3(1%) = 4.541
• t40(1%) = 2.423
• t45(1%) ≈ 2.413
• F4, 5(5%) = 5.192
(Note t45(1%) is approximate as it is estimated from t40(1%) = 2.423 and t50(1%) = 2.403 -- the value we want is not in the tables, so we interpolate.)

In `R`, the commands `qnorm, qchisq, qt`, and `qf` will get percentage points of the normal, χ2, t, and F distributions respectively. For example, we can get the percentage points given above, and some others, as follows.

```> qt(0.01, df=3, lower.tail=F)
[1] 4.540703
> qt(0.01, df=40, lower.tail=F)
[1] 2.423257
> qt(0.01, df=45, lower.tail=F)
[1] 2.412116
> qf(0.1, df1 = 4, df2 = 5, lower.tail = F)
[1] 3.520196
> qf(0.05, df1 = 4, df2 = 5, lower.tail = F)
[1] 5.192168
> qf(0.01, df1 = 4, df2 = 5, lower.tail = F)
[1] 11.39193
```
The following are some examples of getting percentage points of the normal distribution from `R`.
```> qnorm(0.05, lower.tail = F)
[1] 1.644854
> qnorm(0.05, mean = 0, sd = 1, lower.tail = F)
[1] 1.644854
> qnorm(0.05, mean = 0, sd = 1)
[1] -1.644854
```
Note that we supply the probability P/100 rather than P and then supply parameters of the distribution. We have to tell `R` that we are interested in upper percentage points, otherwise it assumes we are after lower percentage points --- that is what has happened with the last `R` command above.