vinecopulib / pyvinecopulib

A Python library for vine copula models
MIT License
88 stars 22 forks source link

selection of best-fit vine-copula #118

Open chienyutseng opened 5 months ago

chienyutseng commented 5 months ago

hi, i am trying to find the optimal vine-coupla for my 4-dimensional data with Vinecop.select(), meanwhile using the R-package VineCopula for the same procedure due to the support for plotting. However, the results are different from these two packages. I've tested with some setting condition terms, with different Bicop.family() and select criteria with some current summary. It seems that there's not much data gap between the value of AIC and log-lik from those two packages.

i am wondering if it's acceptable for the difference of the best-fit vine-copula from pyvinecopulib and VineCopula in R ?

there's also another issue is that the value of bic shows -inf in the result from pyvinecopulib.

the following is my testing progress:

pyvinecopulib

U = pv.to_pseudo_obs(dataset)
copula = pv.Vinecop(d=len(dataset.columns))
copula.select(U)
image
controls = pv.FitControlsVinecop(family_set=[pv.BicopFamily.tll],selection_criterion='aic')
copula.select(U, controls=fit_control)
image
controls = pv.FitControlsVinecop(selection_criterion='aic')
copula_1, copula_1.aic(), copula_1.bic(), copula_1.loglik()
image

VineCopula


u_s1 <- data1[, 2]
u_s2 <- data1[, 3]
u_d <- data1[, 4]
u_R <- data1[, 1]

u <- cbind(u_R, u_s1, u_s2, u_d)
u_pseudo <- pseudo_obs(u)

fit_tll <- vinecop(u_pseudo, family_set=c('tll'), selcrit='aic' , show_trace=TRUE)
print(fit_tll)
image
fit <- vinecop(u_pseudo, show_trace=TRUE , selcrit='aic')
print(fit4)
contour(fit4)
image
tnagler commented 5 months ago

Both libraries call the same C++ code, so the differences are a little weird. Can you confirm you have the latest version of both libraries?

chienyutseng commented 5 months ago

thanks for the advice, but after the upgrade, the fitting results didn't change.

I would also like to confirm if it is reasonable for the 'bic' value in pyvinecopulib to be 'inf'.

here is the latest version of the package :

pyvinecopulib==0.6.4
packageVersion("VineCopula") -> ‘2.5.0’
tnagler commented 5 months ago

your fit results in R are from the package rvinecopulib so please update this package

chienyutseng commented 5 months ago

yes, I've also updated package rvinecopulib, which the version is 0.6.3.1.1. However, the difference remains.