Re: [R] Trouble with pmvnorm?

2014-02-11 Thread Paul Parsons
Of course, sorry... The approach below is indeed a much slicker way to calculate the probability of the ith variable being the smallest: #construct a new mv norm distribution, for y = x - x_i #define y = Bx, where B is a matrix B - matrix(rep(0,25),nrow=5) diag(B) - rep(1,5) B[,i] - -1 B - B[-i,]

Re: [R] Trouble with pmvnorm?

2014-02-10 Thread peter dalgaard
On 09 Feb 2014, at 10:56 , Paul Parsons pparsons...@gmail.com wrote: Many thanks, Peter. Creating a wrapper function for integrand using Vectorize, and then integrating the wrapper, does indeed solve the problem. I tried your final suggestion, but the variable x still gets passed into

Re: [R] Trouble with pmvnorm?

2014-02-09 Thread Paul Parsons
Many thanks, Peter. Creating a wrapper function for integrand using Vectorize, and then integrating the wrapper, does indeed solve the problem. I tried your final suggestion, but the variable x still gets passed into pmvnorm inside the new mean and variance matrix, leading to the same

Re: [R] Trouble with pmvnorm?

2014-02-08 Thread peter dalgaard
You almost said it yourself: Your integrand doesn't vectorize. The direct culprit is the following: If x is a vector, what is lower=c(x,x,x,x)? A vector of length 4*length(x). And pmvnorm doesn't vectorize so it wouldn't help to have lower= as a matrix (e.g., cbind(x,x,x,x)) instead. A

[R] Trouble with pmvnorm?

2014-02-06 Thread Paul Parsons
Hi I have a multivariate normal distribution in five variables. The distribution is specified by a vector of means ('means') and a variance-covariance matrix ('varcov'), both set up as global variables. I'm trying to figure out the probabilities of each random variable being the