mickkk
mickkk

Reputation: 1192

How to fit data in the form of vectors to Gumbel copula in R?

I am relatively new to R. For my final exam at university I decided to write a dissertation on copulas and so I collected some knowledge of the theory behind copulas, what they are and how they work. I also program in R but have never used copulas in R therefore I am a novice to copulas in R.

My question is: how can I fit raw data (in the form of an R vector) to a Gumbel copula?

Here is the format of my data:

x <- c(x1,x2,x3,...,xn)
y <- c(y1,y2,y3,...,yn)

Right now I'm using the copula package, I know how to generate random copulas and Gumbel copulas given theta as below:

#independence case
r_matrix <- t(rgumbel(2000,theta=1))
plot(r_matrix[1,], r_matrix[2,], col="blue", main="Gumbel, independence case")
positive dependence
r_matrix <- t(rgumbel(2000,theta=3))
plot(r_matrix[1,], r_matrix[2,], col="blue", main="Gumbel, Positive dependence")

However I do not know how to estimate theta.. I know what Spearman's Rho and Kendall's Tau are, if that could help. Could you please help me to fit x and y to the Gumbel copula? Should I use another package? Thank you

Upvotes: 0

Views: 1693

Answers (1)

user4386452
user4386452

Reputation: 26

I hope this helps

library(copula)
gumbel.cop= gumbelCopula(2, dim = 7)
set.seed(117)
u1 = rCopula(500, gumbel.cop)
fit.ml = fitCopula(gumbel.cop, u1, method = "ml")

The output for the above is

fitCopula() estimation based on 'maximum likelihood'
and a sample of size 500.
      Estimate Std. Error z value Pr(>|z|)    
param  2.01132    0.02902   69.31   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
The maximized loglikelihood is  1643 
Optimization converged
Number of loglikelihood evaluations:
function gradient 
      20        3 

You can also try "mpl","itau" or "irho" instead of "ml" for the estimator. Just so you know "ml" is (maximum likelihood), "mpl" is (maximum pseudo-likelihood), "itau" is (inversion of Kendall’s tau), and "irho" is (inversion of Spearman’s rho). See R copula package for more details

Upvotes: 1

Related Questions