From: Sergey Goriatchev <sergeyg_at_gmail.com>

Date: Sat, 22 Mar 2008 13:42:18 +0100

}

persp(u, u, gauss, xlab="x1", ylab="x2", zlab="Density of Gauss Copula",

Date: Sat, 22 Mar 2008 13:42:18 +0100

I have the code for the bivariate Gaussian copula. It is written with
for-loops, it works, but I wonder if there is a way to vectorize the
function.

I don't see how outer() can be used in this case, but maybe one can
use mapply() or Vectorize() in some way? Could anyone help me, please?

rho <- 0.5 #corr

R <- rbind(c(1,rho),c(rho,1)) #vcov matrix
id <- diag(2)

gauss <- matrix(0,99,99)

u <- seq(0.01, 0.99, by=0.01)

for(i in 1:99){

for(j in 1:99){ xx <- t(t(c(qnorm(u[i]), qnorm(u[j])))) gauss[i,j] <- 1/sqrt(1-rho^2)*exp(-0.5*t(xx)%*%(solve(R)-id)%*%xx) }

}

persp(u, u, gauss, xlab="x1", ylab="x2", zlab="Density of Gauss Copula",

theta=320, phi=20, col="palegreen", ticktype="detailed")

-- Sergei ______________________________________________ R-help_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.Received on Sat 22 Mar 2008 - 12:45:34 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Sat 22 Mar 2008 - 19:31:18 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*