Skip to content

Commit

Permalink
Separate out and comment out the tests for the equivalence of cumulat…
Browse files Browse the repository at this point in the history
…ive() and sratio() for the cloglog link (see <paul-buerkner#1137 (comment)>).
  • Loading branch information
fweber144 committed May 5, 2021
1 parent 36727dd commit d5242a4
Showing 1 changed file with 45 additions and 12 deletions.
57 changes: 45 additions & 12 deletions tests/testthat/tests.distributions.R
Original file line number Diff line number Diff line change
Expand Up @@ -322,46 +322,79 @@ test_that("inv_link_<ordinal_family>() works correctly for arrays", {

test_that(paste(
"dsratio() and dcratio() give the same results for symmetric distribution",
"functions and that dcumulative() and dsratio() give the same results for",
"the cloglog link"
"functions"
), {
source(testthat::test_path(file.path("helpers", "d_ordinal_sim.R")))
for (eta_test in eta_test_list) {
for (link in c("logit", "probit", "cauchit", "cloglog")) {
d_cumul <- dcumulative(seq_len(ncat),
eta_test, thres_test, link = link)
d_sratio <- dsratio(seq_len(ncat),
eta_test, thres_test, link = link)
d_cratio <- dcratio(seq_len(ncat),
eta_test, thres_test, link = link)
if (link != "cloglog") {
expect_equal(d_sratio, d_cratio)
expect_false(isTRUE(all.equal(d_sratio, d_cumul)))
} else {
expect_false(isTRUE(all.equal(d_sratio, d_cratio)))
expect_equal(d_sratio, d_cumul)
}
}
}
})

### TODO: Clarify why the equivalence between sratio() and cumulative() in case
### of the cloglog link does not hold (it should, at least according to
### Appendix A of <https://doi.org/10.1177%2F2515245918823199>):
# test_that(paste(
# "dcumulative() and dsratio() give the same results for the cloglog link"
# ), {
# source(testthat::test_path(file.path("helpers", "d_ordinal_sim.R")))
# for (eta_test in eta_test_list) {
# for (link in c("logit", "probit", "cauchit", "cloglog")) {
# d_cumul <- dcumulative(seq_len(ncat),
# eta_test, thres_test, link = link)
# d_sratio <- dsratio(seq_len(ncat),
# eta_test, thres_test, link = link)
# if (link != "cloglog") {
# expect_false(isTRUE(all.equal(d_sratio, d_cumul)))
# } else {
# expect_equal(d_sratio, d_cumul)
# }
# }
# }
# })
###

test_that(paste(
"inv_link_sratio() and inv_link_cratio() applied to arrays give the same",
"results for symmetric distribution functions and that inv_link_cumulative()",
"and inv_link_sratio() applied to arrays give the same results for the",
"cloglog link"
"results for symmetric distribution functions"
), {
source(testthat::test_path(file.path("helpers", "inv_link_ordinal_sim.R")))
for (link in c("logit", "probit", "cauchit", "cloglog")) {
il_cumul <- inv_link_cumulative(x_test, link = link)
il_sratio <- inv_link_sratio(x_test, link = link)
il_cratio <- inv_link_cratio(nx_test, link = link)
if (link != "cloglog") {
expect_equal(il_sratio, il_cratio)
expect_false(isTRUE(all.equal(il_sratio, il_cumul)))
} else {
expect_false(isTRUE(all.equal(il_sratio, il_cratio)))
expect_equal(il_sratio, il_cumul)
}
}
})

### TODO: Clarify why the equivalence between sratio() and cumulative() in case
### of the cloglog link does not hold (it should, at least according to
### Appendix A of <https://doi.org/10.1177%2F2515245918823199>):
# test_that(paste(
# "inv_link_cumulative() and inv_link_sratio() applied to arrays give the same",
# "results for the cloglog link"
# ), {
# source(testthat::test_path(file.path("helpers", "inv_link_ordinal_sim.R")))
# for (link in c("logit", "probit", "cauchit", "cloglog")) {
# il_cumul <- inv_link_cumulative(x_test, link = link)
# il_sratio <- inv_link_sratio(x_test, link = link)
# if (link != "cloglog") {
# expect_false(isTRUE(all.equal(il_sratio, il_cumul)))
# } else {
# expect_equal(il_sratio, il_cumul)
# }
# }
# })
###

0 comments on commit d5242a4

Please sign in to comment.