I want to compute a numerical integral for a gaussian trivariate distribution. Say
NIntegrate[
X* PDF[MultinormalDistribution[{0,0,1}, {{1, 1/10, 1/5}, {1/10, 1,1/10}, {1/5, 1/10, 1}}], {X, Y, Z}],
{X, -Infinity, Infinity}, {Y, 0, Infinity}, {Z, -Infinity, -1}
]
(*Out: -0.00365287 *)
This is quite expensive to calculate, so I'd like to make use of parameterisations available for the Gaussian distribution. Specifically, the fact that:
$$ E[X\mid Y\geq y, Z\leq z]=E[E[X \mid Y,Z]\mid Y\geq y, Z\leq z]\\ =\beta_{XY;Z} E[Y\mid Y\geq y, Z\leq z]+\beta_{XZ;Y} E[Z \mid Y\geq y, Z\leq z] $$
where $\beta_{XY;Z}$ notes the regression coefficient of $X$ on $Y$ conditional on $Z$ (and $\beta_{XZ;Y}$ is analogously defined).
Applying this parameterisation to calculate the same integral from above gives
ρXY = 1/10;
ρXZ = 2/10;
ρYZ = 1/10;
βXYz = (ρXY - ρXZ*ρYZ)/(Sqrt[(1 - (ρXZ^2))] Sqrt[(1 - (ρYZ^2))]);
βXZy = (ρXZ - ρXY*ρYZ)/(Sqrt[(1 - ρXY^2)] Sqrt[(1 - ρYZ^2)]);
βXYz*NIntegrate[Y*PDF[BinormalDistribution[{0, 1}, {1, 1}, ρYZ], {Y, Z}], {Y, 0, Infinity}, {Z, -Infinity, -1}]
+
βXZy*NIntegrate[Z*PDF[BinormalDistribution[{0, 1}, {1, 1}, ρYZ], {Y, Z}], {Y, 0, Infinity}, {Z, -Infinity, -1}]
(* Out: -0.00187282 *)
Is it possible that this discrepancy is coming from the precision of NIntegrate
? Or am I just doing something wrong here?
NB. The two computational procedures coincide perfectly if ρXY= ρXZ= ρYZ
UPDATE: I am interested in speeding up the first integral, because what I would ultimately like to do is fix ρXY and ρXZ and calculate something like
ContourPlot[ NIntegrate[
X*PDF[MultinormalDistribution[{0,0,µ}, {{1, ρXY, ρXZ}, {ρXY, 1, ρYZ}, {ρXZ, ρYZ, 1}}], {X, Y, Z}], {X, -Infinity, Infinity}, {Y, a, Infinity}, {Z, -Infinity,b}],{µ,-2,2},{ρYZ,-.9,-9} ]
where the limits $a$ and $b$ are themselves numerical calculations (FindRoots). In other words, I would ideally like a symbolic expression of the first integral in terms of µ, ρYZ, $a$ and $b$
NIntegrate
expression you probably have a typo: the firstZ
variable range specification should actually refer toX
. $\endgroup$(-((2 Erfc[Sqrt[2/11]/3])/E^2) + Erfc[(10 Sqrt[2/11])/3])/(20 Sqrt[2 \[Pi]])
. Perhaps there is a good strategy for the family. $\endgroup$