Cumulative Distribution Function of the Difference of Two t-Distributed Variables by Monte Carlo Simulation
Source:R/pMCdifft.R
pMCdifft.Rd
This function calculates the cumulative distribution function (CDF) of the difference between two independent t-distributed random variables using Monte Carlo simulation. 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
- nMC
A positive integer representing the number of Monte Carlo iterations for simulation.
- 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 exceeds the quantile q.
Details
This function uses Monte Carlo simulation to approximate the distribution of the difference between two t-distributed variables. The method involves:
Generating nMC random samples from each t-distribution
Computing the difference for each pair of samples
Calculating the proportion of differences that exceed the threshold q
The accuracy increases with larger nMC values
Monte Carlo simulation provides a flexible and intuitive approach that can handle any combination of parameters, but the accuracy depends on the number of simulations. Larger nMC values yield more precise estimates but require more computational time.
Examples
# Calculate P(t1 - t2 > 3) for equal parameters using 10,000 simulations
pMCdifft(nMC = 1e+4, q = 3, mu.t1 = 2, mu.t2 = 0, sd.t1 = 1, sd.t2 = 1, nu.t1 = 17, nu.t2 = 17)
#> [1] 0.2453
# Calculate P(t1 - t2 > 1) for unequal variances using 50,000 simulations
pMCdifft(nMC = 5e+4, q = 1, mu.t1 = 5, mu.t2 = 3, sd.t1 = 2, sd.t2 = 1.5, nu.t1 = 10, nu.t2 = 15)
#> [1] 0.64712
# Calculate P(t1 - t2 > 0) for high precision with 100,000 simulations
pMCdifft(nMC = 1e+5, q = 0, mu.t1 = 1, mu.t2 = 0, sd.t1 = 1, sd.t2 = 1, nu.t1 = 5, nu.t2 = 20)
#> [1] 0.74054