

Hi Michael,

Thanks for your response. Here is a simple example of what I am trying to
do:

w=rep(0.02,10)
Q=rep(0.02,10)
rho=matrix(0.5,nrow=10,ncol=10)
m=10
LGD=0.45

M1=sum(sapply(1:m,
function(k){sum(sapply(1:m,function(j){w[k]*w[j]*LGD^2*(pmnorm(c(qnorm(Q[k]),qnorm(Q[j])),c(0,0),equicorr(2,rho[k,j]))-Q[k]*Q[j])}))})) 

It uses the mnormt and QRM packages.

I am trying to reproduce the following sum:

\sum\limits_{j=1}^M \sum\limits_{k=1}^M w_j w_k
LGD^2[N_2(N^{-1}[Q(j)],N^{-1}[Q(k)],\rho_{jk})-Q(j)Q(k)]



_______________________________________________
If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/sapply-and-matrix-command-tp4637769p4639622.html

To unsubscribe from sapply and matrix command, visit http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4637769&code=ci1oZWxwQHItcHJvamVjdC5vcmd8NDYzNzc2OXwtNzg0MjM1NTA4
	[[alternative HTML version deleted]]

