I got some R code that I don't understand.

Question as comment in code
//where is t comming from, what is phi inverse

rAC <- function(name, n, d, theta){
#generic function for Archimedean copula simulation
illegalpar <- switch(name,
clayton = (theta < 0),
gumbel = (theta < 1),
frank = (theta < 0),
BB9 = ((theta[1] < 1) | (theta[2] < 0)),
GIG = ((theta[2] < 0) | (theta[3] < 0) | ((theta[1]>0) & (theta[3]==0)) |
((theta[1]<0) & (theta[2]==0))))
if(illegalpar)
stop("Illegal parameter value")
independence <- switch(name,
clayton = (theta == 0),
gumbel = (theta == 1),
frank = (theta == 0),
BB9 = (theta[1] == 1),
GIG=FALSE)
U <- runif(n * d)
U <- matrix(U, nrow = n, ncol = d)
if(independence)
return(U)
Y <- switch(name,
clayton = rgamma(n, 1/theta),
gumbel = rstable(n, 1/theta) * (cos(pi/(2 * theta)))^theta,
frank = rFrankMix(n, theta),
BB9 = rBB9Mix(n, theta),
GIG = rGIG(n,theta[1],theta[2],theta[3]))
Y <- matrix(Y, nrow = n, ncol = d)
phi.inverse <- switch(name,
clayton = function(t, theta)
//where is t comming from, what is phi inverse
{
(1 + t)^(-1/theta)
}
,
gumbel = function(t, theta)
{
exp( - t^(1/theta))
}
,
frank = function(t, theta)
{
(-1/theta) * log(1 - (1 - exp( - theta)) * exp( - t))
}
,
BB9 = function(t, theta)
{
exp( - (theta[2]^theta[1] + t)^(1/theta[1]) + theta[2])
}
,
GIG = function(t, theta)
{
lambda <- theta[1]
chi <- theta[2]
psi <- theta[3]
if (chi==0)
out <- (1+2*t/psi)^(-lambda)
else if (psi==0)
out <- 2^(lambda+1)*exp(besselM3(lambda,sqrt(2*chi*t),log
value=TRUE)-lambda*log(2*chi*t)/2)/gamma(-lambda)
else
out <- exp(besselM3(lambda,sqrt(chi*(psi+2*t)),logvalue=T
RUE)+lambda*log(chi*psi)/2-besselM3(lambda,sqrt(chi*psi),logvalue=TRUE)-lambda*log(chi*(psi+2*t))/2)
out
}
)
phi.inverse( - log(U)/Y, theta)
}
-- 
View this message in context: 
http://www.nabble.com/Newbie-that-don%27t-understand-R-code-tp25009034p25009034.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@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.

Reply via email to