Hi r-users,

I try to fit the t copula using the gamma marginals.  But I got error message which I don't really understand.

Thank you for any help given.

myCop.t <- ellipCopula(family = "t", dim = 2, dispstr = "toep", param = 0.5, df = 8)
myCop.t
myMvd <- mvdc(copula = myCop.t, margins = c("gamma", "gamma"), paramMargins = list(list(mean = 0, sd = 2), list(mean = 0,
sd = 1)))
myMvd
dat <- stn_pos ## observed data
loglikMvdc(c(0, 2, 0, 1, 0.5,8), dat, myMvd)   ## loglikelihood
mm <- apply(dat, 2, mean)
vv <- apply(dat, 2, var)
rho <- rcorr(stn_pos,type="spearman")[[1]]; round(rho,2)
rbind(mm,vv)
b1.0 <- c(mm[1]^2/vv[1], vv[1]/mm[1])
b2.0 <- c(mm[2]^2/vv[2], vv[2]/mm[2])
a.0  <- sin(cor(dat[, 1], dat[, 2], method = "kendall") * pi/2)
start <- c(b1.0, b2.0, a.0)
fit <- fitMvdc(dat, myMvd, start = start,optim.control = list(trace = TRUE, maxit = 2000))
fit

#################

> head(dat);tail(dat)
      [,1]  [,2]
[1,]  28.4  43.5
[2,]   9.2   7.4
[3,]  48.8  68.9
[4,] 185.2 115.7
[5,]   4.1  11.7
[6,]  67.6  29.8
        [,1]  [,2]
[946,]   8.8  17.2
[947,] 119.6 164.0
[948,]  68.4 163.6
[949,]  45.8  61.6
[950,]  77.0 101.0
[951,]  56.6  74.8

> myCop.t <- ellipCopula(family = "t", dim = 2, dispstr = "toep", param = 0.5, df = 8)
> myCop.t
t copula family  
Dimension:  2 
Parameters:
   rho.1  =  0.5 
   df  =  8 
> myMvd <- mvdc(copula = myCop.t, margins = c("gamma", "gamma"), paramMargins = list(list(mean = 0, sd = 2), list(mean = 0, sd = 1)))
> myMvd
An object of class “mvdc”
Slot "copula":
t copula family  
Dimension:  2 
Parameters:
   rho.1  =  0.5 
   df  =  8 
Slot "margins":
[1] "gamma" "gamma"
Slot "paramMargins":
[[1]]
[[1]]$mean
[1] 0
[[1]]$sd
[1] 2

[[2]]
[[2]]$mean
[1] 0
[[2]]$sd
[1] 1

Slot "marginsIdentical":
[1] FALSE

> dat <- stn_pos ## observed data

> loglikMvdc(c(0, 2, 0, 1, 0.5,8), dat, myMvd)   ## loglikelihood
Error in pgamma(x, mean = 0, sd = 2) : 
  unused argument(s) (mean = 0, sd = 2)

[1] NaN
> mm <- apply(dat, 2, mean)
> vv <- apply(dat, 2, var)
> rho <- rcorr(stn_pos,type="spearman")[[1]]; round(rho,2)
     [,1] [,2]
[1,]  1.0  0.9
[2,]  0.9  1.0
> rbind(mm,vv)
         [,1]      [,2]
mm   58.63912   83.7224
vv 1789.51116 3315.2367
> b1.0 <- c(mm[1]^2/vv[1], vv[1]/mm[1])
> b2.0 <- c(mm[2]^2/vv[2], vv[2]/mm[2])
> a.0  <- sin(cor(dat[, 1], dat[, 2], method = "kendall") * pi/2)
> start <- c(b1.0, b2.0, a.0)
> fit <- fitMvdc(dat, myMvd, start = start,optim.control = list(trace = TRUE, maxit = 2000))
Error in fitMvdc(dat, myMvd, start = start, optim.control = list(trace = TRUE,  : 
  The length of start and mvdc parameters do not match.
> 


      
	[[alternative HTML version deleted]]

