| Version: | 1.0.0 |
| 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>. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Depends: | R (≥ 3.5.0) |
| Imports: | stats |
| Suggests: | testthat (≥ 3.0.0), mvtnorm, knitr, rmarkdown |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2025-11-06 20:47:04 UTC; API18340 |
| Author: | Yusuke Yamaguchi [aut, cre] |
| Maintainer: | Yusuke Yamaguchi <yamagubed@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2025-11-11 21:40:02 UTC |
Distribution Functions for Approximated t-Difference
Description
Distribution Functions for Approximated t-Difference
Usage
dtdiff(x, ws_result)
ptdiff(q, ws_result)
qtdiff(p, ws_result)
rtdiff(n, ws_result)
Arguments
x, q |
Vector of quantiles |
ws_result |
Result from ws_tdiff_univariate() |
p |
Vector of probabilities |
n |
Number of observations |
Value
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.
Examples
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)
Validate Welch-Satterthwaite Approximation
Description
Validates the approximation quality by comparing moments of the approximated distribution with the theoretical moments.
Usage
validate_approximation(ws_result, n_sim = 10000, seed = NULL)
Arguments
ws_result |
Result from any ws_tdiff function |
n_sim |
Number of simulations for validation (default: 10000) |
seed |
Random seed for reproducibility |
Value
A list containing validation metrics
Examples
result <- ws_tdiff_univariate(0, 1, 10, 0, 1.5, 15)
validation <- validate_approximation(result)
print(validation)
Equal Parameters Special Case
Description
Computes the Welch-Satterthwaite approximation for the special case where both distributions have identical parameters.
Usage
ws_tdiff_equal_params(mu, sigma, nu)
Arguments
mu |
Common location parameter |
sigma |
Common scale parameter (must be > 0) |
nu |
Common degrees of freedom (must be > 4) |
Details
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.
Value
An S3 object of class "ws_tdiff_univariate" with the simplified parameters
Examples
# 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)
Welch-Satterthwaite Approximation for General Multivariate t-Differences
Description
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).
Usage
ws_tdiff_multivariate_general(
mu1,
Sigma1,
nu1,
mu2,
Sigma2,
nu2,
max_iter = 10,
tol = 0.001
)
Arguments
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) |
Details
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.
Value
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" |
Examples
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)
Welch-Satterthwaite Approximation for Multivariate t-Differences (Independent)
Description
Approximates the distribution of differences between two independent p-dimensional vectors with independent t-distributed components.
Usage
ws_tdiff_multivariate_independent(mu1, sigma1, nu1, mu2, sigma2, nu2)
Arguments
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) |
Details
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
Value
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" |
See Also
ws_tdiff_multivariate_general for correlated components
Examples
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)
Welch-Satterthwaite Approximation for Univariate t-Differences
Description
Approximates the distribution of the difference between two independent non-standardized t-distributed random variables using the Welch-Satterthwaite method.
Usage
ws_tdiff_univariate(mu1, sigma1, nu1, mu2, sigma2, nu2)
Arguments
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) |
Details
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).
Value
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" |
References
Yamaguchi, Y., Homma, G., Maruo, K., & Takeda, K. Welch-Satterthwaite Approximation for Difference of Non-Standardized t-Distributed Variables. (unpublished).
See Also
ws_tdiff_equal_params for the special case of equal parameters
dtdiff, ptdiff, qtdiff, rtdiff
for distribution functions
Examples
# 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)