Comments (10)
Hi! Your example doesn't run, C_DI
is not defined. Please also provide code for the cases where an error occurs, so I don't have to guess what to replace.
from vinecopula.
Apologize for the typo, i did defined C_DI
at my local side and the example can worked. What couldn't work is when i try to replace BB1Copula()
to BiCop()
, as code show below
H <- rnorm(100)
D <- rnorm(100)
I <- rnorm(100)
u_H <- pobs(H)
u_D <- pobs(D)
u_I <- pobs(I)
C_HD <- BiCop(family = 1, par =0.36)
C_DI <- BiCop(family = 1, par =0.53)
C_HIgivenD <- BiCop(family = 1, par =0.54)
k <- ddvCopula(cbind(u_H, u_D), C_HD)
m <- dduCopula(cbind(u_D, u_I), C_DI)
cond_prob <- dduCopula(cbind(k, m), C_HIgivenD)
from vinecopula.
OK, a few things:
- The code you're writing is not for conditional sampling, it computes a conditional probability. Conditional sampling is the inverse of the transformation you're computing.
- You cannot use
copula::ddvCopula()
withVineCopula::BiCop
objects. You have to replace theBiCop()
calls withBiCop2copula()
. - Even then, the corresponding
ddvCopula()
anddduCopula()
methods were not defined in theVC2copula
package (my bad). This is fixed in thedev
branch. You can update usingremotes::install_github("tnagler/VC2copula@dev")
from vinecopula.
Thank you for your supplement.
According to what you mentioned first, what i trying to do is conditional sampling, as the formula below, which is what i am having trouble with.
x1 = w1, x2 = F^-1(w2|x1), x3 = F^-1(w3|x1, x2),
with F(x j |x1, . . . , x j−1) = ∂ C j, j−1|1,..., j−2 {F(x j |x1, . . . , x j−2), F(x j−1|x1, . . . , x j−2)} / ∂ F(x j−1|x1, . . . , x j−2)
if i wasn't wrong,i can get x2
from VineCopula::BiCopHinv
, but is there any function for getting x3
from given x1
and x2
?
from vinecopula.
- The formula is for unconditional sampling.
- You can use
VineCopula::RVineSim(N, RVM, U=W)
whereW
is a matrix containing w1,w2,w3 from your example in the columns. You can also use this for conditional sampling, assuming the RVineMatrix is set up appropriately (variables you condition on have to be furthest up on the diagonal) and you useRVinePIT()
before on the conditioning values. Do you have a reference for what you're trying to implement? - For manual computation, you have to chain inverse and regular h-functions, but getting this right is not easy.
from vinecopula.
The following snapshot(Kjersti et al., 2007), is what I trying to do.
i have gotten a fitted 3D CVine Copula(for variable X,Y,Z) from my observation:
** Tree: 0
2,1 <-> Gaussian, parameters = 0.485697
1,3 <-> Gaussian, parameters = 2.10785
** Tree: 1
2,3 | 1 <-> Joe 90°, parameters = -1.08
The algorithm I planned to build is getting X from another Copula and viewed as observation, then representing as conditional value for the 3D CVine copula, and getting Y & Z by the pair-copulae decomposed model.
from vinecopula.
OK, the three dimensional example is fairly easy:
RVM <- C2RVine(1:3, family = c(1, 4, 6), par = c(0.3, 2.4, 1.5))
W <- cbind(w1 = 0.2, runif(100), runif(100))
RVineSim(100, RVM, U = W)
Here we're simulating x1, x2, x3 conditional on x2 = 0.2. You can adapt this to your liking.
from vinecopula.
thanks a alot! i think this is what i want. but please allow me to ask futher questions.
I am seeking clarification on the specific scenarios in which the pair-copula decomposition model is most appropriately applied. Many journals refer to this method in the context of vine-copula simulations, and I was under the impression that this methodology should be applied for my needs. Could you please provide some insight on this?
from vinecopula.
I can't really answer this question without knowing much more about your application context. But if you want to simulate two variables conditional on one other variable, this is a viable method. Closing this now, since the software part seems to be solved.
from vinecopula.
Really appreciate for the assistance!
from vinecopula.
Related Issues (20)
- 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)
- BiCopTau2Par for Frank HOT 10
- 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
- Regarding the utilization of copula families HOT 2
- Calculating conditional probability using BiCopCDF HOT 8
- Is there a substitute function for CDVine:: CDVineSeqEst? HOT 2
- "BB8" transform to family number not present in BiCopName HOT 2
- How to predict under specified conditions using vine copula HOT 2
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.