Re: How to create conditional correlated random values given exogenous data



Ray Koopman wrote:
1. Get the cholesky factor, say A, of the desired 5 x 5 covariance
matrix whose first 2 variables are the given X-variables.

2. Get the QR decomposition of the n x 6 matrix in which
column 1 is all 1's,
columns 2 & 3 are the two given X-variables,
columns 4, 5, & 6 are filled with independent identically
distributed random normal values.

3. Y = sqrt[m]*(the last 3 columns of Q)*
(the transpose of the lower right 3 x 3 section of A),
where m is either n or n-1, depending on how you define variance.

Step 3 is wrong. Try this instead:
If R[2,2] < 0 then Q[1:n,2] = -Q[1:n,2]
If R[3,3] < 0 then Q[1:n,3] = -Q[1:n,3]
Y = sqrt[m] * Q[1:n,2:6] * Transpose[A[3:5,1:5]]

.