Cumulative Distribution Function of the Difference of Two t-Distributed Variables by Numerical Integration
Source:R/pNIdifft.R
pNIdifft.Rd
This function calculates the cumulative distribution function (CDF) of the difference between two independent t-distributed random variables using numerical integration via convolution. Specifically, it computes P(T1 - T2 ≥ q) where T1 and T2 follow t-distributions with potentially different location, scale, and degrees of freedom parameters.
Arguments
- q
A numeric value representing the quantile threshold.
- mu.t1
A numeric value representing the location parameter of the first t-distribution.
- mu.t2
A numeric value representing the location parameter of the second t-distribution.
- sd.t1
A positive numeric value representing the scale parameter of the first t-distribution.
- sd.t2
A positive numeric value representing the scale parameter of the second t-distribution.
- nu.t1
A positive numeric value representing the degrees of freedom of the first t-distribution.
- nu.t2
A positive numeric value representing the degrees of freedom of the second t-distribution.
Value
A numeric vector representing P(T1 - T2 ≥ q), the probability that the difference between the two t-distributed variables is greater than or equal to the quantile q.
Details
This function uses the exact convolution approach to compute the distribution of the difference between two t-distributed variables. The method involves:
Using the convolution formula: $$P(T_1 - T_2 ≥ q) = \int_{-\infty}^{\infty} f_1(x) \cdot F_2(x - q) dx$$
Where \(f_1(x)\) is the PDF of the first t-distribution
And \(F_2(x - q)\) is the CDF of the second t-distribution evaluated at \(x - q\)
Adaptive integration bounds based on the distribution characteristics
High-precision numerical integration with specified tolerances
This approach provides exact results (within numerical precision) but is more computationally intensive than approximation methods like Welch-Satterthwaite.
Examples
# Calculate P(t1 - t2 ≥ 3) for equal parameters
pNIdifft(q = 3, mu.t1 = 2, mu.t2 = 0, sd.t1 = 1, sd.t2 = 1, nu.t1 = 17, nu.t2 = 17)
#> [1] 0.24857
# Calculate P(t1 - t2 ≥ 1) for unequal variances
pNIdifft(q = 1, mu.t1 = 5, mu.t2 = 3, sd.t1 = 2, sd.t2 = 1.5, nu.t1 = 10, nu.t2 = 15)
#> [1] 0.6478101