# Using R to calculate qt (t-dist) using qf(f dist) help?

I am having quite some trouble using R to calculate, say, qt(0.975,6) using qf instead of qt. I know the relationship between the t-distribution and the f-distribution which I understand as follows:

// the $t^2$ $=$ $F(1,p)$ meaning that the $t^2$ distribution is basically the $F$ distribution with $1$ degrees of freedom in the numerator and $p$ degrees of freedom in the denominator.

But how would I apply this knowledge using R?

I have a similar problem with using $F$ distribution to calculate $chi squared$ and I understand that relationship to be as follows:

// two independent $chi squared$ distributions between divided by each other with degrees of freedom $p$ in the numerator and $q$ in the denominator we get an $F(p,q)$.

How would I utilize what I know here however, to do that in R?

Thanks so much for the help, in advance! :)

• Solve the problem first, write the code second. If this is a programming question, describe algorithm you want to implement (and post it on StackOverflow instead). If this is a statistics question, leave programming out of it (at least in the beginning). Otherwise you end up confusing the two when they are really very different things. – shadowtalker Sep 26 '14 at 17:29
• I'm betting that the piece you are missing is the fact that both the positive and negative tails of $t$ go into the positive tail of $F$. Thus, if each tail of the $t$ has an area of, say, $.10$, then the upper tail area of $F=t^2$ is $2\times.10=.20$. If you're dealing with quantiles, of course, you need to think this in reverse. – rvl Sep 26 '14 at 17:45

## 1 Answer

As indicated by @rvl, you want to be sure that you are taking into consideration that F is always two tailed. If you do this by changing the quantile you request from the F ditribution to be .95 relative to the one tailed t of .975, you'll get the expected result: all.equal(sqrt(qf(0.95,1,6)),qt(.975,6)).

In regards to $\chi^2$ ... I just don't know. See @Aniko's comment below as a possible explaination as to why this isn't turning out quite like you might expect.

• +1 for the first part of your answer, but the second part is confused. The ratio of the two chi-squared variables is always F, but it does not follow that the ratio of any given quantiles is the quantile of the ratio. – Aniko Sep 26 '14 at 19:12
• I am certainly more than a bit confused about the second part, even with your comment in hand. Which two $\chi^2$ variables would one be talking about in regards to the equation mentioned by the asker? – russellpierce Sep 26 '14 at 19:51
• My apologies but why do we change our significance level from 0.975 to 0.95 again? Because F-dist is two tailed? – nicefella Sep 26 '14 at 20:19
• The $t$ distribution is two tailed. The $F$ distribution also technically has two-tails. One tail stretches to $\inf$ and the other ends at 0. Typically we care about the upper tail because it reflects higher variance than expected. However, unlike $t$, $F$ is blind to whether one specific mean is higher or lower than another specific mean, it just knows about squared differences (variances). As a negative variance is non-nonsensical, so too are negative values of $F$. – russellpierce Sep 26 '14 at 20:53