apaNIGsim.Correlated(nSims, NIGparameters, Correlations, Method)
=apaNIGsim.Correlated(nSims, NIGparameters, Correlations, Method)Result
Simulates correlated normal inverse Gaussian (NIG) distributed random variables whose Pearson correlations equal the target correlations. Returns an nSims x c matrix, each column containing a variable.
Syntax
nSims: number of observations to simulate
NIGparameters: 4 x c matrix of NIG parameters alpha, beta, mu and delta (rows), each column containing a variable
Correlations: c x c target Pearson correlation matrix of the NIG variables
Method: optional; 0 = normal variance-mean mixture with independent mixing variables, 1 = Gaussian copula with exact NIG marginals; default: 0
Algorithm
Method 0: each variable is a normal variance-mean mixture X(j) = mu(j) + beta(j)·Z(j) + √Z(j)·W(j), where the mixing variables Z(j) are independent inverse Gaussian draws with parameters delta(j) and gamma(j) = √(alpha(j)² − beta(j)²), and W is multivariate standard normal with correlation matrix R. The Pearson correlation of the NIG variables is Corr(X(i), X(j)) = R(i,j)·m(i,j), with m(i,j) = E[√Z(i)]·E[√Z(j)] / √(Var X(i)·Var X(j)), E[√Z] = √(delta/gamma)·K0(delta·gamma) / K1/2(delta·gamma) and Var X = delta·alpha² / gamma³. R is set to R(i,j) = Correlations(i,j) / m(i,j).
Method 0: Gaussian copula X(j) = F(j)⁻¹(Φ(W(j))), where F(j) is the NIG cdf of variable j and W is multivariate standard normal with correlation matrix R. F(j)⁻¹(Φ(z)) is tabulated on a fine grid from the numerically integrated NIG density, with exponential tails beyond the grid. For each pair, R(i,j) is found by bisection such that the Pearson correlation of X(i) and X(j), computed from the Hermite expansion Σk ck(i)·ck(j)·R(i,j)^k / (σ(i)·σ(j)), equals Correlations(i,j).
Method 1 is the NORTA (normal to anything) method of Cario and Nelson (1997); the Hermite expansion of the Pearson correlation as a polynomial in R(i,j) follows Xiao and Zhou (2019). Cario, M. C. and Nelson, B. L. (1997), Modeling and generating random vectors with arbitrary marginal distributions and correlation matrix, Technical Report, Department of Industrial Engineering and Management Sciences, Northwestern University, https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.48.281. Xiao, Q. and Zhou, S. (2019), Matching a correlation coefficient by a Gaussian copula, Communications in Statistics – Theory and Methods 48(7), 1728–1747, https://doi.org/10.1080/03610926.2018.1439962.
Remarks
Correlations are population (distribution) correlations; the sample correlations of a simulated matrix deviate from them by sampling error.
Both methods reproduce the NIG marginals and the target Pearson correlations. In Method 0 the attainable absolute correlation is limited to m(i,j) < 1, which decreases with heavier tails and stronger skewness; observed correlations of heavy-tailed return series may exceed it. Method 1 builds the quantile tables once per call and attains correlations up to those of perfectly comonotonic or countermonotonic variables (close to ±1 for similar marginals) and produces joint tail events.
A target outside the attainable range (the error message states the range), a set of targets for which R is not positive semi-definite, invalid parameters (alpha must exceed |beta|, delta must be positive) and a Correlations matrix that is not a valid correlation matrix return an error message.
The function is volatile and the results change with each recalculation.
Pressing Esc aborts the calculation; the function then returns "Calculation aborted by user."
