# Similar Function to Excel's T.Dist.2T()

**URL:** <https://discourse.julialang.org/t/similar-function-to-excels-t-dist-2t/123514>\
**Category:** Statistics\
**Created:** [December 5, 2024, 7:41pm UTC](https://discourse.julialang.org/t/similar-function-to-excels-t-dist-2t/123514 "2024-12-05T19:41:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SergeantMike67](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergeantmike67/32/25103_2.png) [@SergeantMike67](https://discourse.julialang.org/u/SergeantMike67)\
**Post date:** [December 5, 2024, 7:41pm UTC](https://discourse.julialang.org/t/similar-function-to-excels-t-dist-2t/123514/1 "2024-12-05T19:41:44Z")

</div>

Seems straight forward but how would I get a p value if I have calculated the test statistic and have the degrees of freedom.

This example uses the method in Zar(1996) for comparing regression equations (Chapter 17)

the formula for the t-statistic is

`t = (b1-b2) / (sb1-sb2)`

where b1 and b2 is the calculated coefficient of two different lines here the values are:  
b1=1.353712741  
b2 = 1.249425897

and the errors for those coefficients are:  
sb1 = 0.32542874  
sb2 = 0.197671413

Using the formula for the t-statistic I get an answer of:  
t = 8.480670589

alpha = 0.05  
d.f.= 17

Essentially what I am looking for is a similar function to T.Dist.2T(test statistic, degrees of freedom) in Excel.

---

<div class="post-metadata">

**Author:** ![nateybear](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nateybear/32/20645_2.png) [@nateybear](https://discourse.julialang.org/u/nateybear)\
**Post date:** [December 5, 2024, 8:10pm UTC](https://discourse.julialang.org/t/similar-function-to-excels-t-dist-2t/123514/2 "2024-12-05T20:10:03Z")

</div>

The `Distributions` package has a T distribution that you can use:

```julia
using Distributions

2 * ccdf(TDist(df), abs(t_value))

```

---

<div class="post-metadata">

**Author:** ![SergeantMike67](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergeantmike67/32/25103_2.png) [@SergeantMike67](https://discourse.julialang.org/u/SergeantMike67)\
**Post date:** [December 5, 2024, 8:21pm UTC](https://discourse.julialang.org/t/similar-function-to-excels-t-dist-2t/123514/3 "2024-12-05T20:21:35Z")

</div>

Thank you but what is ccdf and where does that come from?

---

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [December 5, 2024, 8:28pm UTC](https://discourse.julialang.org/t/similar-function-to-excels-t-dist-2t/123514/4 "2024-12-05T20:28:15Z")

</div>

From an Excel page:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/e/ce7a53cd691c0fda3e55dd65a5eb46ce9767a021.png)

With Julia:

```julia
julia> using Distributions
julia> 2*ccdf(TDist(60),1.959999998)
0.054644929975920895

```

The `ccdf` is the complementary cumulative distribution function defined in the `Distributions.jl` package for the given distribution, which is `TDist(60)` or the T-distribution with 60 degrees of freedom.

---

<div class="post-metadata">

**Author:** ![SergeantMike67](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sergeantmike67/32/25103_2.png) [@SergeantMike67](https://discourse.julialang.org/u/SergeantMike67)\
**Post date:** [December 5, 2024, 9:09pm UTC](https://discourse.julialang.org/t/similar-function-to-excels-t-dist-2t/123514/5 "2024-12-05T21:09:27Z")

</div>

I see that in the univariate distributions page now. Never would have thought to look for it there.

Thank you so much
