Skip to content
Prev 301544 / 398503 Next

bivariate normal

On Jul 27, 2012, at 10:45 AM, Anders Holm wrote:

            
I do not think you are reading the documentation for the d- and p-  
functions in mvtnorm correctly:

Here is the 2-dimensional case using pmvnorn (since you asked for  
probabilities)  and the result is as expected:

 > n <- 2
 > mean <- rep(0, 2)
 > corr <- diag(2)
 > corr[lower.tri(corr)] <- 0
 > corr[upper.tri(corr)] <- 0

Half of the xy plane of a 2d-mvnorm with 0 covariances should give 0.5

 > prob <- pmvnorm( lower= c(-Inf,-Inf), upper= c( 0, Inf), mean, corr)
 > prob
[1] 0.5
attr(,"error")
[1] 2e-16
attr(,"msg")
[1] "Normal Completion"

And a single quadrant should give 0.25.

 > prob <- pmvnorm(lower=c(-Inf,-Inf), upper=c( 0, 0), mean, corr)
 > prob
[1] 0.25
attr(,"error")
[1] 1e-15
attr(,"msg")
[1] "Normal Completion"

I guessing that you want to provide the data to pmvnorm with apply()  
using -Inf as the 'lower' limits and your datapoints as the 'upper'  
values:

Perhaps:

apply(n_x_2_values,
 >
David Winsemius, MD
Alameda, CA, USA