Hello Aptech:

I am sorry for keeping asking the similar questions. The following is my questions based on my previous post here.

Q1:

In the first post I made, "How to obtain mutivariate normal distribution with mean u and covariance matrix using cdfMvn", you introduced to me the use of "cdfMvne. The example we did last time is that, for a two-dimention random vector Z=[Z1,Z2], if they are evaluated at [z1, z2] such as:

```
//Upper limits of integration
ulim = { -0.5, 1 };
```

with non-zero mean vector

`mu = { 0.76, 1.1 };`

and Correlation matrix

`corr = { 1 0.26, 0.26 1 };`

then the solution given last time is to use the command

```
{ p2, tol, err } = cdfMvne(cdfmControlCreate(), ulim_t, corr, mu_t);
print p2;
```

However, I have two problems as follows: 1) `ulim_t`

and `mu_t`

are not defined, which I believe they should be *ulim* and *mu* defined above. 2) the results from `print p2`

gives

0.10383468 0.59483487

which is not 0.066579035 from the command :

`cdfMvn(ulim-mu, corr)`

I understand that if `corr`

is a (2 by 2) diagonal matrix, then I simply multiply the number from `p2`

to get the joint density `P(Z1<z1, Z2<z2)`

. My question now is how should I get the joint density `P(Z1<z1, Z2<z2)`

from `cdfMvne()`

when the correlation matrix is not diagonal?

Q2:

This question is to ask how should I compute in GAUSS a multivariate logistic function with non-zero mean and non-diagonal correlation matrix?

Thank you very much for your help as always!

## 1 Answer

There is no reason to apologize for asking questions. That is the purpose of the forum. 🙂

**Regarding Q1**

I think all of your problems are coming because `cdfMVne`

requires the integration limits and mean to be a ROW vector, while `cdfMVn`

takes in COLUMN vectors. Here is an example that does what you want

```
//No commas between elements
//so they are row vectors
ulim = { 0 0 };
mu = { 0 0 };
//Non-diagonal correlation matrix
corr = { 1 0.26,
0.26 1 };
//Declare 'ctl' to be a cdfmControl struct
//and fill with default settings
struct cdfmControl ctl;
ctl = cdfmControlCreate();
{ p2, a, b } = cdfMVne(ctl,ulim, corr,mu);
print p2;
```

If you change `ulim`

and `mu`

to be COLUMN vectors, you will get a 2x1 return, since `cdfMVne`

treats each row of `ulim`

and `mu`

as a separate set of inputs.