Closed weiqianxi1314 closed 1 week ago
While a vine's PDF admits a closed-form expression, its CDF does not.
Note that the rvinecopulib package provides a pvinecop method which computes the vine's CDF via quasi Monte Carlo integration.
Could someone give me a clue on how to calculate the VineCDF, i have hit a dead end here.
What exactly did you try? As mentioned, there is no RVineCDF in VineCopula, but you are welcome to use rvinecopulib, or implementing a Monte Carlo version... A quick example:
RVineCDF <- function(u, N, RVM, seed=42) {
# Set random seed
set.seed(seed)
# Simulate N quasi-random numbers from the vine model
u_sim <- RVineSim(N, RVM)
# Initialize output vector
n <- nrow(u)
vine_distribution <- numeric(n)
# Compute the cumulative distribution
for (i in seq_len(n)) {
temp <- u[i, ]
# Calculate the maximum difference row-wise between u_sim and temp
x <- apply(u_sim, 1, function(row) max(row - temp))
# Count occurrences where all differences are <= 0
vine_distribution[i] <- sum(x <= 0)
}
# Return normalized cumulative distribution
return(vine_distribution / N)
}
Solved by #97.
I want to know why there is an RVinePDF function, but not an RVineCDF function. Many times, it is necessary to calculate the cumulative probability without a corresponding method function.