Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ocbe-uio/BayesMallows
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.1.0
Choose a base ref
...
head repository: ocbe-uio/BayesMallows
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 16 commits
  • 97 files changed
  • 3 contributors

Commits on Mar 14, 2024

  1. Solving CRAN issue (#403)

    * fixing the issue
    
    * styling
    osorensen authored Mar 14, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    6f6b85d View commit details

Commits on Mar 26, 2024

  1. Fixing lots of issue (#415)

    * incrementing dev version
    
    * updating news
    
    * Allow different initial values across particles also when using pairwise preference data (#406)
    
    * simplifications
    
    * used Cpp for all_topological_sorts. Much much faster, since it is recursive code
    
    * converted preferences to matrix for SMC
    
    * starting to set up preferences
    
    * done
    
    * styling
    
    * removed shuffle_unranked argument
    
    * restructured arguments to setup_rank_data for pairwise preferences
    
    * fixing some errors
    
    * removing unnecessary statement
    
    * fixed bug in augmented rankings for existing users
    
    * made a better progress reporter
    
    * updated news and description
    
    * fixed #407 (#408)
    
    * Fixing bug in Ulam distance (#411)
    
    * fixed bug and added test
    
    * simplifying
    
    * styling
    
    * Exporting exact partition function (#412)
    
    * fixing documentation typo
    
    * fixing #409
    
    * Consistency checks with pairwise preferences (#414)
    
    * fixed issue with updated users with pairwise preferences
    
    * fixed #404
    osorensen authored Mar 26, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ad4b935 View commit details

Commits on Apr 19, 2024

  1. Lots of updates (#416)

    * incrementing dev version
    
    * updating news
    
    * Allow different initial values across particles also when using pairwise preference data (#406)
    
    * simplifications
    
    * used Cpp for all_topological_sorts. Much much faster, since it is recursive code
    
    * converted preferences to matrix for SMC
    
    * starting to set up preferences
    
    * done
    
    * styling
    
    * removed shuffle_unranked argument
    
    * restructured arguments to setup_rank_data for pairwise preferences
    
    * fixing some errors
    
    * removing unnecessary statement
    
    * fixed bug in augmented rankings for existing users
    
    * made a better progress reporter
    
    * updated news and description
    
    * fixed #407 (#408)
    
    * Fixing bug in Ulam distance (#411)
    
    * fixed bug and added test
    
    * simplifying
    
    * styling
    
    * Exporting exact partition function (#412)
    
    * fixing documentation typo
    
    * fixing #409
    
    * Consistency checks with pairwise preferences (#414)
    
    * fixed issue with updated users with pairwise preferences
    
    * fixed #404
    
    * improved cpp code for topological sorts
    
    * incrementing dev version
    
    * generating all topological sorts in random order
    
    * adding save=TRUE argument where necessary
    
    * incrementing and updating
    
    * updating cran comments
    
    * fixing a long-running example
    
    * fixing CodeFactor issues
    osorensen authored Apr 19, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    49d459d View commit details
  2. updating cran comments

    osorensen committed Apr 19, 2024
    Copy the full SHA
    1a6a0b5 View commit details
  3. hotfix

    osorensen committed Apr 19, 2024
    Copy the full SHA
    39710ba View commit details
  4. updating news

    osorensen committed Apr 19, 2024
    Copy the full SHA
    8d0d7db View commit details

Commits on Jul 8, 2024

  1. Fixed bug in likelihood calculation with clusters (#419)

    * dev version
    
    * Ulam bug 417 (#418)
    
    * hotfix
    
    * updating news
    
    * fixing Ulam issue
    
    * incrementing version before running CRAN tests
    
    * updating news.md to say that no bug in Ulam distance has been fixed
    
    * fixing error in likelihood calculation
    
    * added unit test for log likelihood with clusters
    
    * fixed namespace thing
    
    * switching to vapply for safety
    
    * fixing some more wrong test expectations
    osorensen authored Jul 8, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    039e234 View commit details

Commits on Aug 15, 2024

  1. Develop (#420)

    * dev version
    
    * Ulam bug 417 (#418)
    
    * hotfix
    
    * updating news
    
    * fixing Ulam issue
    
    * incrementing version before running CRAN tests
    
    * updating news.md to say that no bug in Ulam distance has been fixed
    
    * fixing error in likelihood calculation
    
    * added unit test for log likelihood with clusters
    
    * fixed namespace thing
    
    * switching to vapply for safety
    
    * fixing some more wrong test expectations
    
    * ready for cran
    osorensen authored Aug 15, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    771fa30 View commit details

Commits on Jan 6, 2025

  1. fixed cluster thinning bug (#424)

    osorensen authored Jan 6, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    198a8dc View commit details
  2. ready to run cran checks

    osorensen committed Jan 6, 2025
    Copy the full SHA
    fc568ed View commit details
  3. updating readme

    osorensen committed Jan 6, 2025
    Copy the full SHA
    70bdb96 View commit details

Commits on Jan 14, 2025

  1. dontrunning example

    osorensen committed Jan 14, 2025
    Copy the full SHA
    ce80f8f View commit details
  2. more skipping

    osorensen committed Jan 14, 2025
    Copy the full SHA
    b2e1377 View commit details
  3. more test fixing

    osorensen committed Jan 14, 2025
    Copy the full SHA
    8de89af View commit details

Commits on Feb 10, 2025

  1. ggplot2 future proofing (#426)

    * stabilise label access
    
    * repair mistake
    
    * updated version and news
    
    ---------
    
    Co-authored-by: Teun van den Brand <[email protected]>
    osorensen and teunbrand authored Feb 10, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    8f04146 View commit details

Commits on Feb 11, 2025

  1. Fixed test CI (#428)

    * Regenerated test coverage CI (#427)
    
    Reran `usethis::use_github_action()` and made minor adjustments.
    
    * Improved wording (#427)
    wleoncio authored Feb 11, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    3bbef53 View commit details
Showing with 1,423 additions and 507 deletions.
  1. +26 −8 .github/workflows/test-coverage.yaml
  2. +1 −0 BayesMallows.Rproj
  3. +2 −3 DESCRIPTION
  4. +2 −0 NAMESPACE
  5. +59 −0 NEWS.md
  6. +6 −2 R/RcppExports.R
  7. +0 −26 R/all_topological_sorts.R
  8. +26 −0 R/compute_exact_partition_function.R
  9. +7 −8 R/compute_mallows.R
  10. +5 −4 R/compute_mallows_mixtures.R
  11. +15 −0 R/compute_mallows_sequentially.R
  12. +2 −2 R/estimate_partition_function.R
  13. +21 −56 R/generate_initial_ranking.R
  14. +2 −4 R/generate_transitive_closure.R
  15. +1 −1 R/get_cardinalities.R
  16. +11 −16 R/get_mallows_loglik.R
  17. +27 −0 R/set_progress_report.R
  18. +10 −1 R/set_smc_options.R
  19. +16 −27 R/setup_rank_data.R
  20. +10 −0 R/smc_misc.R
  21. +2 −2 R/tidy_mcmc.R
  22. +11 −4 R/update_mallows.R
  23. +1 −1 R/validation_functions.R
  24. +3 −4 README.Rmd
  25. +2 −1 README.md
  26. +26 −8 cran-comments.md
  27. +11 −0 inst/examples/compute_exact_partition_function_example.R
  28. +2 −2 inst/examples/compute_mallows_example.R
  29. +3 −1 inst/examples/compute_mallows_sequentially_example.R
  30. +2 −0 inst/examples/estimate_partition_function_example.R
  31. +2 −4 inst/examples/label_switching_example.R
  32. +2 −0 inst/examples/sample_prior_example.R
  33. +8 −3 inst/examples/update_mallows_example.R
  34. +48 −0 man/compute_exact_partition_function.Rd
  35. +9 −12 man/compute_mallows.Rd
  36. +3 −4 man/compute_mallows_mixtures.Rd
  37. +3 −1 man/compute_mallows_sequentially.Rd
  38. +4 −1 man/estimate_partition_function.Rd
  39. BIN man/figures/README-unnamed-chunk-5-1.png
  40. BIN man/figures/README-unnamed-chunk-6-1.png
  41. BIN man/figures/README-unnamed-chunk-8-1.png
  42. +2 −1 man/get_cardinalities.Rd
  43. +1 −0 man/get_transitive_closure.Rd
  44. +8 −3 man/plot.SMCMallows.Rd
  45. +2 −0 man/sample_prior.Rd
  46. +1 −0 man/set_compute_options.Rd
  47. +1 −0 man/set_initial_values.Rd
  48. +1 −0 man/set_model_options.Rd
  49. +1 −0 man/set_priors.Rd
  50. +38 −0 man/set_progress_report.Rd
  51. +12 −1 man/set_smc_options.Rd
  52. +15 −26 man/setup_rank_data.Rd
  53. +8 −3 man/update_mallows.Rd
  54. +19 −4 src/RcppExports.cpp
  55. +104 −0 src/all_topological_sorts.cpp
  56. +3 −0 src/all_topological_sorts.h
  57. +56 −33 src/distances.cpp
  58. +0 −4 src/distances.h
  59. +3 −0 src/missing_data.h
  60. +14 −10 src/missing_data_functions.cpp
  61. +51 −10 src/particles.cpp
  62. +2 −1 src/particles.h
  63. +3 −2 src/progress_reporter.cpp
  64. +1 −1 src/progress_reporter.h
  65. +2 −1 src/rank_proposal.cpp
  66. +3 −5 src/rank_proposal.h
  67. +2 −2 src/run_mcmc.cpp
  68. +1 −1 src/run_smc.cpp
  69. +1 −0 src/smc_augmentation_class.cpp
  70. +3 −0 src/smc_classes.h
  71. +13 −1 src/smc_data_class.cpp
  72. +0 −78 src/subset.cpp
  73. +6 −0 tests/testthat.R
  74. +1 −0 tests/testthat/test-acceptance_ratio.R
  75. +52 −38 tests/testthat/test-assess_convergence.R
  76. +25 −0 tests/testthat/test-assign_cluster.R
  77. +35 −0 tests/testthat/test-compute_exact_partition_function.R
  78. +1 −0 tests/testthat/test-compute_mallows.R
  79. +21 −0 tests/testthat/test-compute_mallows_sequentially.R
  80. +23 −0 tests/testthat/test-compute_rank_distance.R
  81. +1 −0 tests/testthat/test-estimate_partition_function.R
  82. +22 −2 tests/testthat/test-get_mallows_loglik.R
  83. +2 −2 tests/testthat/test-mcmc_correctness.R
  84. +2 −1 tests/testthat/test-plot.R
  85. +3 −2 tests/testthat/test-plot_elbow.R
  86. +6 −4 tests/testthat/test-plot_top_k.R
  87. +20 −0 tests/testthat/test-set_progress_report.R
  88. +8 −16 tests/testthat/test-setup_rank_data.R
  89. +94 −4 tests/testthat/test-smc_pairwise.R
  90. +25 −15 tests/testthat/test-smc_update_correctness.R
  91. +44 −0 work-docs/bughunting.R
  92. +1 −1 work-docs/docker.sh
  93. +29 −29 work-docs/pairwise_smc.R
  94. +37 −0 work-docs/topological_sorts.R
  95. +87 −0 work-docs/topological_sorts.cpp
  96. +46 −0 work-docs/ulam.cpp
  97. +70 −0 work-docs/validate_pairwise_ls.R
34 changes: 26 additions & 8 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
@@ -8,37 +8,55 @@ on:

name: test-coverage

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
covr::codecov(
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
# Fail if error if not on PR, or if on PR and token is given
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
- name: Upload test results

- name: Upload failures, if any
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
1 change: 1 addition & 0 deletions BayesMallows.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: 6e0ef04a-160c-463b-bc1b-40b5326f6cb9

RestoreWorkspace: No
SaveWorkspace: No
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: BayesMallows
Type: Package
Title: Bayesian Preference Learning with the Mallows Rank Model
Version: 2.1.0
Version: 2.2.3.9000
Authors@R: c(person("Oystein", "Sorensen",
email = "oystein.sorensen.1985@gmail.com",
role = c("aut", "cre"),
@@ -46,12 +46,11 @@ BugReports: https://github.com/ocbe-uio/BayesMallows/issues
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Depends: R (>= 3.5.0)
Imports: Rcpp (>= 1.0.0),
ggplot2 (>= 3.1.0),
Rdpack (>= 1.0),
igraph (>= 1.2.5),
sets (>= 1.0-18),
relations (>= 0.6-8),
rlang (>= 0.3.1)
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ export(assess_convergence)
export(assign_cluster)
export(burnin)
export(compute_consensus)
export(compute_exact_partition_function)
export(compute_expected_distance)
export(compute_mallows)
export(compute_mallows_mixtures)
@@ -52,6 +53,7 @@ export(set_compute_options)
export(set_initial_values)
export(set_model_options)
export(set_priors)
export(set_progress_report)
export(set_smc_options)
export(setup_rank_data)
export(update_mallows)
59 changes: 59 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
# BayesMallows (development versions)

* Making plotting functionality compatible with future versions of ggplot2.

# BayesMallows 2.2.3

* Fixed bug, clus_thinning argument did not work in the case of a single
cluster. Thanks to Timothy Lee for pointing this out. Issue #423 on GitHub.

# BayesMallows 2.2.2

* An error in compute_mallows_loglik when the number of clusters is more than
one has been corrected. Thanks to Marta Crispino.

# BayesMallows 2.2.1

* Skipping a unit test which failed on CRAN's M1 Mac builder.

# BayesMallows 2.2.0

* For initialization of latent ranks when using pairwise preference data, all
topological sorts are now generated in random order.
* The SMC function now check for consistency with previous latent ranks for
existing users also when data arrive in the form of pairwise preferences.
* A function compute_exact_partition_function() is now added, which returns the
logarithm of the exact partition function for Cayley, Hamming, and Kendall
distance.
* Fixed a bug in the Ulam distance. Thanks for Marta Crispino for discovering
it.
* Fixed a bug in SMC algorithm for pairwise preference data, where the proposal
distribution incorrectly was assumed to be uniform.
* It is now possible to report progress of MCMC more flexibly using
compute_mallows() or compute_mallows_mixtures(). The old argument "verbose"
which by default reported every 1000'th iteration has been replaced by an
argument "progress_report" which can be set by calling set_progress_report().
The latter allows setting the interval between reports. This is particularly
useful for big data, where running 1000 iterations may take very long time.
* Fixed a bug which caused inconsistent partial rank data to be retained from
previous timepoints when existing users update their preferences.
* Arguments random and random_limit to setup_rank_data() have been removed. A
new argument max_topological_sorts has been added instead, which captures all
previous use cases, but also allows the user to specify the number of
topological sorts to generate. This makes it useful also with a relatively
large number of items, while it previously would be computationally unfeasible
for anything more than 8-9 items.
* Argument shuffle_unranked to setup_rank_data() has been removed. If there are
unranked items they will now always be shuffled. For reproducibility, set the
random number seed.
* SMC Mallows with pairwise preference data now allows different initially
values for the augmented rankings across the particles. This is obtained by
generating (a subset of) all topological sorts consistent with the transitive
closure for the user, and sampling from these. Can be set with the
max_topological_sorts argument to set_smc_options().

# BayesMallows 2.1.1

* Fixed gcc-UBSAN issue happening when compute_mallows_sequentially() is run
without user IDs specified.

# BayesMallows 2.1.0

* The SMC method update_mallows() now supports pairwise preferences, both new
8 changes: 6 additions & 2 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -5,6 +5,10 @@ abind <- function(x, y) {
.Call(`_BayesMallows_abind`, x, y)
}

all_topological_sorts <- function(prefs, n_items, maxit, save) {
.Call(`_BayesMallows_all_topological_sorts`, prefs, n_items, maxit, save)
}

#' Asymptotic Approximation of Partition Function
#'
#' Compute the asymptotic approximation of the logarithm of the partition function,
@@ -68,8 +72,8 @@ rmallows <- function(rho0, alpha0, n_samples, burnin, thinning, leap_size = 1L,
.Call(`_BayesMallows_rmallows`, rho0, alpha0, n_samples, burnin, thinning, leap_size, metric)
}

run_mcmc <- function(data, model_options, compute_options, priors, initial_values, pfun_values, pfun_estimate, verbose = FALSE) {
.Call(`_BayesMallows_run_mcmc`, data, model_options, compute_options, priors, initial_values, pfun_values, pfun_estimate, verbose)
run_mcmc <- function(data, model_options, compute_options, priors, initial_values, pfun_values, pfun_estimate, progress_report) {
.Call(`_BayesMallows_run_mcmc`, data, model_options, compute_options, priors, initial_values, pfun_values, pfun_estimate, progress_report)
}

run_smc <- function(data, new_data, model_options, smc_options, compute_options, priors, initial_values, pfun_values, pfun_estimate) {
26 changes: 0 additions & 26 deletions R/all_topological_sorts.R

This file was deleted.

26 changes: 26 additions & 0 deletions R/compute_exact_partition_function.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#' @title Compute exact partition function
#'
#' @description For Cayley, Hamming, and Kendall distances, computationally
#' tractable functions are available for the exact partition function.
#'
#' @param alpha Dispersion parameter.
#' @param n_items Number of items.
#' @param metric Distance function, one of "cayley", "hamming", or "kendall".
#'
#' @return The logarithm of the partition function.
#' @export
#'
#' @references \insertAllCited{}
#'
#' @example inst/examples/compute_exact_partition_function_example.R
#' @family partition function
compute_exact_partition_function <- function(
alpha, n_items,
metric = c("cayley", "hamming", "kendall")) {
metric <- match.arg(metric, c("cayley", "hamming", "kendall"))
validate_integer(n_items)
validate_positive(n_items)
validate_positive(alpha)

get_partition_function(alpha, n_items, metric, NULL)
}
15 changes: 7 additions & 8 deletions R/compute_mallows.R
Original file line number Diff line number Diff line change
@@ -14,8 +14,8 @@
#' is the latent consensus ranking, \eqn{Z_{n}(\alpha)} is the partition
#' function (normalizing constant), and \eqn{d(r,\rho)} is a distance function
#' measuring the distance between \eqn{r} and \eqn{\rho}. We refer to
#' \insertCite{vitelli2018;textual}{BayesMallows} for further details of the Bayesian
#' Mallows model.
#' \insertCite{vitelli2018;textual}{BayesMallows} for further details of the
#' Bayesian Mallows model.
#'
#' `compute_mallows` always returns posterior distributions of the latent
#' consensus ranking \eqn{\rho} and the scale parameter \eqn{\alpha}. Several
@@ -44,9 +44,8 @@
#' Ulam distances when the cardinalities are not available, cf.
#' [get_cardinalities()].
#'
#' @param verbose Logical specifying whether to print out the progress of the
#' Metropolis-Hastings algorithm. If `TRUE`, a notification is printed
#' every 1000th iteration. Defaults to `FALSE`.
#' @param progress_report An object of class "BayesMallowsProgressReported"
#' returned from [set_progress_report()].
#'
#' @param cl Optional cluster returned from [parallel::makeCluster()]. If
#' provided, chains will be run in parallel, one on each node of `cl`.
@@ -70,7 +69,7 @@ compute_mallows <- function(
priors = set_priors(),
initial_values = set_initial_values(),
pfun_estimate = NULL,
verbose = FALSE,
progress_report = set_progress_report(),
cl = NULL) {
validate_class(data, "BayesMallowsData")
validate_class(model_options, "BayesMallowsModelOptions")
@@ -92,7 +91,7 @@ compute_mallows <- function(
} else {
lapplyfun <- prepare_cluster(cl, c(
"data", "model_options", "compute_options", "priors", "initial_values",
"pfun_values", "pfun_estimate", "verbose"
"pfun_values", "pfun_estimate", "progress_report"
))
chain_seq <- seq_along(cl)
}
@@ -109,7 +108,7 @@ compute_mallows <- function(
initial_values = initial_values,
pfun_values = pfun_values,
pfun_estimate = pfun_estimate,
verbose = verbose
progress_report = progress_report
)
})

9 changes: 5 additions & 4 deletions R/compute_mallows_mixtures.R
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ compute_mallows_mixtures <- function(
priors = set_priors(),
initial_values = set_initial_values(),
pfun_estimate = NULL,
verbose = FALSE,
progress_report = set_progress_report(),
cl = NULL) {
stopifnot(is.null(cl) || inherits(cl, "cluster"))

@@ -40,15 +40,16 @@ compute_mallows_mixtures <- function(
} else {
lapplyfun <- prepare_cluster(cl, c(
"data", "model_options", "compute_options", "priors", "initial_values",
"pfun_estimate", "verbose"
"pfun_estimate", "progress_report"
))
}

models <- lapplyfun(n_clusters, function(x) {
model_options$n_clusters <- x
compute_mallows(
data = data, model_options = model_options, compute_options = compute_options,
priors = priors, initial_values = initial_values, verbose = verbose
data = data, model_options = model_options,
compute_options = compute_options, priors = priors,
initial_values = initial_values, progress_report = progress_report
)
})

15 changes: 15 additions & 0 deletions R/compute_mallows_sequentially.R
Original file line number Diff line number Diff line change
@@ -54,6 +54,21 @@ compute_mallows_sequentially <- function(
if (!is.list(data) | !all(vapply(data, inherits, logical(1), "BayesMallowsData"))) {
stop("data must be a list of BayesMallowsData objects.")
}
if (any(
vapply(data, function(x) {
is.null(x$user_ids) || length(x$user_ids) == 0
}, logical(1))
)) {
stop("User IDs must be set.")
}
data <- lapply(data, function(x) {
if (!is.null(x$preferences)) {
x$preferences <- as.matrix(x$preferences)
} else {
x$preferences <- matrix(0, 0, 0)
}
x
})
pfun_values <- extract_pfun_values(model_options$metric, data[[1]]$n_items, pfun_estimate)
alpha_init <- sample(initial_values$alpha, smc_options$n_particles, replace = TRUE)
rho_init <- initial_values$rho[, sample(ncol(initial_values$rho), smc_options$n_particles, replace = TRUE)]
4 changes: 2 additions & 2 deletions R/estimate_partition_function.R
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
#' any number of items, for footrule distances with up to 50 items, Spearman
#' distance with up to 20 items, and Ulam distance with up to 60 items. This
#' function is thus intended for the complement of these cases. See
#' [get_cardinalities()] for details.
#' [get_cardinalities()] and [compute_exact_partition_function()] for details.
#'
#' @param method Character string specifying the method to use in order to
#' estimate the logarithm of the partition function. Available options are
@@ -122,7 +122,7 @@ extract_pfun_values <- function(metric, n_items, pfun_estimate) {
"estimate in argument pfun_estimate."
)
} else {
return(NULL)
NULL
}
}
)
Loading