| Title: | Welch-Satterthwaite Approximation for t-Distribution Differences |
|---|---|
| Description: | Implements the Welch-Satterthwaite approximation for differences of non-standardized t-distributed random variables in both univariate and multivariate settings. The package provides methods for computing effective degrees of freedom and scale parameters, as well as distribution functions for the approximated difference distribution. The methodology extends the classical Welch-Satterthwaite framework from variance combinations to t-distribution differences through careful moment matching. Methods build on the classical Welch-Satterthwaite approach described in Welch (1947) <doi:10.1093/biomet/34.1-2.28> and Satterthwaite (1946) <doi:10.2307/3002019>. |
| Authors: | Yusuke Yamaguchi [aut, cre] |
| Maintainer: | Yusuke Yamaguchi <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-05-18 09:53:40 UTC |
| Source: | https://github.com/cran/wstdiff |
Distribution Functions for Approximated t-Difference
dtdiff(x, ws_result) ptdiff(q, ws_result) qtdiff(p, ws_result) rtdiff(n, ws_result)dtdiff(x, ws_result) ptdiff(q, ws_result) qtdiff(p, ws_result) rtdiff(n, ws_result)
x, q
|
Vector of quantiles |
ws_result |
Result from ws_tdiff_univariate() |
p |
Vector of probabilities |
n |
Number of observations |
For dtdiff: Numeric vector of density values.
For ptdiff: Numeric vector of cumulative probabilities.
For qtdiff: Numeric vector of quantiles.
For rtdiff: Numeric vector of random samples from the approximated
t-difference distribution.
result <- ws_tdiff_univariate(0, 1, 10, 0, 1.5, 15) dtdiff(0, result) ptdiff(0, result) qtdiff(c(0.025, 0.975), result) samples <- rtdiff(100, result)result <- ws_tdiff_univariate(0, 1, 10, 0, 1.5, 15) dtdiff(0, result) ptdiff(0, result) qtdiff(c(0.025, 0.975), result) samples <- rtdiff(100, result)
Validates the approximation quality by comparing moments of the approximated distribution with the theoretical moments.
validate_approximation(ws_result, n_sim = 10000, seed = NULL)validate_approximation(ws_result, n_sim = 10000, seed = NULL)
ws_result |
Result from any ws_tdiff function |
n_sim |
Number of simulations for validation (default: 10000) |
seed |
Random seed for reproducibility |
A list containing validation metrics
result <- ws_tdiff_univariate(0, 1, 10, 0, 1.5, 15) validation <- validate_approximation(result) print(validation)result <- ws_tdiff_univariate(0, 1, 10, 0, 1.5, 15) validation <- validate_approximation(result) print(validation)
Computes the Welch-Satterthwaite approximation for the special case where both distributions have identical parameters.
ws_tdiff_equal_params(mu, sigma, nu)ws_tdiff_equal_params(mu, sigma, nu)
mu |
Common location parameter |
sigma |
Common scale parameter (must be > 0) |
nu |
Common degrees of freedom (must be > 4) |
When X1 ~ t(mu, sigma^2, nu) and X2 ~ t(mu, sigma^2, nu) are independent, the difference Z = X1 - X2 simplifies to:
Location: mu_diff = 0
Scale: sigma_star = sigma * sqrt(2*nu/(nu-2))
Degrees of freedom: nu_star = 2*(nu - 4)
This special case provides validation for the general formulas and computational efficiency when parameters are known to be equal.
An S3 object of class "ws_tdiff_univariate" with the simplified parameters
# Equal parameters case result <- ws_tdiff_equal_params(mu = 0, sigma = 1, nu = 10) print(result) # nu_star should be 2*(10-4) = 12 # Verify against general formula general <- ws_tdiff_univariate(0, 1, 10, 0, 1, 10) all.equal(result$nu_star, general$nu_star)# Equal parameters case result <- ws_tdiff_equal_params(mu = 0, sigma = 1, nu = 10) print(result) # nu_star should be 2*(10-4) = 12 # Verify against general formula general <- ws_tdiff_univariate(0, 1, 10, 0, 1, 10) all.equal(result$nu_star, general$nu_star)
Approximates the distribution of differences between two independent multivariate t-distributed random vectors with arbitrary covariance structure. This implements Theorem 3 from Yamaguchi et al. (2025).
ws_tdiff_multivariate_general( mu1, Sigma1, nu1, mu2, Sigma2, nu2, max_iter = 10, tol = 0.001 )ws_tdiff_multivariate_general( mu1, Sigma1, nu1, mu2, Sigma2, nu2, max_iter = 10, tol = 0.001 )
mu1 |
Location vector of first distribution (length p) |
Sigma1 |
Scale matrix of first distribution (p x p, positive definite) |
nu1 |
Degrees of freedom of first distribution (must be > 4) |
mu2 |
Location vector of second distribution (length p) |
Sigma2 |
Scale matrix of second distribution (p x p, positive definite) |
nu2 |
Degrees of freedom of second distribution (must be > 4) |
max_iter |
Maximum iterations for convergence (default: 10) |
tol |
Convergence tolerance (default: 1e-6) |
This function handles the general case where components may be correlated within each multivariate t-distribution. The approximation uses a single scalar degrees of freedom parameter to capture the overall tail behavior.
The iterative algorithm (Section 4.3 of the paper):
Initialize with sum of covariance matrices
Compute effective degrees of freedom using trace formulas
Update scale matrix
Iterate until convergence
Note: For high dimensions with heterogeneous component behaviors,
consider using ws_tdiff_multivariate_independent instead.
An S3 object of class "ws_tdiff_multivariate_general" containing:
mu_diff |
Location vector of difference |
Sigma_star |
Effective scale matrix |
nu_star |
Effective degrees of freedom (scalar) |
converged |
Logical indicating convergence |
iterations |
Number of iterations performed |
method |
Character string "multivariate_general" |
Sigma1 <- matrix(c(1, 0.3, 0.3, 1), 2, 2) Sigma2 <- matrix(c(1.5, 0.5, 0.5, 1.2), 2, 2) result <- ws_tdiff_multivariate_general( mu1 = c(0, 1), Sigma1 = Sigma1, nu1 = 10, mu2 = c(0, 0), Sigma2 = Sigma2, nu2 = 15 ) print(result)Sigma1 <- matrix(c(1, 0.3, 0.3, 1), 2, 2) Sigma2 <- matrix(c(1.5, 0.5, 0.5, 1.2), 2, 2) result <- ws_tdiff_multivariate_general( mu1 = c(0, 1), Sigma1 = Sigma1, nu1 = 10, mu2 = c(0, 0), Sigma2 = Sigma2, nu2 = 15 ) print(result)
Approximates the distribution of differences between two independent p-dimensional vectors with independent t-distributed components.
ws_tdiff_multivariate_independent(mu1, sigma1, nu1, mu2, sigma2, nu2)ws_tdiff_multivariate_independent(mu1, sigma1, nu1, mu2, sigma2, nu2)
mu1 |
Location vector of first distribution (length p) |
sigma1 |
Scale vector of first distribution (length p, all > 0) |
nu1 |
Degrees of freedom vector of first distribution (length p, all > 4) |
mu2 |
Location vector of second distribution (length p) |
sigma2 |
Scale vector of second distribution (length p, all > 0) |
nu2 |
Degrees of freedom vector of second distribution (length p, all > 4) |
This function applies the univariate Welch-Satterthwaite approximation component-wise when all components are mutually independent. Each component difference Zj = X1j - X2j is approximated independently using the univariate method.
This approach is optimal for:
Marginal inference on specific components
Cases where components have different tail behaviors
Maintaining computational efficiency in high dimensions
An S3 object of class "ws_tdiff_multivariate_independent" containing:
mu_diff |
Location vector of difference |
sigma_star |
Vector of effective scale parameters |
nu_star |
Vector of effective degrees of freedom |
p |
Dimension of the vectors |
method |
Character string "multivariate_independent" |
ws_tdiff_multivariate_general for correlated components
result <- ws_tdiff_multivariate_independent( mu1 = c(0, 1), sigma1 = c(1, 1.5), nu1 = c(10, 12), mu2 = c(0, 0), sigma2 = c(1.2, 1), nu2 = c(15, 20) ) print(result)result <- ws_tdiff_multivariate_independent( mu1 = c(0, 1), sigma1 = c(1, 1.5), nu1 = c(10, 12), mu2 = c(0, 0), sigma2 = c(1.2, 1), nu2 = c(15, 20) ) print(result)
Approximates the distribution of the difference between two independent non-standardized t-distributed random variables using the Welch-Satterthwaite method.
ws_tdiff_univariate(mu1, sigma1, nu1, mu2, sigma2, nu2)ws_tdiff_univariate(mu1, sigma1, nu1, mu2, sigma2, nu2)
mu1 |
Location parameter of first distribution |
sigma1 |
Scale parameter of first distribution (must be > 0) |
nu1 |
Degrees of freedom of first distribution (must be > 4) |
mu2 |
Location parameter of second distribution |
sigma2 |
Scale parameter of second distribution (must be > 0) |
nu2 |
Degrees of freedom of second distribution (must be > 4) |
For two independent non-standardized t-distributed random variables:
X1 ~ t(mu1, sigma1^2, nu1)
X2 ~ t(mu2, sigma2^2, nu2)
The difference Z = X1 - X2 is approximated as: Z ~ t(mu1 - mu2, sigma_star^2, nu_star)
where the effective parameters are computed through moment matching:
sigma_star matches the variance of Z
nu_star is derived from fourth moment matching
The method requires nu1 > 4 and nu2 > 4 for the existence of fourth moments. The approximation quality improves as degrees of freedom increase and approaches exactness as nu -> infinity (normal limit).
An S3 object of class "ws_tdiff_univariate" containing:
mu_diff |
Location parameter of difference (mu1 - mu2) |
sigma_star |
Effective scale parameter (Equation 1 from paper) |
nu_star |
Effective degrees of freedom (Equation 2 from paper) |
input_params |
List of input parameters for reference |
method |
Character string "univariate" |
Yamaguchi, Y., Homma, G., Maruo, K., & Takeda, K. Welch-Satterthwaite Approximation for Difference of Non-Standardized t-Distributed Variables. (unpublished).
ws_tdiff_equal_params for the special case of equal parameters
dtdiff, ptdiff, qtdiff, rtdiff
for distribution functions
# Example 1: Different scale parameters result <- ws_tdiff_univariate( mu1 = 0, sigma1 = 1, nu1 = 10, mu2 = 0, sigma2 = 1.5, nu2 = 15 ) print(result) # Example 2: Equal parameters (special case) result_equal <- ws_tdiff_univariate( mu1 = 5, sigma1 = 2, nu1 = 20, mu2 = 3, sigma2 = 2, nu2 = 20 ) # Should match ws_tdiff_equal_params(5-3, 2, 20)# Example 1: Different scale parameters result <- ws_tdiff_univariate( mu1 = 0, sigma1 = 1, nu1 = 10, mu2 = 0, sigma2 = 1.5, nu2 = 15 ) print(result) # Example 2: Equal parameters (special case) result_equal <- ws_tdiff_univariate( mu1 = 5, sigma1 = 2, nu1 = 20, mu2 = 3, sigma2 = 2, nu2 = 20 ) # Should match ws_tdiff_equal_params(5-3, 2, 20)