Serving the Quantitative Finance Community

 
User avatar
emh
Topic Author
Posts: 0
Joined: February 20th, 2008, 3:39 am

Fitting copulas over emperical data in R

October 1st, 2012, 4:56 pm

I am trying how to fit copulas over empirical Bi variate data in R. I saw the following pieces of Code(http://www.jstatsoft.org/v21/i04/paper) in R but i don't seem to understand some parts of it. First the author simulates some data to fit which i understand."To illustrate, we generate a sample from a bivariate distribution with gamma margins and anormal copula:R> myMvd <- mvdc(copula = ellipCopula(family = "normal", param = 0.5),+ margins = c("gamma", "gamma"), paramMargins = list(list(shape = 2,+ scale = 1), list(shape = 3, scale = 2)))R> n <- 200R> dat <- rmvdc(myMvd, n)The parameters to be estimated consist of marginal parameters β = (2, 1, 3, 2)and copulaparameter α = 0.5. The loglikelihood at the true parameter value is:R> loglikMvdc(c(2, 1, 3, 2, 0.5), dat, myMvd)[1] -781.1641Next is the code to fit a coupla over this data.---------------------------------------------------------------------------------------My questions on the code below are.1) How does he decide the initial value of of the Copula value a.0 (as in what is the math do get hat function).2)Is it possible for the marginals to be some non parametric empirical distribution. How do i do that.3) Would it matter if the myMvd object is without the list in this as the parametrs in the list are exactly what we are are trying to estimate.R> mm <- apply(dat, 2, mean)R> vv <- apply(dat, 2, var)R> b1.0 <- c(mm[1]^2/vv[1], vv[1]/mm[1])R> b2.0 <- c(mm[2]^2/vv[2], vv[2]/mm[2])R> a.0 <- sin(cor(dat[, 1], dat[, 2], method = "kendall") * pi/2)R> start <- c(b1.0, b2.0, a.0)R> fit <- fitMvdc(dat, myMvd, start = start,+ optim.control = list(trace = TRUE, maxit = 2000))R> fitThe ML estimation is based on 200 observations.Margin 1 :Estimate Std. Errorm1.shape 1.830479 0.1689802m1.scale 1.037388 0.1100475Margin 2 :Estimate Std. Errorm2.shape 3.515646 0.3362403m2.scale 1.628037 0.1672812Copula:Estimate Std. Errorrho.1 0.419909 0.05820196The maximized loglikelihood is -777.327Any help would be greatly appreciated.