# How to simulate Gumbel Copula in R?

I am relatively new to R programming,

I am trying to generate Gumbel coupla as described by

https://datascienceplus.com/modelling-dependence-with-copulas/


Apply the copula in the mvdc() function and then use rmvdc() to get our simulated observations from the generated multivariate distribution.

copula_dist <- mvdc(copula=gumbelCopula(1.37,dim=2), margins=c("gumbel","gumbel"),
paramMargins=list(list(shape=10.2988298881251, scale=1.02463492397923),
list(shape=11.3384023583015, scale=2.02977411878884)))


My outcome was:

Error in parse(text = x, srcfile = src): <text>:5:0: unexpected end of input
3:                                       list(shape=11.3384023583015, scale=2.02977411878884))
4: # sim <- rmvdc(copula_dist, 3965)
^
Traceback:


Can someone help me with understanding how may I simulate Gumbel Copula?

Btw I did

# Fit the transformed data
library('VineCopula')
library(copula)
u <- pobs(as.matrix(resi_Trans))[,1]
v <- pobs(as.matrix(resi_Trans))[,2]
selectedCopula <- BiCopSelect(u,v,familyset=NA)
selectedCopula


and the outcome was

Bivariate copula: Gumbel (par = 1.37, tau = 0.27)


I am not sure if the tau need to be represented in gumbelCopula(1.37,dim=2) in my previous function

copula_dist <- mvdc(copula=gumbelCopula(1.37,dim=2),....

• You have a syntax error (unbalanced parentheses).
– whuber
Commented Mar 11, 2017 at 19:15
• Thank you for pointing it out i will re-edit it but this will not stop the problem Commented Mar 11, 2017 at 19:16

After lots of search and work, I found the following one needs to understand that

Quantile function and generating Gumbel variates is mentioned in

https://en.wikipedia.org/wiki/Gumbel_distribution


Moreover, I was misunderstanding the idea of shape and scale it seems that a Gumbel distribution is defined by location and scale. However, for our purpose, I kept it as shape and scale.

I believe that the margin distribution of "gumbel" is not well implemented in the package "Copula" maybe because it might not have frequently been used.

To work around this you better define the function

qgumbel <- function(p,shape,scale) shape-scale *log(-log(p))


And now this code runs

G3 <- gumbelCopula(1.37, dim=2)
gMvd2 <- mvdc(G3, c("gumbel","exp"), param = list(list(shape=10.2988298881251, scale=1.02463492397923), list(rate=4)))
set.seed(11)
# n <- if(Xtras) 10000 else 200 # sample size (realistic vs short for example)
x <- rMvdc(100, gMvd2)