Erdogan CEVHER - 3 months ago 29

R Question

I want to find the F value (of a one(right)-tailed distribution) that will correspond to p=0.05 given pre-specified two degrees of freedom (1 and 29 below). I do this by trial and error:

`#..F values..............p values...`

1-pf(4.75, 1, 29) # 0.03756451

1-pf(4.15, 1, 29) # 0.05085273

1-pf(4.18295, 1, 29) # 0.05000037

1-pf(4.18297, 1, 29) # 0.04999985

1-pf(4.18296, 1, 29) # 0.05000011

So, I want to obtain F=4.18296 without trial and error. Any idea?

Answer

There are two possibilities to achieve such result, we need to use the quantile function:

`qf(1 - 0.05, 1, 29)`

or `qf(0.05, 1, 29, lower.tail = FALSE)`

```
qf(1 - 0.05, 1, 29)
# [1] 4.182964
qf(0.05, 1, 29, lower.tail = FALSE)
# [1] 4.182964
1 - pf(4.182964, 1, 29)
# [1] 0.05000001
```

The first option takes into account that the default option of `lower.tail`

is equal to `TRUE`

so we have to use 1 - 0.05

For the second option, we specify that we want P[X > x] using `lower.tail = FALSE`