Skip to contents

This function calculates the cumulative distribution function (CDF) of the difference between two independent t-distributed random variables using the Welch-Satterthwaite approximation. Specifically, it computes P(T1 - T2 > q) where T1 and T2 follow t-distributions with potentially different degrees of freedom and scale parameters.

Usage

pWSdifft(q, mu.t1, mu.t2, sd.t1, sd.t2, nu.t1, nu.t2)

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 value representing P(T1 - T2 > q), the probability that the difference between the two t-distributed variables exceeds the quantile q.

Details

The Welch-Satterthwaite approximation is used to approximate the distribution of the difference between two t-distributed variables. The method involves:

  • Calculating the effective degrees of freedom using the Welch-Satterthwaite formula: $$\nu^* = \frac{(s_1^2 + s_2^2)^2}{\frac{s_1^4}{\nu_1} + \frac{s_2^4}{\nu_2}}$$

  • Using a single t-distribution with adjusted parameters to approximate the difference

  • Computing the standardized quantile and applying the t-distribution CDF

This approximation is particularly useful for unequal variances and degrees of freedom, providing a computationally efficient alternative to exact convolution methods.

Examples

# Calculate P(t1 - t2 > 3) for equal parameters
pWSdifft(q = 3, mu.t1 = 2, mu.t2 = 0, sd.t1 = 1, sd.t2 = 1, nu.t1 = 17, nu.t2 = 17)
#> [1] 0.2421594

# Calculate P(t1 - t2 > 1) for unequal variances
pWSdifft(q = 1, mu.t1 = 5, mu.t2 = 3, sd.t1 = 2, sd.t2 = 1.5, nu.t1 = 10, nu.t2 = 15)
#> [1] 0.6533185

# Calculate P(t1 - t2 > 0) for different degrees of freedom
pWSdifft(q = 0, mu.t1 = 1, mu.t2 = 1, sd.t1 = 1, sd.t2 = 1, nu.t1 = 5, nu.t2 = 20)
#> [1] 0.5