r3chisq {ARHT} | R Documentation |
Generate samples approximately from three positively correlated chi-squared random variables (χ^2(d_1), χ^2(d_2), χ^2(d_3)) when the degrees of freedom (d_1, d_2, d_3) are large.
r3chisq(size, df, corr_mat)
size |
sample size. |
df |
the degree of freedoms of the marginal distributions. Must be non-negative, but can be non-integer.
The function uses |
corr_mat |
the target correlation matrix; negative elements will be set to 0. |
It is generally hard to sample from (χ^2(d_1), χ^2(d_2), χ^2(d_3)) with a designed correlation matrix.
In the algorithm, we approximate the random vector by (z^T Q_1 z, z^T Q_2 z, z^T Q_3 z)
where z is a standard norm random vector and Q_1,Q_2,Q_3 are diagonal matrices
with diagonal elements 1's and 0's. The designed positive correlations is approximated by carefully
selecting common locations of 1's on the diagonals. The generated sample may have slightly larger marginal degrees
of freedom than the inputted df
, also slightly different covariances.
sample
: a size
-by-3 matrix contains the generated sample.
approx_cov
: the true covariance matrix of sample
.
Li, H., Aue, A., Paul, D., Peng, J., & Wang, P. (2016). An adaptable generalization of Hotelling's T^2 test in high dimension. arXiv preprint <arXiv:1609.08725>.
set.seed(10086) cor_examp = matrix(c(1,1/6,2/3,1/6,1,2/3,2/3,2/3,1),3,3) a_sam = r3chisq(size = 10000, df = c(80,90,100), corr_mat = cor_examp) cov(a_sam$sample) - a_sam$approx_cov cov2cor(a_sam$approx_cov) - cor_examp