I would like to find the t-value
for 90% confidence interval with 17 observation.
In Excel, I can do this calculation with t=T.INV.2T(.10, 16)=1.75
however in R I cannot find the correct way to get the same result.
qt(p = 1-.9, df = 17-1) = -1.34
qt(p = (1-.9)/2, df = 17-1) = -1.75 # trying with two-tailed?
What is the function R doing the same computation as T.INV.2T
in Excel.
Similarly, we have also T.DIST.2T
in Excel, what is the same function in R?
You need the 1 - .1 / 2 = 0.95
quantile from the t-distribution with 17 - 1 = 16
degrees of freedom:
qt(0.95, 16)
# [1] 1.745884
Explanation
Excel describes T.INV.2T
as
Returns the two-tailed inverse of the Student's t-distribution
which is the quantile in math talk (though I would never use the term 2 tailed quantile). The p%
quantile q
is defined as the point which satisfies P(X <= q) >= p%
.
In R
we get that with the function qt
(q for quantile, t for t-distribution). Now we just have to sort out what is meant by a two-tailed inverse
. It turns out we are looking for the point q
which satisfies P(X <= -|q| | X >= |q|) >= .1
. Since the t-distribution is symmetrical this simplifies to P(X >= |q|) >= .1 / 2
.
You can easily verify that in R
with the use of the probability function pt
:
pt(qt(0.05, 16), 16, lower.tail = TRUE) +
pt(qt(0.95, 16), 16, lower.tail = FALSE)
# [1] 0.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With