Skip to content

bivariate normal

3 messages · Anders Holm, Rolf Turner, David Winsemius

#
On 28/07/12 05:45, Anders Holm wrote:
Huh?  Where ever did you get that idea?  (Makes no sense at all,
     as far as I can see.)
Sorry, I must be a bit dim, but I don't follow this at all.

     Anyhow, either dmnorm() from the "mnormt" package or
     dmvnorm() from the "mvtnorm" package should, properly applied,
     do everything that you want.

         cheers,

             Rolf
#
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