On Wed, Aug 8, 2012 at 10:37 AM, alijk1989 [via R]
wrote:
>
>
> 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:
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,r
On Wed, Aug 8, 2012 at 9:17 AM, alijk1989 [via R]
wrote:
>
>
> Hi,
>
> I have made some progress speeding up my code. This is what I have at the
> moment:
>
>
> 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]
Hi,
I have made some progress speeding up my code. This is what I have at the
moment:
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])}))}))
I tried setting up a function as so:
f1 <- function
Take a look at ?expand.grid
Michael
On Aug 4, 2012, at 5:03 PM, "alijk1989 [via R]"
wrote:
>
>
> Thanks again for the help looks like this will be useful for what I'm doing.
> Is there any way to use combn to return combinations of values with
> themselves:
>
> e.g.
>
>> combn(1:3,2)
>
>
Thanks again for the help looks like this will be useful for what I'm doing.
Is there any way to use combn to return combinations of values with
themselves:
e.g.
>combn(1:3,2)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,]111 2 2 3
[2,]1 232 3 3
HI,
You can also try this:
d<-1:25
A<-sample(combn(20:30,2))
B<-sample(combn(20:30,2))
lapply(d,function(x) matrix(c(1,A[x],B[x],1),2,2))
[[1]]
[,1] [,2]
[1,]1 23
[2,] 271
[[2]]
[,1] [,2]
[1,]1 21
[2,] 211
[[3]]
[,1] [,2]
[1,]1 29
[2,] 231
[[4]
7 matches
Mail list logo