Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug near CDF = 1 in BiCopPDF #37

Closed
cag472 opened this issue May 3, 2017 · 1 comment
Closed

Bug near CDF = 1 in BiCopPDF #37

cag472 opened this issue May 3, 2017 · 1 comment

Comments

@cag472
Copy link

cag472 commented May 3, 2017

I was comparing BiCopPDF to dCopula and got nearly perfect agreement, but ~0.1% of the values would strongly disagree, with BiCopPDF getting something O(10^5) and dCopula getting 0. It turns out this is when the CDF value of the input is near the maximum. I made the following minimum working example:

library(VineCopula)
data <- matrix(data=runif(200), ncol=2)
copula <- BiCopSelect(data[,1], data[,2], familyset=1, selectioncrit="AIC", indeptest=F, rotations=FALSE)
print(BiCopPDF(0.99 , 0.9999, copula))
print(BiCopPDF(0.9999 , 0.9999, copula))
print(BiCopPDF(0.99999999 , 0.99999999, copula))
print(BiCopPDF(1 , 1, copula))

With this example, I get different values every time I run this, with the last number in the printout giving anything from 0.0001 to 8.

@tnagler
Copy link
Owner

tnagler commented May 3, 2017

I am not sure what you see as a bug in your example code.
Note that the true value of the Gaussian copula pdf at (1,1) would be Inf for rho > 0 and 0 for rho < 0. To avoid numerical instability, VineCopula never evaluates the density at values smaller than 1e-10 or larger than 1 - 1e-10. So:

> print(BiCopPDF(1 - 1e-10 , 1 - 1e-10, copula))
#> [1] 17.49833
> print(BiCopPDF(1 , 1, copula))
#> [1] 17.49833

@tnagler tnagler closed this as completed Jul 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants