Skip to content

Commit

Permalink
unlucky
Browse files Browse the repository at this point in the history
  • Loading branch information
tnagler committed Mar 10, 2024
1 parent 6260029 commit 605ce2e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
5 changes: 2 additions & 3 deletions inst/include/vinecopulib/vinecop/implementation/class.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -1166,13 +1166,12 @@ Vinecop::rosenblatt_discrete(const Eigen::MatrixXd& u,
// fill first row of hfunc2 matrix with evaluation points;
// points have to be reordered to correspond to natural order
for (size_t j = 0; j < d_; ++j) {
hfunc2.col(j) = u.block(b.begin, order[j] - 1, b.size, 1);
hfunc2.col(j) = uu.block(b.begin, order[j] - 1, b.size, 1);
if (var_types_[order[j] - 1] == "d") {
hfunc2_sub.col(j) =
u.block(b.begin, d_ + disc_cols[order[j] - 1], b.size, 1);
uu.block(b.begin, d_ + disc_cols[order[j] - 1], b.size, 1);
}
}
hfunc1_sub = Eigen::MatrixXd::Zero(b.size, d);

for (size_t tree = 0; tree < trunc_lvl; ++tree) {
tools_interface::check_user_interrupt(
Expand Down
19 changes: 11 additions & 8 deletions tests/testthat/test_rosenblatt.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,25 @@ test_that("rosenblatt works with vine copulas", {

test_that("rosenblatt_discrete works with vine copulas", {
u <- rvinecop(2000, vc)
uu <- cbind(u, u)
uu <- cbind(u, u[, 2])

thresh <- 0.05
uu[, 1:3][u < thresh] <- 1e-10
uu[, -(1:3)][u < thresh] <- thresh
uu[u[, 2] < thresh, 2] <- 1e-10
uu[u[, 2] < thresh, 4] <- thresh

vc_c <- vc <- vinecop(uu, var_types = rep("d", 3), structure = mat, family = "clay")
vc_c <- vc <- vinecop(uu, var_types = c("c", "d", "c"),
structure = mat, family = "clay")
vc_c$var_types = rep("c", 3)

v <- inverse_rosenblatt(rosenblatt_discrete(uu, vc), vc_c)
expect_eql(v, u, tol = 2 * thresh)
pairs(cbind(v, u))

for (i in 1:50) {
rosenblatt_discrete(uu, vc)
}
# other format
uu <- cbind(u, u)
uu[u[, 2] < thresh, 2] <- 1e-10
uu[u[, 2] < thresh, 5] <- thresh
v <- inverse_rosenblatt(rosenblatt_discrete(uu, vc), vc_c)
expect_eql(v, u, tol = 2 * thresh)
})

test_that("rosenblatt works with vine distribution", {
Expand Down

0 comments on commit 605ce2e

Please sign in to comment.