Comments (10)
I think you're right. Could you submit a pull request with a fix?
from vinecopula.
Sure, but I am unsure from a theoretical point of view. For the bivariate Frank copula with parameter theta, it holds:
tau = 1 - 4/theta + 4/theta*D(theta), where D: debye function.
So, for theta=500, I am obtaining tau=0.99:
frankPar <- 500
tau <- 1 - 4/frankPar + 4/frankPar * copula::debye1(frankPar)
tau
[1] 0.9920263
It implies that the maximum tau value with our upper bound (35) would be around 0.89.
frankPar <- 35
tau <- 1 - 4/frankPar + 4/frankPar * copula::debye1(frankPar)
tau
[1] 0.8910855
How should we proceed?
from vinecopula.
Actually, the easiest should be to restrict the parameter range when root solving here. Right now, a parameter > 35 could result from calcPar()
, but it would be truncated immediately after here. So truncating already in calcPar()
wouldn't make things worse. In that case, we could also recompute the lookup table with a narrower range.
What do you think?
from vinecopula.
Thanks! I think that we could make the grid and its corresponding values wider so that it can compute the parameter-tau relationship until tau=0.99 with the theoretical formula. Accordingly, we should extend the parameter range in root solving to make sure that lower and upper bounds return opposite signs as required. For any tau value > 0.89, the returned parameter value will be 35 in this scenario. Does that make sense?
from vinecopula.
Also, do you know why these (1, 2) are commented and values are written one by one instead?
from vinecopula.
But what's the point in making the grid wider, if the result is 35 anyway? Can't we just restrict the root solving range then?
We store the values one by one, so VineCopula does not depend on the copula package (and as a result also gsl, which requires extra system libraries on linux and mac).
from vinecopula.
If I am not mistaken:
approx is interpolating given the grid values for par (x) and tau (y). Therefore, max tau value it can work is bounded by the upper limit of the tau grid. Thus, when we restrict root solving range without making the grid wider, uniroot function could still return positive (tau-interpolation) values for tau > 0.96 in the upper bound, which prevents it from finding a root. Making the grids wider up to tau = 0.99 and adjust the upper bound (app. 500) accordingly should approximate the theoretical relationship with one difference that any parameter > 35 will be truncated to 35.
Without adjusting the grid but changing uniroot range:
frankParGrid <- seq(-100, 100, l = 100)
frankTauVals <- 1 - 4/frankParGrid + 4/frankParGrid * copula::debye1(frankParGrid)
tau <- 0.99
v <- uniroot(function(x) tau - frankTau(x),
lower = 0 + .Machine$double.eps^0.5, upper = 35,
tol = .Machine$double.eps^0.5)$root
Error in uniroot(function(x) tau - frankTau(x), lower = 0 + .Machine$double.eps^0.5, :
f() values at end points not of opposite sign
Suggestion:
frankParGrid <- seq(-500, 500, l = 100)
frankTauVals <- 1 - 4/frankParGrid + 4/frankParGrid * copula::debye1(frankParGrid)
tau <- 0.99
v <- uniroot(function(x) tau - frankTau(x),
lower = 0 + .Machine$double.eps^0.5, upper = 500,
tol = .Machine$double.eps^0.5)$root
# v will be truncated to 35
v
[1] 398.3634
from vinecopula.
Ah yeah, I get it. Then even better:
frankParGrid <- c(-10^(5:2), seq(-36, 36, l = 100), 10^(2:5))
frankTauVals <- 1 - 4/frankParGrid + 4/frankParGrid * copula::debye1(frankParGrid)
frankTau <- function (par) approx(x = frankParGrid, y = frankTauVals, xout = par)$y
tau <- 0.99
v <- uniroot(function(x) tau - frankTau(x),
lower = 0 + .Machine$double.eps^0.5, upper = 1e5,
tol = .Machine$double.eps^0.5)$root
# v will be truncated to 35
v
That way we don't lose accuracy in the [-35,35] range but can handle taus up to 0.9999.
from vinecopula.
Agreed, great!
from vinecopula.
solved by #79
from vinecopula.
Related Issues (20)
- Error in variance calculation in RVineVuongTest HOT 2
- Unexpected C-Vine Simulation Results HOT 6
- BiCopSelect selects the wrong copula HOT 6
- How to set up vine copula model with different margins in vine_dist() and a possible bug in rvinecoplib HOT 1
- Numerical stability for Gumbel copula with huge parameter HOT 1
- BiCopEst for boundary case HOT 9
- Small bug in RVineMLE HOT 1
- Vectorize parameters HOT 6
- familyset not working in RVineStructureSelect HOT 2
- VineCopula; RStudio Version 1.3.959: contour rvinematrixe HOT 2
- Differences between CDVine and VineCopula? HOT 3
- RVineStructureSelect() returns C-Vine even when specified otherwise HOT 1
- RVineStructureSelect tree problem (RStudio Version 1.3.1073)
- Error in uniroot...? HOT 2
- about choosing the variables of vine copula HOT 1
- Suggestion: Add a function that fits all copulas HOT 2
- about the RVineMLE$message HOT 11
- Parameter - error given for rotated Gumbel and Clayton copulas HOT 1
- how to modify the package RVineStructureSelect HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vinecopula.