-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new version for how smc_mallows_new_item_rank_* is initialised #198
Comments
Sounds interesting, show me the code! :) |
Hi @anjastein, just started getting back to this now that 1.2.0 is out and the API has settled a bit. Quick question. The code you sent me back in April mentions two functions, |
Yes, that sounds about right! :) |
From @anjastein > The script called `updated_rankings_functions_for_waldir.R` contains the new functions that would benefit from being translated from R to C++. A lot of the code suffers from DRY (two very similar functions but in one of them the variable alpha is fixed) and probably uses a lot of code that you have created in the BayesMallows SMC extension of the CRAN package already, so I hope it won't be time-consuming.
Defaults to NULL, in which case `initialize_rho()` is called, as per the previous implementation. squash! Added default to `rho_samples_init` (#198)
This restores the behavior from the previous version, which is to _silently_ generate alpha_samples. Since the warning introduced on commit f2bd74c was removed, the test unit introduced there makes no sense anymore, so it was removed.
Copy-pasted from previous version of `smc_mallows_new_item_rank()`.
Test script modified to reduce code footprint and execution time. Test on local machine showed a reduction from 144 s to 0.3 s to run the affected script.
* Added original script (#198) From @anjastein > The script called `updated_rankings_functions_for_waldir.R` contains the new functions that would benefit from being translated from R to C++. A lot of the code suffers from DRY (two very similar functions but in one of them the variable alpha is fixed) and probably uses a lot of code that you have created in the BayesMallows SMC extension of the CRAN package already, so I hope it won't be time-consuming. * Roxygenized docs, split unit tests (#198) * Commented out temporarily-broken tests (#198) * Removed explicit calls to the function (#198) * Replaced `abort()` calls with `stop()` (#198) * Updated renamed functions See commit 375a6f6 for details. * Updated proposed code to the 1.2.0 API * Restyled file * Added TODOs * Minor doc fix (#198) * Adding `smc_mallows_new_item_rank_updated_cpp()` (#198) * Adding default value to `alpha_samples_init` The alpha-fixed variant does not use it. * Wrapping unit tests around `test_that()` (#198) * Updated build version * Added TODO * Improved variable declaration * Updated docs and Rcpp exports * Increment version number to 1.2.0.9002 * Syntax fixes (#198) * Updated unit tests to use C++ version (#198) * Improved handling of alpha_fixed without alpha_samples_init (#198) * Updated docs, RoxygenNote version * Replaced original R functions with C++ (#198) * Merged identical functions (#198) * Replaced `smc_mallows_new_item_rank()` (#198) Subfunction was also moved away from _back_ into , since it's not being used anywhere else * Updated deprecated smc_mallows_new_rank funcs Rerouting to new function deleted because the arguments mismatch. squash! fixup! Updated deprecated smc_mallows_new_rank funcs * Added default to `rho_samples_init` (#198) Defaults to NULL, in which case `initialize_rho()` is called, as per the previous implementation. squash! Added default to `rho_samples_init` (#198) * Adapted unit tests accordingly to #198 updates * Removed warning when `alpha_samples_init` is not provided (#198) This restores the behavior from the previous version, which is to _silently_ generate alpha_samples. Since the warning introduced on commit f2bd74c was removed, the test unit introduced there makes no sense anymore, so it was removed. * Added function to augment rankings (#198) Copy-pasted from previous version of `smc_mallows_new_item_rank()`. * Augment ranking if empty aug_rankings_init (#198) * Added error expectation to unit tests * Fixed warnings caused by comparison between int and uword * Fixed test unit syntax The removed bit was depending on `smc_test_new_user_unif`, an object which has not been created at that point. This issue was present in the original script. Also, the error message is now explicitly mentioned to match the purpose of this particular test unit. * Added TODO * Simplified syntax (#198) * Moved test further down the script To a place where all inputs are already defined. * Allowing `aug_rankings_init` to be nullable * Adapted test expectations * Code style adjustments * Drastically reduced test execution time (#198) Test script modified to reduce code footprint and execution time. Test on local machine showed a reduction from 144 s to 0.3 s to run the affected script. * Replacing casting function with one-liner (#198) Source: #252 (comment) * Replacing arma for Rcpp on function argument (#198) Source: #252 (comment) Co-authored-by: Anja Stein <a.stein1@lancaster.ac.uk> Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com>
Closed due to merging of #252. Please report any outstanding bugs on a new issue. |
* incremented to development version * Add linter CI (#167) * replaced purrr with lapply in plot_elbow and wrote an extra test * change purrr with Map in sample_mallows * replaced purrr with lapply in compute_mallows_mixtures * removed purrr from compute_posterior_intervals * removed purrr from assess_convergence * removed purrr from rank conversion * replaced purrr with vapply et al in print function and added test * removed purrr from compute_mallows * removed purrr from generate_constraints and from a test * removed purrr from Imports and incremented development version * removed library call to purrr * replaced map with lapply in example * removed another call to map * hope I soon have removed every piece of purrr * updated docs * Untidyr (#154) * removed tidyr from sample_mallows * removed tidyr from assign_cluster * removed tidyr from predict_top_k and updated tests * replaced tidyr in plot_top_k * replaced one tidyr in compute_consensus * replaced tidyr in compute_consensus and updated tests * replaced tidyr in generate_constraints * replaced tidyr in test_compute_mallows * removed a whole lot of dependencies * removed tidyr from Imports * updated news * Untidyr (#156) * removed tidyr from sample_mallows * removed tidyr from assign_cluster * removed tidyr from predict_top_k and updated tests * replaced tidyr in plot_top_k * replaced one tidyr in compute_consensus * replaced tidyr in compute_consensus and updated tests * replaced tidyr in generate_constraints * replaced tidyr in test_compute_mallows * removed a whole lot of dependencies * removed tidyr from Imports * updated news * moved permutations function to R/misc.R * Removed permfun.R and remaining source of it * SMC-Mallows (#157) * Identified more codelines related to #90 * Reclassified Rcpp objects as arma (#90) In the smc_leap_and_shift_probs() function. * Increment version number * Fixed unit tests * Updated TODOs * Increment version number * Replaced Rcpp::sample with arma::randi (#90) * Adjusted unit tests * Replaced Rcpp vector with arma vector (#90) * Removed TODO For the moment, smc_mallows_new_users_complete() will still use Rcpp::sample() to calculate the arma::uvec index. Replacement of Rcpp::sample() with arma::rand*() is encouraged, but left to any future developer aware of how to include probability weights on arma::rand*(). For more details, see conversation in issue #90. * Rearranged inline comments Top comment was relocated and rewritten on https://github.com/ocbe-uio/BayesMallows/issues/90#issuecomment-866614296 for better visibility and organization. Mid-code comment added for future reference. * Syntax fix * Reduced example length (closes #96) * Increment version number * Reduced unit test parameters (resolves #100) * Dropped usage of deprecated function (closes #99) * Added original scripts (#106) * Fitting scripts to package format (#106) * Added original scripts * Removed source calls, moved unit tests * Syntax fixes * Updated docs, exported new functions * Added placeholders for unit tests * Commented out failing tests These tests trigger errors on get_rank_distance(), to be investigated later (see issue #98 comments section for more details). * Increment version number * Increment version number * Syntax fix aug_prob is a vector, so we need to select just one element to perform those operations. * Fixed function name Function was using a deprecated, alternative name. * Fixed calls to get_mallows_loglik (#98, #109) * Reduced number of iterations on test * Restyled file * Fixes tests (#109) * Implemented tests (#98) * Edited test titles * Removed TODO * Improved SMC tests' speed (fixes #102) * Moved get_sample_probabilities() to src folder * Translated get_sample_probabilities + docs (#98) * Moved calculate_forward_probability to src folder * Exporting empty C++ function * Partial translation of calculate_forward_probability * Added get_sample_probabilities to smc.h * Finished translation of calculate_forward_probability Also: - Updated build version + Rcpp exports - Increment version number * Updated unit test expectations * Removed unnecessary library call * Translated calculate_backward_probability to C++ * Increment version number * Syntax fixes + refactoring * Changed file Unix permissions to match other files Used chmod to change the file permissions from 755 to 644 so it matches the rest of the files on the folder. * Added files for SMC-Mallows new item rank * Updated SMC partial rankings functions and tests * Restyled files * Syntax fixes * Commented out code to be worked on (#110) * Increment version number * Syntax fix * Formatted unit tests (#110) * Reduced test time (#110) Further test optimization Check fixes * Improvements to validation * Added SMC dataset * Improved partial ranking tests (#110) * Improved API feedback * Adapted test units for new item rank (#110) * Optimized unit tests (#110) * Minor fixes for clean check * Translated metropolis_hastings_aug_ranking_pseudo (#98) - Added skeleton of C++ metropolis_hastings_aug_ranking_pseudo - Translated metropolis_hastings_aug_ranking_pseudo - Replaced R version with C++ version - Fixed behavior of metropolis_hastings_aug_ranking_pseudo - Improved test format and updated expectations * Increment version number and R version dependency * Refactoring for easier debugging * Fixed RNG behavior on unit test * Removed superseded function * Added translation of metropolis_hastings_aug_ranking * Fixed documentation The docs for metropolis_hastings_aug_ranking_CPP() had text from the pseudo function. * Replaced R version of mh_aug_ranking with C++ (#98) Also, adjusted unit test expectations accordingly * Increment version number * Adjusted tests and renamed arguments (#98) * Added original code for correction_kernel C++ (#111) * Syntax fixes * Increment version number * Replaced R with C++ version of correction_kernel (#111) * Refactoring * Code optimization * Renamed cpp file * Added original code for correction_kernel_pseudo C++ (#111) * Syntax fixes * Replaced R with C++ of correction_kernel_pseudo (#111) * Increment version number * Replaced calculation of remaining_set * Translated smc_mallows_new_users_partial (#107) - Added C++ skeleton of smc_mallows_new_users_partial - Translated function * Set more seeds in unit tests This avoids random errors in unit testing. * Increment version number * Fixed calculation on smc_mallows_new_users_complete * Replaced R version with C++ version (#107) Of smc_mallows_new_users_partial(). * cal_fwd_prob() now works with both R and C++ indices * Refactoring * Adjusting unit tests * Returning test units to their original expectation * Updated Roxygen version * cal_bwd_prob() now works with both R and C++ indices This is basically a copy-paste from commit ce5d52cd. I smell a function coming... * Refactoring * Adjusting test expectations to new code output The differing output is caused by `set.seed(101)` having a different effect on the new C++ functions, particularly the output of `test_1_forward$aug_ranking`, which trickles down into the calculation of `test_1_backward_b`, thus causing different probabilities. The code was back-checked with the original R code, in which case the output seems the same. However, this should be checked with Anja. * Moved common code into function As "promised" on e497763640992f788c4ff0c98f6f127b99d4d785. * Translated partial ranks alpha fixed to C++ (#107) - Added skeleton of C++ alpha_fixed function - Finished translation - Switched R and C++ versions - Updated unit test expectations - Removed the R version of the function * Added parameters to SMC new users complete Added alpha_prob_sd, lambda and alpha_max, which were new arguments to metropolis_hastings_alpha and were internally defined as constants. * Added knitr as vignette engine Now both R.rsp and knitr are used as vignette builders. The former is used to add the BM paper in PDF format, the latter is hosting the SMC Rmarkdown vignette (yet a mockup). * Added mockup of SMC vignette * Updated .gitignore Update generated by `devtools::build_vignettes()`. * Updated build version * Translated new_item_rank to C++ (#113) * Replaced R new_item_rank with C++ version (#113) * Increment version number * Opening CI to all branches r.yml is currently configured for only triggering GitHub Actions CI workflow for the `master` and the `main` (inexistent here) branches. Opening it up to any branch so commits to `smc-mallows` also get triggered. This is important so we can better foresee problems in the upcoming merge with `master`. Opening up to any branch name shouldn't be a problem on this repository, since `master` is the only long-lived branch at the moment. * Syntax fixes * Refactoring * More specific seed setting * Fixing tests for Ubuntu Tests for Mac and Windows are still failing due to RNG. To be addressed later. * Investigate tests (#127) * Added prints statements to `arma::shuffle` * Added unique sort to `setdiff` * Updated tests Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> * Updates to smc_post_processing_functions.R (#119) * Updates to smc_post_processing_functions.R Hi, Just done a bit of tidying with the post_processing_functions. Here is a summary of my proposed changes: 1. edited `smc_processing` to allow the option to print the `col_names` of the original dataset if appropriate 2. edited `compute_consensus` to print the output correctly in the `MAP` case and to print the `colnames` of a dataset if appropriate instead of listing items as 'item 1, item 2, ... etc'. 3. edited `plot_posterior_intervals_rho` to print the `colnames` of a dataset if appropriate instead of listing items as 'item 1, item 2, ... etc'. 4. adjusted the font sizes of the axis labels in `plot_heatplot_rho` 5. removed the variable `verbose` from `plot_posterior_alpha` so that it now prints when calling the functions and doesn't do duplicate plots. 6. commented out any unused post-processing functions I have added some general comments, which begin with `#AS:` to explain why I have made the following changes (even though Github will highlight them). Let me know if you disagree or think any changes are unnecessary. I am planning on renaming the variables in the functions `heatMat` and `heatplot_fixed` so that they are consistent with the other heatplot functions, but I shall do this once this pull request has been completed/resolved(?). Waldir's changes: * Changed test unit expectations * Documentation fixes * Removed commented-out code * Replaced dplyr call with base R Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Updated smc.rmd Copy-pasted vignette script to github. Need to upload the matching .bib file containing the references. * create vignette.bib This file contains the references to be printed in the smc.Rmd file * Remove unused columns The final columns of rho_samples and alpha_samples do not get populated with non-zero values, so they are redundant. The same change applies to smc_mallows_new_item_rank_alpha_fixed, so this will appear as another pull request. * Remove unused column Extra column in rho_samples is redundant * Update compute_posterior_intervals_rho Reordered column in output to print item names in correct numerical order "item 1, item 2, ..., item 10" instead of "item 1, item 10, item 2, ..., item 9" * Cosmetic changes to heatplot functions Renamed variables to keep variable names consistent. Added some comments to explain the steps in the functions. * Updated test expectation Test units should be reset to expect one fewer columns, given the most recent code changes proposed. * Updated test expectations The previous changes on this branch reduce the number of columns by 1, so this must be reflected in the relevant unit test expectations. * Syntax fixes + doc update * Syntax fixes * Increment version number * Syntax adjustments * Changed test expectations back to what they should be See comment https://github.com/ocbe-uio/BayesMallows/issues/116#issuecomment-938583180 for more details. * Trying to reproduce Anja's seed and output * Increment version number * Added C++ version of smc_mallows_new_item_rank_alpha_fixed (#113) * Replaced R with C++ of smc_mallows_new_item_rank_alpha_fixed (#113) * Added C++ function of SMC new item alpha fixed (#113) * Added C++ version of smc_mallows_new_item_rank_alpha_fixed (#113) * Replaced R with C++ of smc_mallows_new_item_rank_alpha_fixed (#113) * Added C++ function of SMC new item alpha fixed (#113) * Added unit tests for #134 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> * Reduced test time * get_mallows_loglik now transposes as needed (#134) This eliminated the bug when passing rankings as a row vector and rho as a column vector (or vice-versa). Both still need to be matrices, though. * Increment version Increment version number to 1.0.3.9002 Increment version number to 1.0.3.9003 Increment version number to 1.0.3.9004 * Updated build version * Exported all functions from #117 - Exported `plot_rho_heatplot()` - Exported `plot_alpha_posterior()` - Exported `compute_posterior_intervals_alpha()` - Exported `compute_posterior_intervals_rho()` - Exported `compute_rho_consensus()` Also, some function names were renamed in comments and the SMC vignette text due to slight differences between their names there and the one on the code. The names on the code were preferred. Namely, the changes were: 1. `plot_heatplot_rho` into `plot_rho_heatplot` 2. `compute_consensus_rho` into `compute_rho_consensus` * Refactoring * Increment version number to 1.0.3.9006 * Added print argument to internal function * Updated test expectation, added comments * Added temporary print statements for debugging * Increment version number to 1.0.3.9007 * Added function plot_rho_posterior.R in smc_post_processing_functions.R (#137) * Added function plot_rho_posterior.R in smc_post_processing_functions.R * Synxtax fixes + whitespace removal * Exporting function with documentation Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Changing output of SMC function to new class Including change in test expectation. * Added generics, methods for compute_posterior_intervals * Changed classes of Mallows objects (#80) Generics and methods related to `compute_posterior_intervals()` had some class additions to allow for better dispatching between BayesMallows and SMC-Mallows methods. * Moved methods to same file (#80) Moved all methods of `compute_posterior_intervals()` and `.compute_posterior_intervals()` to the same file (easier to manage). * Syntax and documentation fixes/updates * Increment version number to 1.0.3.9006 * Updated TODOs * Update smc.Rmd Removed the heatplot function and replaced it with the plot rho posterior function. Some descriptions have changed to fit the description of the posterior function. * Remove heatplot functions Since we now have the `plot_rho_posterior` function to clearer visualisation, we can discontinue this function. * Deleted commented-out code * Updated docs * Removed unit test for dropped function * Increment version number to 1.0.3.9007 * Moved gtools from Suggests to Depends Also, standardized indentation. * Updated build version * added print statements to calculate_forward_probability.cpp Added lots of print statements to help with debugging * added print statements to calculate_backwards_probability.cpp added extra print statements for debugging * Fixed bug causing issue #116 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * Removed temporary code * Updated test expectations * Removed gtools dependency on SMC (#142) Removed dependency on gtools::mixedorder Works by extracting everything that isn't a digit ([0-9]) and ultimately using the index of the sorted elements to sort `rho_posterior_interval`. Works well for the standard "Item DD" format that SMC uses, and probably for other formats as well, but this wasn't extensively tested. * Replaced purrr::map with lapply on SMC (#142) * Replaced tidyr calls in SMC functions (#142) - Replaced tidyr::gather with stats::reshape - Replaced tidyr::spreadh with stats::reshape * Minor adjustments to SMC vignette Removed unused dependencies, Removed usage of , automatic whitespace adjustments. * Renamed SMC-Mallows vignette file So it matches the capitalization of "BayesMallows.pdf.asis" * Removed unneeded suggestions from DESCRIPTION * pedantic point * I suggest using a single file for references, to avoid duplication of data. * fixed some typos and tried to make the vignette code more consistent with the rest of the package, include <- for assignment * changed assignment operator in vignette * renamed all testfiles from test_ to test- * updated testthat version number in DESCRIPTION * ran styler on vignette * Created test which catches the warning in #159 * Fixed the warning, closes #159 * Mentions SMC in DESCRIPTION. * slight update in DESCRIPTION * updated news.md and incremented version number Co-authored-by: Anja Stein <anjastein@users.noreply.github.com> Co-authored-by: Anja Stein <anjastein@noreply.users.github.com> Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * corrected a bunch of typos and updated readme * corrected more typos with devtools::spellcheck() * accidentally deleted vignettes/BayesMallows.pdf in previous commit. fixed here * Convert MAP output to tibble (fixes #163) (#164) * Added test script for compute_rho_consensus (#163) * Minor test optimizations Restyling + shortening * Casting df as tibble (fixes #163) Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * Changed classes for compute_posterior_interval methods (#80) * Added tests to check BM and SMC classes (#80) * Implement generics to close #80 (#161) * Replaced Rcpp vector with arma vector (#90) * Removed TODO For the moment, smc_mallows_new_users_complete() will still use Rcpp::sample() to calculate the arma::uvec index. Replacement of Rcpp::sample() with arma::rand*() is encouraged, but left to any future developer aware of how to include probability weights on arma::rand*(). For more details, see conversation in issue #90. * Rearranged inline comments Top comment was relocated and rewritten on https://github.com/ocbe-uio/BayesMallows/issues/90#issuecomment-866614296 for better visibility and organization. Mid-code comment added for future reference. * Syntax fix * Reduced example length (closes #96) * Increment version number * Reduced unit test parameters (resolves #100) * Dropped usage of deprecated function (closes #99) * Added original scripts (#106) * Fitting scripts to package format (#106) * Added original scripts * Removed source calls, moved unit tests * Syntax fixes * Updated docs, exported new functions * Added placeholders for unit tests * Commented out failing tests These tests trigger errors on get_rank_distance(), to be investigated later (see issue #98 comments section for more details). * Increment version number * Increment version number * Syntax fix aug_prob is a vector, so we need to select just one element to perform those operations. * Fixed function name Function was using a deprecated, alternative name. * Fixed calls to get_mallows_loglik (#98, #109) * Reduced number of iterations on test * Restyled file * Fixes tests (#109) * Implemented tests (#98) * Edited test titles * Removed TODO * Improved SMC tests' speed (fixes #102) * Moved get_sample_probabilities() to src folder * Translated get_sample_probabilities + docs (#98) * Moved calculate_forward_probability to src folder * Exporting empty C++ function * Partial translation of calculate_forward_probability * Added get_sample_probabilities to smc.h * Finished translation of calculate_forward_probability Also: - Updated build version + Rcpp exports - Increment version number * Updated unit test expectations * Removed unnecessary library call * Translated calculate_backward_probability to C++ * Increment version number * Syntax fixes + refactoring * Changed file Unix permissions to match other files Used chmod to change the file permissions from 755 to 644 so it matches the rest of the files on the folder. * Added files for SMC-Mallows new item rank * Updated SMC partial rankings functions and tests * Restyled files * Syntax fixes * Commented out code to be worked on (#110) * Increment version number * Syntax fix * Formatted unit tests (#110) * Reduced test time (#110) Further test optimization Check fixes * Improvements to validation * Added SMC dataset * Improved partial ranking tests (#110) * Improved API feedback * Adapted test units for new item rank (#110) * Optimized unit tests (#110) * Minor fixes for clean check * Translated metropolis_hastings_aug_ranking_pseudo (#98) - Added skeleton of C++ metropolis_hastings_aug_ranking_pseudo - Translated metropolis_hastings_aug_ranking_pseudo - Replaced R version with C++ version - Fixed behavior of metropolis_hastings_aug_ranking_pseudo - Improved test format and updated expectations * Increment version number and R version dependency * Refactoring for easier debugging * Fixed RNG behavior on unit test * Removed superseded function * Added translation of metropolis_hastings_aug_ranking * Fixed documentation The docs for metropolis_hastings_aug_ranking_CPP() had text from the pseudo function. * Replaced R version of mh_aug_ranking with C++ (#98) Also, adjusted unit test expectations accordingly * Increment version number * Adjusted tests and renamed arguments (#98) * Added original code for correction_kernel C++ (#111) * Syntax fixes * Increment version number * Replaced R with C++ version of correction_kernel (#111) * Refactoring * Code optimization * Renamed cpp file * Added original code for correction_kernel_pseudo C++ (#111) * Syntax fixes * Replaced R with C++ of correction_kernel_pseudo (#111) * Increment version number * Replaced calculation of remaining_set * Translated smc_mallows_new_users_partial (#107) - Added C++ skeleton of smc_mallows_new_users_partial - Translated function * Set more seeds in unit tests This avoids random errors in unit testing. * Increment version number * Fixed calculation on smc_mallows_new_users_complete * Replaced R version with C++ version (#107) Of smc_mallows_new_users_partial(). * cal_fwd_prob() now works with both R and C++ indices * Refactoring * Adjusting unit tests * Returning test units to their original expectation * Updated Roxygen version * cal_bwd_prob() now works with both R and C++ indices This is basically a copy-paste from commit ce5d52cd. I smell a function coming... * Refactoring * Adjusting test expectations to new code output The differing output is caused by `set.seed(101)` having a different effect on the new C++ functions, particularly the output of `test_1_forward$aug_ranking`, which trickles down into the calculation of `test_1_backward_b`, thus causing different probabilities. The code was back-checked with the original R code, in which case the output seems the same. However, this should be checked with Anja. * Moved common code into function As "promised" on e497763640992f788c4ff0c98f6f127b99d4d785. * Translated partial ranks alpha fixed to C++ (#107) - Added skeleton of C++ alpha_fixed function - Finished translation - Switched R and C++ versions - Updated unit test expectations - Removed the R version of the function * Added parameters to SMC new users complete Added alpha_prob_sd, lambda and alpha_max, which were new arguments to metropolis_hastings_alpha and were internally defined as constants. * Added knitr as vignette engine Now both R.rsp and knitr are used as vignette builders. The former is used to add the BM paper in PDF format, the latter is hosting the SMC Rmarkdown vignette (yet a mockup). * Added mockup of SMC vignette * Updated .gitignore Update generated by `devtools::build_vignettes()`. * Updated build version * Translated new_item_rank to C++ (#113) * Replaced R new_item_rank with C++ version (#113) * Increment version number * Opening CI to all branches r.yml is currently configured for only triggering GitHub Actions CI workflow for the `master` and the `main` (inexistent here) branches. Opening it up to any branch so commits to `smc-mallows` also get triggered. This is important so we can better foresee problems in the upcoming merge with `master`. Opening up to any branch name shouldn't be a problem on this repository, since `master` is the only long-lived branch at the moment. * Syntax fixes * Refactoring * More specific seed setting * Fixing tests for Ubuntu Tests for Mac and Windows are still failing due to RNG. To be addressed later. * Investigate tests (#127) * Added prints statements to `arma::shuffle` * Added unique sort to `setdiff` * Updated tests Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> * Updates to smc_post_processing_functions.R (#119) * Updates to smc_post_processing_functions.R Hi, Just done a bit of tidying with the post_processing_functions. Here is a summary of my proposed changes: 1. edited `smc_processing` to allow the option to print the `col_names` of the original dataset if appropriate 2. edited `compute_consensus` to print the output correctly in the `MAP` case and to print the `colnames` of a dataset if appropriate instead of listing items as 'item 1, item 2, ... etc'. 3. edited `plot_posterior_intervals_rho` to print the `colnames` of a dataset if appropriate instead of listing items as 'item 1, item 2, ... etc'. 4. adjusted the font sizes of the axis labels in `plot_heatplot_rho` 5. removed the variable `verbose` from `plot_posterior_alpha` so that it now prints when calling the functions and doesn't do duplicate plots. 6. commented out any unused post-processing functions I have added some general comments, which begin with `#AS:` to explain why I have made the following changes (even though Github will highlight them). Let me know if you disagree or think any changes are unnecessary. I am planning on renaming the variables in the functions `heatMat` and `heatplot_fixed` so that they are consistent with the other heatplot functions, but I shall do this once this pull request has been completed/resolved(?). Waldir's changes: * Changed test unit expectations * Documentation fixes * Removed commented-out code * Replaced dplyr call with base R Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Updated smc.rmd Copy-pasted vignette script to github. Need to upload the matching .bib file containing the references. * create vignette.bib This file contains the references to be printed in the smc.Rmd file * Remove unused columns The final columns of rho_samples and alpha_samples do not get populated with non-zero values, so they are redundant. The same change applies to smc_mallows_new_item_rank_alpha_fixed, so this will appear as another pull request. * Remove unused column Extra column in rho_samples is redundant * Update compute_posterior_intervals_rho Reordered column in output to print item names in correct numerical order "item 1, item 2, ..., item 10" instead of "item 1, item 10, item 2, ..., item 9" * Cosmetic changes to heatplot functions Renamed variables to keep variable names consistent. Added some comments to explain the steps in the functions. * Updated test expectation Test units should be reset to expect one fewer columns, given the most recent code changes proposed. * Updated test expectations The previous changes on this branch reduce the number of columns by 1, so this must be reflected in the relevant unit test expectations. * Syntax fixes + doc update * Syntax fixes * Increment version number * Syntax adjustments * Changed test expectations back to what they should be See comment https://github.com/ocbe-uio/BayesMallows/issues/116#issuecomment-938583180 for more details. * Trying to reproduce Anja's seed and output * Increment version number * Added C++ version of smc_mallows_new_item_rank_alpha_fixed (#113) * Replaced R with C++ of smc_mallows_new_item_rank_alpha_fixed (#113) * Added C++ function of SMC new item alpha fixed (#113) * Added C++ version of smc_mallows_new_item_rank_alpha_fixed (#113) * Replaced R with C++ of smc_mallows_new_item_rank_alpha_fixed (#113) * Added C++ function of SMC new item alpha fixed (#113) * Added unit tests for #134 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> * Reduced test time * get_mallows_loglik now transposes as needed (#134) This eliminated the bug when passing rankings as a row vector and rho as a column vector (or vice-versa). Both still need to be matrices, though. * Increment version Increment version number to 1.0.3.9002 Increment version number to 1.0.3.9003 Increment version number to 1.0.3.9004 * Updated build version * Exported all functions from #117 - Exported `plot_rho_heatplot()` - Exported `plot_alpha_posterior()` - Exported `compute_posterior_intervals_alpha()` - Exported `compute_posterior_intervals_rho()` - Exported `compute_rho_consensus()` Also, some function names were renamed in comments and the SMC vignette text due to slight differences between their names there and the one on the code. The names on the code were preferred. Namely, the changes were: 1. `plot_heatplot_rho` into `plot_rho_heatplot` 2. `compute_consensus_rho` into `compute_rho_consensus` * Refactoring * Increment version number to 1.0.3.9006 * Added print argument to internal function * Updated test expectation, added comments * Added temporary print statements for debugging * Increment version number to 1.0.3.9007 * Added function plot_rho_posterior.R in smc_post_processing_functions.R (#137) * Added function plot_rho_posterior.R in smc_post_processing_functions.R * Synxtax fixes + whitespace removal * Exporting function with documentation Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Changing output of SMC function to new class Including change in test expectation. * Added generics, methods for compute_posterior_intervals * Changed classes of Mallows objects (#80) Generics and methods related to `compute_posterior_intervals()` had some class additions to allow for better dispatching between BayesMallows and SMC-Mallows methods. * Moved methods to same file (#80) Moved all methods of `compute_posterior_intervals()` and `.compute_posterior_intervals()` to the same file (easier to manage). * Syntax and documentation fixes/updates * Increment version number to 1.0.3.9006 * Updated TODOs * Update smc.Rmd Removed the heatplot function and replaced it with the plot rho posterior function. Some descriptions have changed to fit the description of the posterior function. * Remove heatplot functions Since we now have the `plot_rho_posterior` function to clearer visualisation, we can discontinue this function. * Deleted commented-out code * Updated docs * Removed unit test for dropped function * Increment version number to 1.0.3.9007 * Moved gtools from Suggests to Depends Also, standardized indentation. * Updated build version * added print statements to calculate_forward_probability.cpp Added lots of print statements to help with debugging * added print statements to calculate_backwards_probability.cpp added extra print statements for debugging * Fixed bug causing issue #116 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * Removed temporary code * Updated test expectations * Removed gtools dependency on SMC (#142) Removed dependency on gtools::mixedorder Works by extracting everything that isn't a digit ([0-9]) and ultimately using the index of the sorted elements to sort `rho_posterior_interval`. Works well for the standard "Item DD" format that SMC uses, and probably for other formats as well, but this wasn't extensively tested. * Replaced purrr::map with lapply on SMC (#142) * Replaced tidyr calls in SMC functions (#142) - Replaced tidyr::gather with stats::reshape - Replaced tidyr::spreadh with stats::reshape * Minor adjustments to SMC vignette Removed unused dependencies, Removed usage of , automatic whitespace adjustments. * Renamed SMC-Mallows vignette file So it matches the capitalization of "BayesMallows.pdf.asis" * Removed unneeded suggestions from DESCRIPTION * Created generic for compute_consensus * Generalized compute_consensus subfunctions (#80) Tests started failing due to different output structure from the previous expectation. To be investigated. * Fixed leftover merge conflict from develop * Increment version number to 1.0.4.9002 * Dropped usage of dplyr::do * Updated docs * Increment version number to 1.0.4.9003 * Reindented test code to aid debugging * Removed duplicated unit tests with wrong name Apparently git didn't pickup on the renaming of "test_" to "test-" * (Re)deleted redundant bib file All vignettes point to a common inst/REFERENCES.bib, no need for a new file. * sorted the consensus output * Renamed class of compute_consensus.BayesMallows output (#80) * Renamed test file Since it contains tests for both `compute_consensus()` and `compute_posterior_intervals()`. * Added class tests for compute_rho_consensus (#80) * Introducing consensus_SMCMallows class (#80) * Moved compute_consensus methods together (#80) * Updated docs * Removed finished TODOs from code Co-authored-by: Anja Stein <anjastein@users.noreply.github.com> Co-authored-by: Anja Stein <anjastein@noreply.users.github.com> Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * incremented version number and updated CRAN note * corrected spelling error in smc vignette * recompiled documentation after resolving conflicts with master branch * recompiled readme and update some citations * Added linter CI workflow * Using <- for assignment * Removed commented out code * Improved spacing around commas and operators * Replaced tab with space for indentation * Fixed spacing before curly brace * Replaced single quotes with double * Adjusting space before left parenthesis * Replaced F with FALSE * Removed superfluous trailing blank lines * Removed unnecessary concatenation Co-authored-by: Øystein Sørensen <oystein@ysteins-mbp.lan> Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> Co-authored-by: Anja Stein <anjastein@users.noreply.github.com> Co-authored-by: Anja Stein <anjastein@noreply.users.github.com> Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * fixed #168 and added unit test * issue 112 smc memory (#169) * Improved variable declaration on maybe_offset_indices() (#112) * Improved variable declaration on calculate_backward_probability() (#112) * Replaced redundancies with two functions (#112) (#170) New C++ functions: - `arma_setdiff_vec()` - `Rcpp_setdiff_arma()` Both are slight variations of `arma_setdiff()` using different-classed objects. Code could be further optimized by merging the new functions into arma_setdiff(). Good luck dealing with all the vec-uvec conversions, though. * Declared constants and references (#112) (#172) * Removed trailing blank line [Linter](https://github.com/ocbe-uio/BayesMallows/pull/170/files) was complaining. * Declaring constants and references on SMC (#112) * Replaced SMC code with functions (#112, #114) (#173) This was primarily done as a stepping stone to replacing some Armadillo/Rcpp back-and-forth (see issue #112). Removing duplicated code makes it easier to replace Rcpp crutches later. The newly-created functions were also simplified as much as I could to get #112 solved. * Fix boolean operands (#175) * Increment version number to 1.1.0.9001 * Fixed boolean operands This should solve the eventual warnings for using bitwise `|` or `&` with boolean operands. * Fix oldrel errors (#176) * Increment version number to 1.1.0.9001 * Fixed boolean operands This should solve the eventual warnings for using bitwise `|` or `&` with boolean operands. * Refactored reshaping on smc_processing() #174 There seems to be a problem with setting `idvar` to `NULL` in R-oldrel, possibly due to some change on the `stats::reshape()` function. This change intends to fix it without changing the output. * Excluding RcppExports.R from linter This file is generated automatically and it keeps triggering a warning on GitHub Actions about it containing a superfluous trailing blank line. * Increment version number to 1.1.0.9002 * Addressing #181 (#182) * Issue 184 cpp (#187) * fixed return type of sample_one_with_prob #184 * updated news * Clean up headers (#196) * removed unnecessary include from distances.h * removed unnecessary statements from missing_data.h * a lot of DRY-ing of header files * corrected typo in function name * removed include for algorithm as it is already included by RcppCommon.h * deleted some more unnecessary includes * incremented to development version * updated news * Update smc_mallows_new_users_complete.cpp (#189) * Update smc_mallows_new_users_complete.cpp Include a vector named ESS_vec (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. * Update smc_mallows_new_users_complete.cpp * Update smc_mallows_new_users_complete.cpp * Update smc_mallows_new_users_complete.cpp * Fixed calculation of ESS_vec elements `^` is not a valid Armadillo operator (see list [here](http://arma.sourceforge.net/docs.html#operators)). The usual way to square a matrix is to multiply it by its transpose, so that's what I proposed here. The operation was also separated from the sum so arma would stop complaining (maybe this could be a one-liner again by using `conv_to()`, but I didn't wanna do that. * Fixup for 06d7c87 Previous commit was syntatically OK, but issues arised when running tests. This fixes it * Adjusted unit tests to ESS addition * Update smc_mallows_new_users_complete.cpp Changed the calculation for ESS - I was using the incorrect formula. * Added unit test for ESS Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Replaced all arma::*word (#202) * Replaced all arma::*word (#199) * Increment version number to 1.1.2.9001 * Reverted changes from ba7c5527f on misc.h Using `using namespace` in header files should be avoided, as their effect trickle down to any other file using them. * Removal of arma:: qualifier from functions (#205) * replaced arma::*class* in mixtures.cpp * removed arma:: in distances.cpp * replaced arma:: in importance_sampling.cpp * leapandshift * removed more arma:: in misc.cpp * removed arma::*class* in missing_data.cpp * removing arma:: in pairwise_comparisons.cpp * removing arma:: in parameterupdates.cpp * removing arma:: in partitionfuns.cpp * removing arma:: in rmallows.cpp * removing arma:: in run_mcmc.cpp * removed arma::*class* from smc functions * replaced arma::ones with ones * replaced arma::zeros and arma::rand* with zeros and rand* * replaced arma::fill* with fill* * replaced arma::span with span * replaced arma::exp with exp * replaced arma::log with log * replaced arma::accu with accu * replaced arma::conv_to with conv_to * replaced arma::max and arma::min with max and min * replaced arma::sum with sum * replaced arma::normalise with normalise * replaced arma::find with find * replaced arma::regspace and arma::linspace with regspace and linspace * replaced arma::shuffle with shuffle * replaced arma::as_scalar with as_scalar * removed arma:: from various not-so-frequently-used functions * removal of arma:: qualifier from more functions * Revert "Removal of arma:: qualifier from functions (#205)" (#206) This reverts commit 3ec2432e218b8f35dccdbe55197229573c97241a. * More work towards #199 (#203) * replaced arma::*class* in mixtures.cpp * removed arma:: in distances.cpp * replaced arma:: in importance_sampling.cpp * leapandshift * removed more arma:: in misc.cpp * removed arma::*class* in missing_data.cpp * removing arma:: in pairwise_comparisons.cpp * removing arma:: in parameterupdates.cpp * removing arma:: in partitionfuns.cpp * removing arma:: in rmallows.cpp * removing arma:: in run_mcmc.cpp * removed arma::*class* from smc functions * Issue 200 (#204) * replaced arma::*class* in mixtures.cpp * removed arma:: in distances.cpp * replaced arma:: in importance_sampling.cpp * leapandshift * removed more arma:: in misc.cpp * removed arma::*class* in missing_data.cpp * removing arma:: in pairwise_comparisons.cpp * removing arma:: in parameterupdates.cpp * removing arma:: in partitionfuns.cpp * removing arma:: in rmallows.cpp * removing arma:: in run_mcmc.cpp * removed arma::*class* from smc functions * replaced arma::ones with ones * replaced arma::zeros and arma::rand* with zeros and rand* * replaced arma::fill* with fill* * replaced arma::span with span * Issue 201 (#207) * replaced arma::*class* in mixtures.cpp * removed arma:: in distances.cpp * replaced arma:: in importance_sampling.cpp * leapandshift * removed more arma:: in misc.cpp * removed arma::*class* in missing_data.cpp * removing arma:: in pairwise_comparisons.cpp * removing arma:: in parameterupdates.cpp * removing arma:: in partitionfuns.cpp * removing arma:: in rmallows.cpp * removing arma:: in run_mcmc.cpp * removed arma::*class* from smc functions * replaced arma::ones with ones * replaced arma::zeros and arma::rand* with zeros and rand* * replaced arma::fill* with fill* * replaced arma::span with span * replaced arma::exp with exp * replaced arma::log with log * replaced arma::accu with accu * replaced arma::conv_to with conv_to * replaced arma::max and arma::min with max and min * replaced arma::sum with sum * replaced arma::normalise with normalise * replaced arma::find with find * replaced arma::regspace and arma::linspace with regspace and linspace * replaced arma::shuffle with shuffle * replaced arma::as_scalar with as_scalar * removed arma:: from various not-so-frequently-used functions * removal of arma:: qualifier from more functions * added pdf(NULL) (#208) * Update smc_mallows_new_users_partial_alpha_fixed.cpp (#191) * Update smc_mallows_new_users_partial_alpha_fixed.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_users_partial_alpha_fixed.cpp * Syntax fix, updated test expectations * Update smc_mallows_new_users_partial_alpha_fixed.cpp Updated L28 to explain the output. Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Update smc_mallows_new_users_partial.cpp (#190) * Update smc_mallows_new_users_partial.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_users_partial.cpp * Syntax fix * Adjusted unit test expectations * Update smc_mallows_new_users_partial.cpp Updated L34 to explain the output. * Update smc_mallows_new_users_partial.cpp Updated L34 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Issue 162 (#211) * replaced two dplyr::filter with [ * replaced some more dplyr::filter * replaced more dplyr * replaced more dplyr::filter * replaced dplyr::filter in plot.BayesMallows * replaced more dplyr::filter * replaced more dplyr::filter * replaced more dplyr::filter * replaced the easy dplyr::filter in compute_consensus.R * replaced more easy dplyr::filters * fixed a line to avoid soft-deprecated dplyr syntax * more complicated un-dplyr-ing in assign_cluster.R * some reordering of test output * simplified a group-by * removed dplyr from map cluster * eliminated dplyr from assign_cluster.R * removed dplyr::mutate a few more places * removed a dplyr::mutate in assess_convergence.R * removed another dplyr::mutate * un-dplyred assess_convergence.R * replaced a dplyr::if_else * replaced some dplyr::select * replaced another mutate * replaced a dplyr::semi_join with base::merge in generate_transitive_closure.R * replaced more dplyr with base * replaced two dplyr::filter with [ * replaced some more dplyr::filter * replaced more dplyr * replaced more dplyr::filter * replaced dplyr::filter in plot.BayesMallows * replaced more dplyr::filter * replaced more dplyr::filter * replaced more dplyr::filter * replaced the easy dplyr::filter in compute_consensus.R * replaced more easy dplyr::filters * fixed a line to avoid soft-deprecated dplyr syntax * more complicated un-dplyr-ing in assign_cluster.R * some reordering of test output * simplified a group-by * removed dplyr from map cluster * eliminated dplyr from assign_cluster.R * removed dplyr::mutate a few more places * removed a dplyr::mutate in assess_convergence.R * removed another dplyr::mutate * un-dplyred assess_convergence.R * if_else to ifelse * replaced some dplyr::select * replaced another mutate * replaced a dplyr::semi_join with base::merge in generate_transitive_closure.R * replaced more dplyr with base * more dplyr replacements * incorporating some updates * some more replacements * replacement in compute_consensus.R * more replacements of dplyr * fixed small issue * replaced a select * changed return values to dataframes * more changes from tibble to data.frame * fixed tests due to sorting * replaced dplyr in estimate_partition_function * simplified naming of columns * replaced dplyr in plot.BayesMallows.R * small change in assign_cluster.R * replaced a dplyr in plot_top_k.R * discovered a code duplication which could easily be fixed * removed a lot of dplyr in compute_consensus.R * updated classes in tests and return values * base function for finding unique values * replaced group and count with aggregate * DRY-ing #114 and base-r-ification * the two find_cpc functions were identical, so I merged them * replaced a group-count with an aggregate * replaced a dplyr in map consensus * DRYing #114 and conversion to base R * all dplyr in compute_consensus.R replaced by base * enormous DRY-ing * replaced more dplyr with base * all tests passing * removed dplyr in example and added import * fixed misspelled import * styling assign_cluster * styling compute_consensus.R * styling compute_posterior_intervals * more styling * increased test coverage of expected_dist * styling of test files * DRY-ing while fixing a false negative in codecov * added more complete tests for consensus with SMC * Addressed "unneded concatenation of a constant" linting * Added change notice on predict_top_k * Added change notice to predict_top_k * improved the message * incremented development version * Adding space between parentheses Should solve linting warnings from 5b64da93. Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Added CodeFactor badge (#213) * Added CodeFactor badge * Moved changes to Rmd file, rebuilt md README.md was rebuilt using `devtools::build_readme()`, which triggered some past changes which should be double-checked. * compiled README.Rmd locally by pressing the knit button Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> * Issue 214 (#215) * created test that catches #214 * updated test so it does not produce pdf file * solve #214 * updated news * Issue 212 (#216) * Started replacing dplyr in test files * removed another dplyr * removed dplyr from test-compute_mallows.R * replaced dplyr in test-compute_consensus.R * replaced dplyr in test-plot_top_k.R * all dplyr dependencies in tests removed * removed dplyr from obs_freq_example * removed dplyr from compute_consensus_example * removed dplyr from plot_top_k_example * added plot_top_k example to predict_top_k * removed dplyr from estimate_partition_function_example * removed more dplyr from examples * replaced dplyr in generate_transitive_closure_example.R * removed dplyr from compute_mallows_example.R * removed two unnecessary library() statements in SMC-Mallows vignette * converted partition function data from tibble to data.frame * simplified script for generating beach data * updated documentation * removed dplyr from DESCRIPTION * updated NEWS.md * updated development version * ran styler on R/ * Followed the advice of CodeFactor, replacing mapply with Map * fixed some forgotten dplyr code which did not cause error due to 'dontrun' * Removed comment referring to #91 * replacing sink() with capture.output() * Dry (#217) * DRY-ed log_lik_db function * added internal documentation * styling * formatted documentation * Update smc_mallows_new_item_rank.cpp (#192) * Update smc_mallows_new_item_rank.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_item_rank.cpp * Fixed syntax, added FIXME * Update smc_mallows_new_item_rank.cpp Updated L33 * Update smc_mallows_new_item_rank.cpp Corrected lines involving `ESS_vec`. * Updated @return documentation * Changed initialization of `ESS_vec` It is now declared later in the code so its initial values can be calculated first. * Updated unit test expectations * Updated Rd docs * Updated docs * Updated initialization of ESS_vec Following https://github.com/ocbe-uio/BayesMallows/commit/156ae3727b20690a25ccb320657659db78e368dd#r72662511 and https://github.com/ocbe-uio/BayesMallows/pull/192#discussion_r862766447, `ESS_vec` starts with `ess_init` on index 0 and zero on indices {1, ..., Time - 1}. Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Dry (#218) * used existing function for computing distance * updated documentation * fixing CodeFactor issue * increasing test coverage * simplified code in lik_db_mix (#220) * simplified code in lik_db_mix * fixed some duplication on my side * fixed error causing tests to fail * renamed get_mallows_loglik (#221) * renamed get_mallows_loglik * fixed CodeFactor issues * using boost factorial function instead * simplified factorials * deleted unnecesary headers * added header * added a comment and replaced math.h with cmath * Binomial coefficient (#222) * DRY logz_cardinalities * DRY log_expected_dist * replaced code duplication with a function * realized we can use binomial coefficient from Rmath.h * got rid of an unnecessary statement in mixtures.cpp * Vec seq (#223) * DRY logz_cardinalities * DRY log_expected_dist * replaced code duplication with a function * realized we can use binomial coefficient from Rmath.h * got rid of an unnecessary statement in mixtures.cpp * replaced arma_vec_seq with regspace * Setdiff (#225) * DRY logz_cardinalities * DRY log_expected_dist * replaced code duplication with a function * realized we can use binomial coefficient from Rmath.h * got rid of an unnecessary statement in mixtures.cpp * replaced arma_vec_seq with regspace * got rid of one of the may setdiff functions * created a single setdiff function (#226) * created a single setdiff function * changed setdiff.hpp to setdiff.h * some cleaning of header files (#230) * replaced Rcpp::sample with arma::shuffle, #227 (#228) * replaced Rcpp::sample with arma::shuffle, #227 * replaced formatting of include * created sampling function, let's see if it passes the tests * removed require() from test * got rid of sample_int * got rid of sample_one_with_prob * got rid of permute_with_weights * added two more tests to understand platform dependency * replaced one new_pseudo_proposal * got rid of new_pseudo_proposal. tests succeeding locally * replaced more shuffle(). * updated unit tests * removed library statement * made setdiff function call by reference * replaced .size() with .n_elem for arma objects * removed some empty lines * turned back a shuffle * another shuffle * checking no windows * updated tests * another update * updated tests * should not test ESS due to bug * updated test * testing on windows * replaced a shuffle with a randperm * replaced unnecessary headers * updated dev version and wrote a line in NEWS.md * renamed a file * Rename loglik (#231) * renamed lik_db_mix to get_mallows_loglik and deprecated it * fixed deprecation notice * Dry smc (#232) * DRY-ed augmentation of ranks for new users * DRY-ed the reweighting for smc_new_users * DRY-ed new_users_complete as well * First DRY-ing of smc_mallows_new_users * had forgot an & * reduced the number of arguments * reorganized code and solved #219 * made an initializer for alpha_samples * refactored a little bit more * Small code modifications (#234) * some small simplification * Update smc_leap_and_shift_probs.cpp Using default argument * put forward and backward probability into a single function (#235) * some small changes (#236) * some improvements of the all_topological_sorts function (#237) * some improvements of the all_topological_sorts function * fixed CodeFactor issue * create a single function for smc_mallows_new_users* (#238) * create a single function for smc_mallows_new_users* * some DRY-ing * fixed documentation issue causing tests to fail * Leap and shift (#240) * cleaning of leap-and-shift code * moved SMC shift step for easier comparison with the other leap and shift function * removed static_cast in leap-and-shift * simplified by using regspace * more code cleaning * deleted whitespace * Ls issue 239 (#241) * cleaning of leap-and-shift code * moved SMC shift step for easier comparison with the other leap and shift function * removed static_cast in leap-and-shift * simplified by using regspace * more code cleaning * deleted whitespace * fixed leap-and-shift bug in #239 * updated NEWS.md and version number * Update smc_mallows_new_item_rank_alpha_fixed.cpp (#193) * Update smc_mallows_new_item_rank_alpha_fixed.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_item_rank_alpha_fixed.cpp * Update smc_mallows_new_item_rank_alpha_fixed.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_item_rank_alpha_fixed.cpp * Syntax fix * Removed duplicated code * Update smc_mallows_new_item_rank_alpha_fixed.cpp Updated L39 to explain the output. * Update smc_mallows_new_item_rank_alpha_fixed.cpp Updated lines involving `ESS_vec` * Update test-smc_mallows_new_item_rank.R Updated test script for smc_mallows_new_item_rank_alpha_fixed Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Testing of C++ functions (#242) * added framework for unit testing of C++ functions and wrote unit test for leapandshift.cpp * fixed CodeFactor issue * another attempt at making CodeFactor happy * SMC now uses the same leap-and-shift function as BayesMallows. Turned the SMC function into a thin wrapper for now. * made leap_and_shift_probs internal * updated readme * Small vignette edits * Dry new item (#243) * DRY-ed initialize_rho function * made common initialize_rho function and updated tests for BayesMallows * refactored initialize_alpha * merged new_item_rank functions * deprecated smc_mallows_new_item_rank_alpha_fixed * extracted a function for the move step * some refactoring * fixed CodeFactor issue! * Updated NEWS.md and incremented development version * made aug_ranking function call by reference * Added tests with explicit expections of numeric output for new_item_rank to make sure #243 is safe * tests passing on mac * fixed CodeFactor issue * another DRY-ing * added a function for normalizing weights * Incremented version and updated news and cran-comments #249 * Updated NEWS.md and cran-comments.md * Update smc_mallows_new_users.cpp (#251) * Update smc_mallows_new_users.cpp - added loop for `partial` and `partial fixed` case to lines 191 and - adjusted loop start and endpoints lines 209 and 220 * updated tests * tiny style update * Updated NEWS.md * Changed divide_by_fact to make it more readable Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> * updated news and incremented development version * Fixed CI linter (#253) * Updated linter YAML * Auto-updated docs * Fix @title for sample_dataset (#256) * Improved title of `sample_dataset` * Increment version to 1.2.0.9001, updated NEWS * Updating new rank functions (#252) * Added original script (#198) From @anjastein > The script called `updated_rankings_functions_for_waldir.R` contains the new functions that would benefit from being translated from R to C++. A lot of the code suffers from DRY (two very similar functions but in one of them the variable alpha is fixed) and probably uses a lot of code that you have created in the BayesMallows SMC extension of the CRAN package already, so I hope it won't be time-consuming. * Roxygenized docs, split unit tests (#198) * Commented out temporarily-broken tests (#198) * Removed explicit calls to the function (#198) * Replaced `abort()` calls with `stop()` (#198) * Updated renamed functions See commit 375a6f6f0aeefb9b019bc11eec3d3a28528485e5 for details. * Updated proposed code to the 1.2.0 API * Restyled file * Added TODOs * Minor doc fix (#198) * Adding `smc_mallows_new_item_rank_updated_cpp()` (#198) * Adding default value to `alpha_samples_init` The alpha-fixed variant does not use it. * Wrapping unit tests around `test_that()` (#198) * Updated build version * Added TODO * Improved variable declaration * Updated docs and Rcpp exports * Increment version number to 1.2.0.9002 * Syntax fixes (#198) * Updated unit tests to use C++ version (#198) * Improved handling of alpha_fixed without alpha_samples_init (#198) * Updated docs, RoxygenNote version * Replaced original R functions with C++ (#198) * Merged identical functions (#198) * Replaced `smc_mallows_new_item_rank()` (#198) Subfunction was also moved away from _back_ into , since it's not being used anywhere else * Updated deprecated smc_mallows_new_rank funcs Rerouting to new function deleted because the arguments mismatch. squash! fixup! Updated deprecated smc_mallows_new_rank funcs * Added default to `rho_samples_init` (#198) Defaults to NULL, in which case `initialize_rho()` is called, as per the previous implementation. squash! Added default to `rho_samples_init` (#198) * Adapted unit tests accordingly to #198 updates * Removed warning when `alpha_samples_init` is not provided (#198) This restores the behavior from the previous version, which is to _silently_ generate alpha_samples. Since the warning introduced on commit f2bd74c4ce7b97fca5d6a3871f3c0ea4332fbde1 was removed, the test unit introduced there makes no sense anymore, so it was removed. * Added function to augment rankings (#198) Copy-pasted from previous version of `smc_mallows_new_item_rank()`. * Augment ranking if empty aug_rankings_init (#198) * Added error expectation to unit tests * Fixed warnings caused by comparison between int and uword * Fixed test unit syntax The removed bit was depending on `smc_test_new_user_unif`, an object which has not been created at that point. This issue was present in the original script. Also, the error message is now explicitly mentioned to match the purpose of this particular test unit. * Added TODO * Simplified syntax (#198) * Moved test further down the script To a place where all inputs are already defined. * Allowing `aug_rankings_init` to be nullable * Adapted test expectations * Code style adjustments * Drastically reduced test execution time (#198) Test script modified to reduce code footprint and execution time. Test on local machine showed a reduction from 144 s to 0.3 s to run the affected script. * Replacing casting function with one-liner (#198) Source: https://github.com/ocbe-uio/BayesMallows/pull/252#discussion_r978953965 * Replacing arma for Rcpp on function argument (#198) Source: https://github.com/ocbe-uio/BayesMallows/pull/252#discussion_r978955092 Co-authored-by: Anja Stein <a.stein1@lancaster.ac.uk> Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> * codefactor issue * CodeFactor issue * CodeFactor issues * Adding data-raw to directories lintr should ignore * Added main testthat file to linter-ignore * Minor code style adjustments Addressed redundant blank lines accused by CodeFactor to clear up the number of issues raised by the system. We're not far from an A+ rating! :) * Updated testthat.R * Updated NEWS.md Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Øystein Sørensen <oystein@ysteins-mbp.lan> Co-authored-by: Anja Stein <anjastein@users.noreply.github.com> Co-authored-by: Anja Stein <anjastein@noreply.users.github.com> Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> Co-authored-by: Anja Stein <a.stein1@lancaster.ac.uk>
* incremented to development version * Add linter CI (#167) * replaced purrr with lapply in plot_elbow and wrote an extra test * change purrr with Map in sample_mallows * replaced purrr with lapply in compute_mallows_mixtures * removed purrr from compute_posterior_intervals * removed purrr from assess_convergence * removed purrr from rank conversion * replaced purrr with vapply et al in print function and added test * removed purrr from compute_mallows * removed purrr from generate_constraints and from a test * removed purrr from Imports and incremented development version * removed library call to purrr * replaced map with lapply in example * removed another call to map * hope I soon have removed every piece of purrr * updated docs * Untidyr (#154) * removed tidyr from sample_mallows * removed tidyr from assign_cluster * removed tidyr from predict_top_k and updated tests * replaced tidyr in plot_top_k * replaced one tidyr in compute_consensus * replaced tidyr in compute_consensus and updated tests * replaced tidyr in generate_constraints * replaced tidyr in test_compute_mallows * removed a whole lot of dependencies * removed tidyr from Imports * updated news * Untidyr (#156) * removed tidyr from sample_mallows * removed tidyr from assign_cluster * removed tidyr from predict_top_k and updated tests * replaced tidyr in plot_top_k * replaced one tidyr in compute_consensus * replaced tidyr in compute_consensus and updated tests * replaced tidyr in generate_constraints * replaced tidyr in test_compute_mallows * removed a whole lot of dependencies * removed tidyr from Imports * updated news * moved permutations function to R/misc.R * Removed permfun.R and remaining source of it * SMC-Mallows (#157) * Identified more codelines related to #90 * Reclassified Rcpp objects as arma (#90) In the smc_leap_and_shift_probs() function. * Increment version number * Fixed unit tests * Updated TODOs * Increment version number * Replaced Rcpp::sample with arma::randi (#90) * Adjusted unit tests * Replaced Rcpp vector with arma vector (#90) * Removed TODO For the moment, smc_mallows_new_users_complete() will still use Rcpp::sample() to calculate the arma::uvec index. Replacement of Rcpp::sample() with arma::rand*() is encouraged, but left to any future developer aware of how to include probability weights on arma::rand*(). For more details, see conversation in issue #90. * Rearranged inline comments Top comment was relocated and rewritten on https://github.com/ocbe-uio/BayesMallows/issues/90#issuecomment-866614296 for better visibility and organization. Mid-code comment added for future reference. * Syntax fix * Reduced example length (closes #96) * Increment version number * Reduced unit test parameters (resolves #100) * Dropped usage of deprecated function (closes #99) * Added original scripts (#106) * Fitting scripts to package format (#106) * Added original scripts * Removed source calls, moved unit tests * Syntax fixes * Updated docs, exported new functions * Added placeholders for unit tests * Commented out failing tests These tests trigger errors on get_rank_distance(), to be investigated later (see issue #98 comments section for more details). * Increment version number * Increment version number * Syntax fix aug_prob is a vector, so we need to select just one element to perform those operations. * Fixed function name Function was using a deprecated, alternative name. * Fixed calls to get_mallows_loglik (#98, #109) * Reduced number of iterations on test * Restyled file * Fixes tests (#109) * Implemented tests (#98) * Edited test titles * Removed TODO * Improved SMC tests' speed (fixes #102) * Moved get_sample_probabilities() to src folder * Translated get_sample_probabilities + docs (#98) * Moved calculate_forward_probability to src folder * Exporting empty C++ function * Partial translation of calculate_forward_probability * Added get_sample_probabilities to smc.h * Finished translation of calculate_forward_probability Also: - Updated build version + Rcpp exports - Increment version number * Updated unit test expectations * Removed unnecessary library call * Translated calculate_backward_probability to C++ * Increment version number * Syntax fixes + refactoring * Changed file Unix permissions to match other files Used chmod to change the file permissions from 755 to 644 so it matches the rest of the files on the folder. * Added files for SMC-Mallows new item rank * Updated SMC partial rankings functions and tests * Restyled files * Syntax fixes * Commented out code to be worked on (#110) * Increment version number * Syntax fix * Formatted unit tests (#110) * Reduced test time (#110) Further test optimization Check fixes * Improvements to validation * Added SMC dataset * Improved partial ranking tests (#110) * Improved API feedback * Adapted test units for new item rank (#110) * Optimized unit tests (#110) * Minor fixes for clean check * Translated metropolis_hastings_aug_ranking_pseudo (#98) - Added skeleton of C++ metropolis_hastings_aug_ranking_pseudo - Translated metropolis_hastings_aug_ranking_pseudo - Replaced R version with C++ version - Fixed behavior of metropolis_hastings_aug_ranking_pseudo - Improved test format and updated expectations * Increment version number and R version dependency * Refactoring for easier debugging * Fixed RNG behavior on unit test * Removed superseded function * Added translation of metropolis_hastings_aug_ranking * Fixed documentation The docs for metropolis_hastings_aug_ranking_CPP() had text from the pseudo function. * Replaced R version of mh_aug_ranking with C++ (#98) Also, adjusted unit test expectations accordingly * Increment version number * Adjusted tests and renamed arguments (#98) * Added original code for correction_kernel C++ (#111) * Syntax fixes * Increment version number * Replaced R with C++ version of correction_kernel (#111) * Refactoring * Code optimization * Renamed cpp file * Added original code for correction_kernel_pseudo C++ (#111) * Syntax fixes * Replaced R with C++ of correction_kernel_pseudo (#111) * Increment version number * Replaced calculation of remaining_set * Translated smc_mallows_new_users_partial (#107) - Added C++ skeleton of smc_mallows_new_users_partial - Translated function * Set more seeds in unit tests This avoids random errors in unit testing. * Increment version number * Fixed calculation on smc_mallows_new_users_complete * Replaced R version with C++ version (#107) Of smc_mallows_new_users_partial(). * cal_fwd_prob() now works with both R and C++ indices * Refactoring * Adjusting unit tests * Returning test units to their original expectation * Updated Roxygen version * cal_bwd_prob() now works with both R and C++ indices This is basically a copy-paste from commit ce5d52cd. I smell a function coming... * Refactoring * Adjusting test expectations to new code output The differing output is caused by `set.seed(101)` having a different effect on the new C++ functions, particularly the output of `test_1_forward$aug_ranking`, which trickles down into the calculation of `test_1_backward_b`, thus causing different probabilities. The code was back-checked with the original R code, in which case the output seems the same. However, this should be checked with Anja. * Moved common code into function As "promised" on e497763640992f788c4ff0c98f6f127b99d4d785. * Translated partial ranks alpha fixed to C++ (#107) - Added skeleton of C++ alpha_fixed function - Finished translation - Switched R and C++ versions - Updated unit test expectations - Removed the R version of the function * Added parameters to SMC new users complete Added alpha_prob_sd, lambda and alpha_max, which were new arguments to metropolis_hastings_alpha and were internally defined as constants. * Added knitr as vignette engine Now both R.rsp and knitr are used as vignette builders. The former is used to add the BM paper in PDF format, the latter is hosting the SMC Rmarkdown vignette (yet a mockup). * Added mockup of SMC vignette * Updated .gitignore Update generated by `devtools::build_vignettes()`. * Updated build version * Translated new_item_rank to C++ (#113) * Replaced R new_item_rank with C++ version (#113) * Increment version number * Opening CI to all branches r.yml is currently configured for only triggering GitHub Actions CI workflow for the `master` and the `main` (inexistent here) branches. Opening it up to any branch so commits to `smc-mallows` also get triggered. This is important so we can better foresee problems in the upcoming merge with `master`. Opening up to any branch name shouldn't be a problem on this repository, since `master` is the only long-lived branch at the moment. * Syntax fixes * Refactoring * More specific seed setting * Fixing tests for Ubuntu Tests for Mac and Windows are still failing due to RNG. To be addressed later. * Investigate tests (#127) * Added prints statements to `arma::shuffle` * Added unique sort to `setdiff` * Updated tests Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> * Updates to smc_post_processing_functions.R (#119) * Updates to smc_post_processing_functions.R Hi, Just done a bit of tidying with the post_processing_functions. Here is a summary of my proposed changes: 1. edited `smc_processing` to allow the option to print the `col_names` of the original dataset if appropriate 2. edited `compute_consensus` to print the output correctly in the `MAP` case and to print the `colnames` of a dataset if appropriate instead of listing items as 'item 1, item 2, ... etc'. 3. edited `plot_posterior_intervals_rho` to print the `colnames` of a dataset if appropriate instead of listing items as 'item 1, item 2, ... etc'. 4. adjusted the font sizes of the axis labels in `plot_heatplot_rho` 5. removed the variable `verbose` from `plot_posterior_alpha` so that it now prints when calling the functions and doesn't do duplicate plots. 6. commented out any unused post-processing functions I have added some general comments, which begin with `#AS:` to explain why I have made the following changes (even though Github will highlight them). Let me know if you disagree or think any changes are unnecessary. I am planning on renaming the variables in the functions `heatMat` and `heatplot_fixed` so that they are consistent with the other heatplot functions, but I shall do this once this pull request has been completed/resolved(?). Waldir's changes: * Changed test unit expectations * Documentation fixes * Removed commented-out code * Replaced dplyr call with base R Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Updated smc.rmd Copy-pasted vignette script to github. Need to upload the matching .bib file containing the references. * create vignette.bib This file contains the references to be printed in the smc.Rmd file * Remove unused columns The final columns of rho_samples and alpha_samples do not get populated with non-zero values, so they are redundant. The same change applies to smc_mallows_new_item_rank_alpha_fixed, so this will appear as another pull request. * Remove unused column Extra column in rho_samples is redundant * Update compute_posterior_intervals_rho Reordered column in output to print item names in correct numerical order "item 1, item 2, ..., item 10" instead of "item 1, item 10, item 2, ..., item 9" * Cosmetic changes to heatplot functions Renamed variables to keep variable names consistent. Added some comments to explain the steps in the functions. * Updated test expectation Test units should be reset to expect one fewer columns, given the most recent code changes proposed. * Updated test expectations The previous changes on this branch reduce the number of columns by 1, so this must be reflected in the relevant unit test expectations. * Syntax fixes + doc update * Syntax fixes * Increment version number * Syntax adjustments * Changed test expectations back to what they should be See comment https://github.com/ocbe-uio/BayesMallows/issues/116#issuecomment-938583180 for more details. * Trying to reproduce Anja's seed and output * Increment version number * Added C++ version of smc_mallows_new_item_rank_alpha_fixed (#113) * Replaced R with C++ of smc_mallows_new_item_rank_alpha_fixed (#113) * Added C++ function of SMC new item alpha fixed (#113) * Added C++ version of smc_mallows_new_item_rank_alpha_fixed (#113) * Replaced R with C++ of smc_mallows_new_item_rank_alpha_fixed (#113) * Added C++ function of SMC new item alpha fixed (#113) * Added unit tests for #134 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> * Reduced test time * get_mallows_loglik now transposes as needed (#134) This eliminated the bug when passing rankings as a row vector and rho as a column vector (or vice-versa). Both still need to be matrices, though. * Increment version Increment version number to 1.0.3.9002 Increment version number to 1.0.3.9003 Increment version number to 1.0.3.9004 * Updated build version * Exported all functions from #117 - Exported `plot_rho_heatplot()` - Exported `plot_alpha_posterior()` - Exported `compute_posterior_intervals_alpha()` - Exported `compute_posterior_intervals_rho()` - Exported `compute_rho_consensus()` Also, some function names were renamed in comments and the SMC vignette text due to slight differences between their names there and the one on the code. The names on the code were preferred. Namely, the changes were: 1. `plot_heatplot_rho` into `plot_rho_heatplot` 2. `compute_consensus_rho` into `compute_rho_consensus` * Refactoring * Increment version number to 1.0.3.9006 * Added print argument to internal function * Updated test expectation, added comments * Added temporary print statements for debugging * Increment version number to 1.0.3.9007 * Added function plot_rho_posterior.R in smc_post_processing_functions.R (#137) * Added function plot_rho_posterior.R in smc_post_processing_functions.R * Synxtax fixes + whitespace removal * Exporting function with documentation Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Changing output of SMC function to new class Including change in test expectation. * Added generics, methods for compute_posterior_intervals * Changed classes of Mallows objects (#80) Generics and methods related to `compute_posterior_intervals()` had some class additions to allow for better dispatching between BayesMallows and SMC-Mallows methods. * Moved methods to same file (#80) Moved all methods of `compute_posterior_intervals()` and `.compute_posterior_intervals()` to the same file (easier to manage). * Syntax and documentation fixes/updates * Increment version number to 1.0.3.9006 * Updated TODOs * Update smc.Rmd Removed the heatplot function and replaced it with the plot rho posterior function. Some descriptions have changed to fit the description of the posterior function. * Remove heatplot functions Since we now have the `plot_rho_posterior` function to clearer visualisation, we can discontinue this function. * Deleted commented-out code * Updated docs * Removed unit test for dropped function * Increment version number to 1.0.3.9007 * Moved gtools from Suggests to Depends Also, standardized indentation. * Updated build version * added print statements to calculate_forward_probability.cpp Added lots of print statements to help with debugging * added print statements to calculate_backwards_probability.cpp added extra print statements for debugging * Fixed bug causing issue #116 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * Removed temporary code * Updated test expectations * Removed gtools dependency on SMC (#142) Removed dependency on gtools::mixedorder Works by extracting everything that isn't a digit ([0-9]) and ultimately using the index of the sorted elements to sort `rho_posterior_interval`. Works well for the standard "Item DD" format that SMC uses, and probably for other formats as well, but this wasn't extensively tested. * Replaced purrr::map with lapply on SMC (#142) * Replaced tidyr calls in SMC functions (#142) - Replaced tidyr::gather with stats::reshape - Replaced tidyr::spreadh with stats::reshape * Minor adjustments to SMC vignette Removed unused dependencies, Removed usage of , automatic whitespace adjustments. * Renamed SMC-Mallows vignette file So it matches the capitalization of "BayesMallows.pdf.asis" * Removed unneeded suggestions from DESCRIPTION * pedantic point * I suggest using a single file for references, to avoid duplication of data. * fixed some typos and tried to make the vignette code more consistent with the rest of the package, include <- for assignment * changed assignment operator in vignette * renamed all testfiles from test_ to test- * updated testthat version number in DESCRIPTION * ran styler on vignette * Created test which catches the warning in #159 * Fixed the warning, closes #159 * Mentions SMC in DESCRIPTION. * slight update in DESCRIPTION * updated news.md and incremented version number Co-authored-by: Anja Stein <anjastein@users.noreply.github.com> Co-authored-by: Anja Stein <anjastein@noreply.users.github.com> Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * corrected a bunch of typos and updated readme * corrected more typos with devtools::spellcheck() * accidentally deleted vignettes/BayesMallows.pdf in previous commit. fixed here * Convert MAP output to tibble (fixes #163) (#164) * Added test script for compute_rho_consensus (#163) * Minor test optimizations Restyling + shortening * Casting df as tibble (fixes #163) Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * Changed classes for compute_posterior_interval methods (#80) * Added tests to check BM and SMC classes (#80) * Implement generics to close #80 (#161) * Replaced Rcpp vector with arma vector (#90) * Removed TODO For the moment, smc_mallows_new_users_complete() will still use Rcpp::sample() to calculate the arma::uvec index. Replacement of Rcpp::sample() with arma::rand*() is encouraged, but left to any future developer aware of how to include probability weights on arma::rand*(). For more details, see conversation in issue #90. * Rearranged inline comments Top comment was relocated and rewritten on https://github.com/ocbe-uio/BayesMallows/issues/90#issuecomment-866614296 for better visibility and organization. Mid-code comment added for future reference. * Syntax fix * Reduced example length (closes #96) * Increment version number * Reduced unit test parameters (resolves #100) * Dropped usage of deprecated function (closes #99) * Added original scripts (#106) * Fitting scripts to package format (#106) * Added original scripts * Removed source calls, moved unit tests * Syntax fixes * Updated docs, exported new functions * Added placeholders for unit tests * Commented out failing tests These tests trigger errors on get_rank_distance(), to be investigated later (see issue #98 comments section for more details). * Increment version number * Increment version number * Syntax fix aug_prob is a vector, so we need to select just one element to perform those operations. * Fixed function name Function was using a deprecated, alternative name. * Fixed calls to get_mallows_loglik (#98, #109) * Reduced number of iterations on test * Restyled file * Fixes tests (#109) * Implemented tests (#98) * Edited test titles * Removed TODO * Improved SMC tests' speed (fixes #102) * Moved get_sample_probabilities() to src folder * Translated get_sample_probabilities + docs (#98) * Moved calculate_forward_probability to src folder * Exporting empty C++ function * Partial translation of calculate_forward_probability * Added get_sample_probabilities to smc.h * Finished translation of calculate_forward_probability Also: - Updated build version + Rcpp exports - Increment version number * Updated unit test expectations * Removed unnecessary library call * Translated calculate_backward_probability to C++ * Increment version number * Syntax fixes + refactoring * Changed file Unix permissions to match other files Used chmod to change the file permissions from 755 to 644 so it matches the rest of the files on the folder. * Added files for SMC-Mallows new item rank * Updated SMC partial rankings functions and tests * Restyled files * Syntax fixes * Commented out code to be worked on (#110) * Increment version number * Syntax fix * Formatted unit tests (#110) * Reduced test time (#110) Further test optimization Check fixes * Improvements to validation * Added SMC dataset * Improved partial ranking tests (#110) * Improved API feedback * Adapted test units for new item rank (#110) * Optimized unit tests (#110) * Minor fixes for clean check * Translated metropolis_hastings_aug_ranking_pseudo (#98) - Added skeleton of C++ metropolis_hastings_aug_ranking_pseudo - Translated metropolis_hastings_aug_ranking_pseudo - Replaced R version with C++ version - Fixed behavior of metropolis_hastings_aug_ranking_pseudo - Improved test format and updated expectations * Increment version number and R version dependency * Refactoring for easier debugging * Fixed RNG behavior on unit test * Removed superseded function * Added translation of metropolis_hastings_aug_ranking * Fixed documentation The docs for metropolis_hastings_aug_ranking_CPP() had text from the pseudo function. * Replaced R version of mh_aug_ranking with C++ (#98) Also, adjusted unit test expectations accordingly * Increment version number * Adjusted tests and renamed arguments (#98) * Added original code for correction_kernel C++ (#111) * Syntax fixes * Increment version number * Replaced R with C++ version of correction_kernel (#111) * Refactoring * Code optimization * Renamed cpp file * Added original code for correction_kernel_pseudo C++ (#111) * Syntax fixes * Replaced R with C++ of correction_kernel_pseudo (#111) * Increment version number * Replaced calculation of remaining_set * Translated smc_mallows_new_users_partial (#107) - Added C++ skeleton of smc_mallows_new_users_partial - Translated function * Set more seeds in unit tests This avoids random errors in unit testing. * Increment version number * Fixed calculation on smc_mallows_new_users_complete * Replaced R version with C++ version (#107) Of smc_mallows_new_users_partial(). * cal_fwd_prob() now works with both R and C++ indices * Refactoring * Adjusting unit tests * Returning test units to their original expectation * Updated Roxygen version * cal_bwd_prob() now works with both R and C++ indices This is basically a copy-paste from commit ce5d52cd. I smell a function coming... * Refactoring * Adjusting test expectations to new code output The differing output is caused by `set.seed(101)` having a different effect on the new C++ functions, particularly the output of `test_1_forward$aug_ranking`, which trickles down into the calculation of `test_1_backward_b`, thus causing different probabilities. The code was back-checked with the original R code, in which case the output seems the same. However, this should be checked with Anja. * Moved common code into function As "promised" on e497763640992f788c4ff0c98f6f127b99d4d785. * Translated partial ranks alpha fixed to C++ (#107) - Added skeleton of C++ alpha_fixed function - Finished translation - Switched R and C++ versions - Updated unit test expectations - Removed the R version of the function * Added parameters to SMC new users complete Added alpha_prob_sd, lambda and alpha_max, which were new arguments to metropolis_hastings_alpha and were internally defined as constants. * Added knitr as vignette engine Now both R.rsp and knitr are used as vignette builders. The former is used to add the BM paper in PDF format, the latter is hosting the SMC Rmarkdown vignette (yet a mockup). * Added mockup of SMC vignette * Updated .gitignore Update generated by `devtools::build_vignettes()`. * Updated build version * Translated new_item_rank to C++ (#113) * Replaced R new_item_rank with C++ version (#113) * Increment version number * Opening CI to all branches r.yml is currently configured for only triggering GitHub Actions CI workflow for the `master` and the `main` (inexistent here) branches. Opening it up to any branch so commits to `smc-mallows` also get triggered. This is important so we can better foresee problems in the upcoming merge with `master`. Opening up to any branch name shouldn't be a problem on this repository, since `master` is the only long-lived branch at the moment. * Syntax fixes * Refactoring * More specific seed setting * Fixing tests for Ubuntu Tests for Mac and Windows are still failing due to RNG. To be addressed later. * Investigate tests (#127) * Added prints statements to `arma::shuffle` * Added unique sort to `setdiff` * Updated tests Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> * Updates to smc_post_processing_functions.R (#119) * Updates to smc_post_processing_functions.R Hi, Just done a bit of tidying with the post_processing_functions. Here is a summary of my proposed changes: 1. edited `smc_processing` to allow the option to print the `col_names` of the original dataset if appropriate 2. edited `compute_consensus` to print the output correctly in the `MAP` case and to print the `colnames` of a dataset if appropriate instead of listing items as 'item 1, item 2, ... etc'. 3. edited `plot_posterior_intervals_rho` to print the `colnames` of a dataset if appropriate instead of listing items as 'item 1, item 2, ... etc'. 4. adjusted the font sizes of the axis labels in `plot_heatplot_rho` 5. removed the variable `verbose` from `plot_posterior_alpha` so that it now prints when calling the functions and doesn't do duplicate plots. 6. commented out any unused post-processing functions I have added some general comments, which begin with `#AS:` to explain why I have made the following changes (even though Github will highlight them). Let me know if you disagree or think any changes are unnecessary. I am planning on renaming the variables in the functions `heatMat` and `heatplot_fixed` so that they are consistent with the other heatplot functions, but I shall do this once this pull request has been completed/resolved(?). Waldir's changes: * Changed test unit expectations * Documentation fixes * Removed commented-out code * Replaced dplyr call with base R Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Updated smc.rmd Copy-pasted vignette script to github. Need to upload the matching .bib file containing the references. * create vignette.bib This file contains the references to be printed in the smc.Rmd file * Remove unused columns The final columns of rho_samples and alpha_samples do not get populated with non-zero values, so they are redundant. The same change applies to smc_mallows_new_item_rank_alpha_fixed, so this will appear as another pull request. * Remove unused column Extra column in rho_samples is redundant * Update compute_posterior_intervals_rho Reordered column in output to print item names in correct numerical order "item 1, item 2, ..., item 10" instead of "item 1, item 10, item 2, ..., item 9" * Cosmetic changes to heatplot functions Renamed variables to keep variable names consistent. Added some comments to explain the steps in the functions. * Updated test expectation Test units should be reset to expect one fewer columns, given the most recent code changes proposed. * Updated test expectations The previous changes on this branch reduce the number of columns by 1, so this must be reflected in the relevant unit test expectations. * Syntax fixes + doc update * Syntax fixes * Increment version number * Syntax adjustments * Changed test expectations back to what they should be See comment https://github.com/ocbe-uio/BayesMallows/issues/116#issuecomment-938583180 for more details. * Trying to reproduce Anja's seed and output * Increment version number * Added C++ version of smc_mallows_new_item_rank_alpha_fixed (#113) * Replaced R with C++ of smc_mallows_new_item_rank_alpha_fixed (#113) * Added C++ function of SMC new item alpha fixed (#113) * Added C++ version of smc_mallows_new_item_rank_alpha_fixed (#113) * Replaced R with C++ of smc_mallows_new_item_rank_alpha_fixed (#113) * Added C++ function of SMC new item alpha fixed (#113) * Added unit tests for #134 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> * Reduced test time * get_mallows_loglik now transposes as needed (#134) This eliminated the bug when passing rankings as a row vector and rho as a column vector (or vice-versa). Both still need to be matrices, though. * Increment version Increment version number to 1.0.3.9002 Increment version number to 1.0.3.9003 Increment version number to 1.0.3.9004 * Updated build version * Exported all functions from #117 - Exported `plot_rho_heatplot()` - Exported `plot_alpha_posterior()` - Exported `compute_posterior_intervals_alpha()` - Exported `compute_posterior_intervals_rho()` - Exported `compute_rho_consensus()` Also, some function names were renamed in comments and the SMC vignette text due to slight differences between their names there and the one on the code. The names on the code were preferred. Namely, the changes were: 1. `plot_heatplot_rho` into `plot_rho_heatplot` 2. `compute_consensus_rho` into `compute_rho_consensus` * Refactoring * Increment version number to 1.0.3.9006 * Added print argument to internal function * Updated test expectation, added comments * Added temporary print statements for debugging * Increment version number to 1.0.3.9007 * Added function plot_rho_posterior.R in smc_post_processing_functions.R (#137) * Added function plot_rho_posterior.R in smc_post_processing_functions.R * Synxtax fixes + whitespace removal * Exporting function with documentation Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Changing output of SMC function to new class Including change in test expectation. * Added generics, methods for compute_posterior_intervals * Changed classes of Mallows objects (#80) Generics and methods related to `compute_posterior_intervals()` had some class additions to allow for better dispatching between BayesMallows and SMC-Mallows methods. * Moved methods to same file (#80) Moved all methods of `compute_posterior_intervals()` and `.compute_posterior_intervals()` to the same file (easier to manage). * Syntax and documentation fixes/updates * Increment version number to 1.0.3.9006 * Updated TODOs * Update smc.Rmd Removed the heatplot function and replaced it with the plot rho posterior function. Some descriptions have changed to fit the description of the posterior function. * Remove heatplot functions Since we now have the `plot_rho_posterior` function to clearer visualisation, we can discontinue this function. * Deleted commented-out code * Updated docs * Removed unit test for dropped function * Increment version number to 1.0.3.9007 * Moved gtools from Suggests to Depends Also, standardized indentation. * Updated build version * added print statements to calculate_forward_probability.cpp Added lots of print statements to help with debugging * added print statements to calculate_backwards_probability.cpp added extra print statements for debugging * Fixed bug causing issue #116 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * Removed temporary code * Updated test expectations * Removed gtools dependency on SMC (#142) Removed dependency on gtools::mixedorder Works by extracting everything that isn't a digit ([0-9]) and ultimately using the index of the sorted elements to sort `rho_posterior_interval`. Works well for the standard "Item DD" format that SMC uses, and probably for other formats as well, but this wasn't extensively tested. * Replaced purrr::map with lapply on SMC (#142) * Replaced tidyr calls in SMC functions (#142) - Replaced tidyr::gather with stats::reshape - Replaced tidyr::spreadh with stats::reshape * Minor adjustments to SMC vignette Removed unused dependencies, Removed usage of , automatic whitespace adjustments. * Renamed SMC-Mallows vignette file So it matches the capitalization of "BayesMallows.pdf.asis" * Removed unneeded suggestions from DESCRIPTION * Created generic for compute_consensus * Generalized compute_consensus subfunctions (#80) Tests started failing due to different output structure from the previous expectation. To be investigated. * Fixed leftover merge conflict from develop * Increment version number to 1.0.4.9002 * Dropped usage of dplyr::do * Updated docs * Increment version number to 1.0.4.9003 * Reindented test code to aid debugging * Removed duplicated unit tests with wrong name Apparently git didn't pickup on the renaming of "test_" to "test-" * (Re)deleted redundant bib file All vignettes point to a common inst/REFERENCES.bib, no need for a new file. * sorted the consensus output * Renamed class of compute_consensus.BayesMallows output (#80) * Renamed test file Since it contains tests for both `compute_consensus()` and `compute_posterior_intervals()`. * Added class tests for compute_rho_consensus (#80) * Introducing consensus_SMCMallows class (#80) * Moved compute_consensus methods together (#80) * Updated docs * Removed finished TODOs from code Co-authored-by: Anja Stein <anjastein@users.noreply.github.com> Co-authored-by: Anja Stein <anjastein@noreply.users.github.com> Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * incremented version number and updated CRAN note * corrected spelling error in smc vignette * recompiled documentation after resolving conflicts with master branch * recompiled readme and update some citations * Added linter CI workflow * Using <- for assignment * Removed commented out code * Improved spacing around commas and operators * Replaced tab with space for indentation * Fixed spacing before curly brace * Replaced single quotes with double * Adjusting space before left parenthesis * Replaced F with FALSE * Removed superfluous trailing blank lines * Removed unnecessary concatenation Co-authored-by: Øystein Sørensen <oystein@ysteins-mbp.lan> Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> Co-authored-by: Anja Stein <anjastein@users.noreply.github.com> Co-authored-by: Anja Stein <anjastein@noreply.users.github.com> Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * fixed #168 and added unit test * issue 112 smc memory (#169) * Improved variable declaration on maybe_offset_indices() (#112) * Improved variable declaration on calculate_backward_probability() (#112) * Replaced redundancies with two functions (#112) (#170) New C++ functions: - `arma_setdiff_vec()` - `Rcpp_setdiff_arma()` Both are slight variations of `arma_setdiff()` using different-classed objects. Code could be further optimized by merging the new functions into arma_setdiff(). Good luck dealing with all the vec-uvec conversions, though. * Declared constants and references (#112) (#172) * Removed trailing blank line [Linter](https://github.com/ocbe-uio/BayesMallows/pull/170/files) was complaining. * Declaring constants and references on SMC (#112) * Replaced SMC code with functions (#112, #114) (#173) This was primarily done as a stepping stone to replacing some Armadillo/Rcpp back-and-forth (see issue #112). Removing duplicated code makes it easier to replace Rcpp crutches later. The newly-created functions were also simplified as much as I could to get #112 solved. * Fix boolean operands (#175) * Increment version number to 1.1.0.9001 * Fixed boolean operands This should solve the eventual warnings for using bitwise `|` or `&` with boolean operands. * Fix oldrel errors (#176) * Increment version number to 1.1.0.9001 * Fixed boolean operands This should solve the eventual warnings for using bitwise `|` or `&` with boolean operands. * Refactored reshaping on smc_processing() #174 There seems to be a problem with setting `idvar` to `NULL` in R-oldrel, possibly due to some change on the `stats::reshape()` function. This change intends to fix it without changing the output. * Excluding RcppExports.R from linter This file is generated automatically and it keeps triggering a warning on GitHub Actions about it containing a superfluous trailing blank line. * Increment version number to 1.1.0.9002 * Addressing #181 (#182) * Issue 184 cpp (#187) * fixed return type of sample_one_with_prob #184 * updated news * Clean up headers (#196) * removed unnecessary include from distances.h * removed unnecessary statements from missing_data.h * a lot of DRY-ing of header files * corrected typo in function name * removed include for algorithm as it is already included by RcppCommon.h * deleted some more unnecessary includes * incremented to development version * updated news * Update smc_mallows_new_users_complete.cpp (#189) * Update smc_mallows_new_users_complete.cpp Include a vector named ESS_vec (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. * Update smc_mallows_new_users_complete.cpp * Update smc_mallows_new_users_complete.cpp * Update smc_mallows_new_users_complete.cpp * Fixed calculation of ESS_vec elements `^` is not a valid Armadillo operator (see list [here](http://arma.sourceforge.net/docs.html#operators)). The usual way to square a matrix is to multiply it by its transpose, so that's what I proposed here. The operation was also separated from the sum so arma would stop complaining (maybe this could be a one-liner again by using `conv_to()`, but I didn't wanna do that. * Fixup for 06d7c87 Previous commit was syntatically OK, but issues arised when running tests. This fixes it * Adjusted unit tests to ESS addition * Update smc_mallows_new_users_complete.cpp Changed the calculation for ESS - I was using the incorrect formula. * Added unit test for ESS Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Replaced all arma::*word (#202) * Replaced all arma::*word (#199) * Increment version number to 1.1.2.9001 * Reverted changes from ba7c5527f on misc.h Using `using namespace` in header files should be avoided, as their effect trickle down to any other file using them. * Removal of arma:: qualifier from functions (#205) * replaced arma::*class* in mixtures.cpp * removed arma:: in distances.cpp * replaced arma:: in importance_sampling.cpp * leapandshift * removed more arma:: in misc.cpp * removed arma::*class* in missing_data.cpp * removing arma:: in pairwise_comparisons.cpp * removing arma:: in parameterupdates.cpp * removing arma:: in partitionfuns.cpp * removing arma:: in rmallows.cpp * removing arma:: in run_mcmc.cpp * removed arma::*class* from smc functions * replaced arma::ones with ones * replaced arma::zeros and arma::rand* with zeros and rand* * replaced arma::fill* with fill* * replaced arma::span with span * replaced arma::exp with exp * replaced arma::log with log * replaced arma::accu with accu * replaced arma::conv_to with conv_to * replaced arma::max and arma::min with max and min * replaced arma::sum with sum * replaced arma::normalise with normalise * replaced arma::find with find * replaced arma::regspace and arma::linspace with regspace and linspace * replaced arma::shuffle with shuffle * replaced arma::as_scalar with as_scalar * removed arma:: from various not-so-frequently-used functions * removal of arma:: qualifier from more functions * Revert "Removal of arma:: qualifier from functions (#205)" (#206) This reverts commit 3ec2432e218b8f35dccdbe55197229573c97241a. * More work towards #199 (#203) * replaced arma::*class* in mixtures.cpp * removed arma:: in distances.cpp * replaced arma:: in importance_sampling.cpp * leapandshift * removed more arma:: in misc.cpp * removed arma::*class* in missing_data.cpp * removing arma:: in pairwise_comparisons.cpp * removing arma:: in parameterupdates.cpp * removing arma:: in partitionfuns.cpp * removing arma:: in rmallows.cpp * removing arma:: in run_mcmc.cpp * removed arma::*class* from smc functions * Issue 200 (#204) * replaced arma::*class* in mixtures.cpp * removed arma:: in distances.cpp * replaced arma:: in importance_sampling.cpp * leapandshift * removed more arma:: in misc.cpp * removed arma::*class* in missing_data.cpp * removing arma:: in pairwise_comparisons.cpp * removing arma:: in parameterupdates.cpp * removing arma:: in partitionfuns.cpp * removing arma:: in rmallows.cpp * removing arma:: in run_mcmc.cpp * removed arma::*class* from smc functions * replaced arma::ones with ones * replaced arma::zeros and arma::rand* with zeros and rand* * replaced arma::fill* with fill* * replaced arma::span with span * Issue 201 (#207) * replaced arma::*class* in mixtures.cpp * removed arma:: in distances.cpp * replaced arma:: in importance_sampling.cpp * leapandshift * removed more arma:: in misc.cpp * removed arma::*class* in missing_data.cpp * removing arma:: in pairwise_comparisons.cpp * removing arma:: in parameterupdates.cpp * removing arma:: in partitionfuns.cpp * removing arma:: in rmallows.cpp * removing arma:: in run_mcmc.cpp * removed arma::*class* from smc functions * replaced arma::ones with ones * replaced arma::zeros and arma::rand* with zeros and rand* * replaced arma::fill* with fill* * replaced arma::span with span * replaced arma::exp with exp * replaced arma::log with log * replaced arma::accu with accu * replaced arma::conv_to with conv_to * replaced arma::max and arma::min with max and min * replaced arma::sum with sum * replaced arma::normalise with normalise * replaced arma::find with find * replaced arma::regspace and arma::linspace with regspace and linspace * replaced arma::shuffle with shuffle * replaced arma::as_scalar with as_scalar * removed arma:: from various not-so-frequently-used functions * removal of arma:: qualifier from more functions * added pdf(NULL) (#208) * Update smc_mallows_new_users_partial_alpha_fixed.cpp (#191) * Update smc_mallows_new_users_partial_alpha_fixed.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_users_partial_alpha_fixed.cpp * Syntax fix, updated test expectations * Update smc_mallows_new_users_partial_alpha_fixed.cpp Updated L28 to explain the output. Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Update smc_mallows_new_users_partial.cpp (#190) * Update smc_mallows_new_users_partial.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_users_partial.cpp * Syntax fix * Adjusted unit test expectations * Update smc_mallows_new_users_partial.cpp Updated L34 to explain the output. * Update smc_mallows_new_users_partial.cpp Updated L34 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Issue 162 (#211) * replaced two dplyr::filter with [ * replaced some more dplyr::filter * replaced more dplyr * replaced more dplyr::filter * replaced dplyr::filter in plot.BayesMallows * replaced more dplyr::filter * replaced more dplyr::filter * replaced more dplyr::filter * replaced the easy dplyr::filter in compute_consensus.R * replaced more easy dplyr::filters * fixed a line to avoid soft-deprecated dplyr syntax * more complicated un-dplyr-ing in assign_cluster.R * some reordering of test output * simplified a group-by * removed dplyr from map cluster * eliminated dplyr from assign_cluster.R * removed dplyr::mutate a few more places * removed a dplyr::mutate in assess_convergence.R * removed another dplyr::mutate * un-dplyred assess_convergence.R * replaced a dplyr::if_else * replaced some dplyr::select * replaced another mutate * replaced a dplyr::semi_join with base::merge in generate_transitive_closure.R * replaced more dplyr with base * replaced two dplyr::filter with [ * replaced some more dplyr::filter * replaced more dplyr * replaced more dplyr::filter * replaced dplyr::filter in plot.BayesMallows * replaced more dplyr::filter * replaced more dplyr::filter * replaced more dplyr::filter * replaced the easy dplyr::filter in compute_consensus.R * replaced more easy dplyr::filters * fixed a line to avoid soft-deprecated dplyr syntax * more complicated un-dplyr-ing in assign_cluster.R * some reordering of test output * simplified a group-by * removed dplyr from map cluster * eliminated dplyr from assign_cluster.R * removed dplyr::mutate a few more places * removed a dplyr::mutate in assess_convergence.R * removed another dplyr::mutate * un-dplyred assess_convergence.R * if_else to ifelse * replaced some dplyr::select * replaced another mutate * replaced a dplyr::semi_join with base::merge in generate_transitive_closure.R * replaced more dplyr with base * more dplyr replacements * incorporating some updates * some more replacements * replacement in compute_consensus.R * more replacements of dplyr * fixed small issue * replaced a select * changed return values to dataframes * more changes from tibble to data.frame * fixed tests due to sorting * replaced dplyr in estimate_partition_function * simplified naming of columns * replaced dplyr in plot.BayesMallows.R * small change in assign_cluster.R * replaced a dplyr in plot_top_k.R * discovered a code duplication which could easily be fixed * removed a lot of dplyr in compute_consensus.R * updated classes in tests and return values * base function for finding unique values * replaced group and count with aggregate * DRY-ing #114 and base-r-ification * the two find_cpc functions were identical, so I merged them * replaced a group-count with an aggregate * replaced a dplyr in map consensus * DRYing #114 and conversion to base R * all dplyr in compute_consensus.R replaced by base * enormous DRY-ing * replaced more dplyr with base * all tests passing * removed dplyr in example and added import * fixed misspelled import * styling assign_cluster * styling compute_consensus.R * styling compute_posterior_intervals * more styling * increased test coverage of expected_dist * styling of test files * DRY-ing while fixing a false negative in codecov * added more complete tests for consensus with SMC * Addressed "unneded concatenation of a constant" linting * Added change notice on predict_top_k * Added change notice to predict_top_k * improved the message * incremented development version * Adding space between parentheses Should solve linting warnings from 5b64da93. Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Added CodeFactor badge (#213) * Added CodeFactor badge * Moved changes to Rmd file, rebuilt md README.md was rebuilt using `devtools::build_readme()`, which triggered some past changes which should be double-checked. * compiled README.Rmd locally by pressing the knit button Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> * Issue 214 (#215) * created test that catches #214 * updated test so it does not produce pdf file * solve #214 * updated news * Issue 212 (#216) * Started replacing dplyr in test files * removed another dplyr * removed dplyr from test-compute_mallows.R * replaced dplyr in test-compute_consensus.R * replaced dplyr in test-plot_top_k.R * all dplyr dependencies in tests removed * removed dplyr from obs_freq_example * removed dplyr from compute_consensus_example * removed dplyr from plot_top_k_example * added plot_top_k example to predict_top_k * removed dplyr from estimate_partition_function_example * removed more dplyr from examples * replaced dplyr in generate_transitive_closure_example.R * removed dplyr from compute_mallows_example.R * removed two unnecessary library() statements in SMC-Mallows vignette * converted partition function data from tibble to data.frame * simplified script for generating beach data * updated documentation * removed dplyr from DESCRIPTION * updated NEWS.md * updated development version * ran styler on R/ * Followed the advice of CodeFactor, replacing mapply with Map * fixed some forgotten dplyr code which did not cause error due to 'dontrun' * Removed comment referring to #91 * replacing sink() with capture.output() * Dry (#217) * DRY-ed log_lik_db function * added internal documentation * styling * formatted documentation * Update smc_mallows_new_item_rank.cpp (#192) * Update smc_mallows_new_item_rank.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_item_rank.cpp * Fixed syntax, added FIXME * Update smc_mallows_new_item_rank.cpp Updated L33 * Update smc_mallows_new_item_rank.cpp Corrected lines involving `ESS_vec`. * Updated @return documentation * Changed initialization of `ESS_vec` It is now declared later in the code so its initial values can be calculated first. * Updated unit test expectations * Updated Rd docs * Updated docs * Updated initialization of ESS_vec Following https://github.com/ocbe-uio/BayesMallows/commit/156ae3727b20690a25ccb320657659db78e368dd#r72662511 and https://github.com/ocbe-uio/BayesMallows/pull/192#discussion_r862766447, `ESS_vec` starts with `ess_init` on index 0 and zero on indices {1, ..., Time - 1}. Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Dry (#218) * used existing function for computing distance * updated documentation * fixing CodeFactor issue * increasing test coverage * simplified code in lik_db_mix (#220) * simplified code in lik_db_mix * fixed some duplication on my side * fixed error causing tests to fail * renamed get_mallows_loglik (#221) * renamed get_mallows_loglik * fixed CodeFactor issues * using boost factorial function instead * simplified factorials * deleted unnecesary headers * added header * added a comment and replaced math.h with cmath * Binomial coefficient (#222) * DRY logz_cardinalities * DRY log_expected_dist * replaced code duplication with a function * realized we can use binomial coefficient from Rmath.h * got rid of an unnecessary statement in mixtures.cpp * Vec seq (#223) * DRY logz_cardinalities * DRY log_expected_dist * replaced code duplication with a function * realized we can use binomial coefficient from Rmath.h * got rid of an unnecessary statement in mixtures.cpp * replaced arma_vec_seq with regspace * Setdiff (#225) * DRY logz_cardinalities * DRY log_expected_dist * replaced code duplication with a function * realized we can use binomial coefficient from Rmath.h * got rid of an unnecessary statement in mixtures.cpp * replaced arma_vec_seq with regspace * got rid of one of the may setdiff functions * created a single setdiff function (#226) * created a single setdiff function * changed setdiff.hpp to setdiff.h * some cleaning of header files (#230) * replaced Rcpp::sample with arma::shuffle, #227 (#228) * replaced Rcpp::sample with arma::shuffle, #227 * replaced formatting of include * created sampling function, let's see if it passes the tests * removed require() from test * got rid of sample_int * got rid of sample_one_with_prob * got rid of permute_with_weights * added two more tests to understand platform dependency * replaced one new_pseudo_proposal * got rid of new_pseudo_proposal. tests succeeding locally * replaced more shuffle(). * updated unit tests * removed library statement * made setdiff function call by reference * replaced .size() with .n_elem for arma objects * removed some empty lines * turned back a shuffle * another shuffle * checking no windows * updated tests * another update * updated tests * should not test ESS due to bug * updated test * testing on windows * replaced a shuffle with a randperm * replaced unnecessary headers * updated dev version and wrote a line in NEWS.md * renamed a file * Rename loglik (#231) * renamed lik_db_mix to get_mallows_loglik and deprecated it * fixed deprecation notice * Dry smc (#232) * DRY-ed augmentation of ranks for new users * DRY-ed the reweighting for smc_new_users * DRY-ed new_users_complete as well * First DRY-ing of smc_mallows_new_users * had forgot an & * reduced the number of arguments * reorganized code and solved #219 * made an initializer for alpha_samples * refactored a little bit more * Small code modifications (#234) * some small simplification * Update smc_leap_and_shift_probs.cpp Using default argument * put forward and backward probability into a single function (#235) * some small changes (#236) * some improvements of the all_topological_sorts function (#237) * some improvements of the all_topological_sorts function * fixed CodeFactor issue * create a single function for smc_mallows_new_users* (#238) * create a single function for smc_mallows_new_users* * some DRY-ing * fixed documentation issue causing tests to fail * Leap and shift (#240) * cleaning of leap-and-shift code * moved SMC shift step for easier comparison with the other leap and shift function * removed static_cast in leap-and-shift * simplified by using regspace * more code cleaning * deleted whitespace * Ls issue 239 (#241) * cleaning of leap-and-shift code * moved SMC shift step for easier comparison with the other leap and shift function * removed static_cast in leap-and-shift * simplified by using regspace * more code cleaning * deleted whitespace * fixed leap-and-shift bug in #239 * updated NEWS.md and version number * Update smc_mallows_new_item_rank_alpha_fixed.cpp (#193) * Update smc_mallows_new_item_rank_alpha_fixed.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_item_rank_alpha_fixed.cpp * Update smc_mallows_new_item_rank_alpha_fixed.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_item_rank_alpha_fixed.cpp * Syntax fix * Removed duplicated code * Update smc_mallows_new_item_rank_alpha_fixed.cpp Updated L39 to explain the output. * Update smc_mallows_new_item_rank_alpha_fixed.cpp Updated lines involving `ESS_vec` * Update test-smc_mallows_new_item_rank.R Updated test script for smc_mallows_new_item_rank_alpha_fixed Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Testing of C++ functions (#242) * added framework for unit testing of C++ functions and wrote unit test for leapandshift.cpp * fixed CodeFactor issue * another attempt at making CodeFactor happy * SMC now uses the same leap-and-shift function as BayesMallows. Turned the SMC function into a thin wrapper for now. * made leap_and_shift_probs internal * updated readme * Small vignette edits * Dry new item (#243) * DRY-ed initialize_rho function * made common initialize_rho function and updated tests for BayesMallows * refactored initialize_alpha * merged new_item_rank functions * deprecated smc_mallows_new_item_rank_alpha_fixed * extracted a function for the move step * some refactoring * fixed CodeFactor issue! * Updated NEWS.md and incremented development version * made aug_ranking function call by reference * Added tests with explicit expections of numeric output for new_item_rank to make sure #243 is safe * tests passing on mac * fixed CodeFactor issue * another DRY-ing * added a function for normalizing weights * Incremented version and updated news and cran-comments #249 * Updated NEWS.md and cran-comments.md * Update smc_mallows_new_users.cpp (#251) * Update smc_mallows_new_users.cpp - added loop for `partial` and `partial fixed` case to lines 191 and - adjusted loop start and endpoints lines 209 and 220 * updated tests * tiny style update * Updated NEWS.md * Changed divide_by_fact to make it more readable Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> * updated news and incremented development version * Fixed CI linter (#253) * Updated linter YAML * Auto-updated docs * Fix @title for sample_dataset (#256) * Improved title of `sample_dataset` * Increment version to 1.2.0.9001, updated NEWS * Updating new rank functions (#252) * Added original script (#198) From @anjastein > The script called `updated_rankings_functions_for_waldir.R` contains the new functions that would benefit from being translated from R to C++. A lot of the code suffers from DRY (two very similar functions but in one of them the variable alpha is fixed) and probably uses a lot of code that you have created in the BayesMallows SMC extension of the CRAN package already, so I hope it won't be time-consuming. * Roxygenized docs, split unit tests (#198) * Commented out temporarily-broken tests (#198) * Removed explicit calls to the function (#198) * Replaced `abort()` calls with `stop()` (#198) * Updated renamed functions See commit 375a6f6f0aeefb9b019bc11eec3d3a28528485e5 for details. * Updated proposed code to the 1.2.0 API * Restyled file * Added TODOs * Minor doc fix (#198) * Adding `smc_mallows_new_item_rank_updated_cpp()` (#198) * Adding default value to `alpha_samples_init` The alpha-fixed variant does not use it. * Wrapping unit tests around `test_that()` (#198) * Updated build version * Added TODO * Improved variable declaration * Updated docs and Rcpp exports * Increment version number to 1.2.0.9002 * Syntax fixes (#198) * Updated unit tests to use C++ version (#198) * Improved handling of alpha_fixed without alpha_samples_init (#198) * Updated docs, RoxygenNote version * Replaced original R functions with C++ (#198) * Merged identical functions (#198) * Replaced `smc_mallows_new_item_rank()` (#198) Subfunction was also moved away from _back_ into , since it's not being used anywhere else * Updated deprecated smc_mallows_new_rank funcs Rerouting to new function deleted because the arguments mismatch. squash! fixup! Updated deprecated smc_mallows_new_rank funcs * Added default to `rho_samples_init` (#198) Defaults to NULL, in which case `initialize_rho()` is called, as per the previous implementation. squash! Added default to `rho_samples_init` (#198) * Adapted unit tests accordingly to #198 updates * Removed warning when `alpha_samples_init` is not provided (#198) This restores the behavior from the previous version, which is to _silently_ generate alpha_samples. Since the warning introduced on commit f2bd74c4ce7b97fca5d6a3871f3c0ea4332fbde1 was removed, the test unit introduced there makes no sense anymore, so it was removed. * Added function to augment rankings (#198) Copy-pasted from previous version of `smc_mallows_new_item_rank()`. * Augment ranking if empty aug_rankings_init (#198) * Added error expectation to unit tests * Fixed warnings caused by comparison between int and uword * Fixed test unit syntax The removed bit was depending on `smc_test_new_user_unif`, an object which has not been created at that point. This issue was present in the original script. Also, the error message is now explicitly mentioned to match the purpose of this particular test unit. * Added TODO * Simplified syntax (#198) * Moved test further down the script To a place where all inputs are already defined. * Allowing `aug_rankings_init` to be nullable * Adapted test expectations * Code style adjustments * Drastically reduced test execution time (#198) Test script modified to reduce code footprint and execution time. Test on local machine showed a reduction from 144 s to 0.3 s to run the affected script. * Replacing casting function with one-liner (#198) Source: https://github.com/ocbe-uio/BayesMallows/pull/252#discussion_r978953965 * Replacing arma for Rcpp on function argument (#198) Source: https://github.com/ocbe-uio/BayesMallows/pull/252#discussion_r978955092 Co-authored-by: Anja Stein <a.stein1@lancaster.ac.uk> Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> * codefactor issue * CodeFactor issue * CodeFactor issues * Adding data-raw to directories lintr should ignore * Added main testthat file to linter-ignore * Minor code style adjustments Addressed redundant blank lines accused by CodeFactor to clear up the number of issues raised by the system. We're not far from an A+ rating! :) * Updated testthat.R * Updated NEWS.md * Changing to forward slash in codecov.yml * Revert "Changing to forward slash in codecov.yml" This reverts commit c8cda93db3ab2496c1835ca78c12a6b6195674f6. * Changing to forward slash in codecov.yml * Added example to linter-ignore Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Øystein Sørensen <oystein@ysteins-mbp.lan> Co-authored-by: Anja Stein <anjastein@users.noreply.github.com> Co-authored-by: Anja Stein <anjastein@noreply.users.github.com> Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> Co-authored-by: Anja Stein <a.stein1@lancaster.ac.uk>
* Changing to forward slash in codecov.yml (#259) * incremented to development version * Add linter CI (#167) * replaced purrr with lapply in plot_elbow and wrote an extra test * change purrr with Map in sample_mallows * replaced purrr with lapply in compute_mallows_mixtures * removed purrr from compute_posterior_intervals * removed purrr from assess_convergence * removed purrr from rank conversion * replaced purrr with vapply et al in print function and added test * removed purrr from compute_mallows * removed purrr from generate_constraints and from a test * removed purrr from Imports and incremented development version * removed library call to purrr * replaced map with lapply in example * removed another call to map * hope I soon have removed every piece of purrr * updated docs * Untidyr (#154) * removed tidyr from sample_mallows * removed tidyr from assign_cluster * removed tidyr from predict_top_k and updated tests * replaced tidyr in plot_top_k * replaced one tidyr in compute_consensus * replaced tidyr in compute_consensus and updated tests * replaced tidyr in generate_constraints * replaced tidyr in test_compute_mallows * removed a whole lot of dependencies * removed tidyr from Imports * updated news * Untidyr (#156) * removed tidyr from sample_mallows * removed tidyr from assign_cluster * removed tidyr from predict_top_k and updated tests * replaced tidyr in plot_top_k * replaced one tidyr in compute_consensus * replaced tidyr in compute_consensus and updated tests * replaced tidyr in generate_constraints * replaced tidyr in test_compute_mallows * removed a whole lot of dependencies * removed tidyr from Imports * updated news * moved permutations function to R/misc.R * Removed permfun.R and remaining source of it * SMC-Mallows (#157) * Identified more codelines related to #90 * Reclassified Rcpp objects as arma (#90) In the smc_leap_and_shift_probs() function. * Increment version number * Fixed unit tests * Updated TODOs * Increment version number * Replaced Rcpp::sample with arma::randi (#90) * Adjusted unit tests * Replaced Rcpp vector with arma vector (#90) * Removed TODO For the moment, smc_mallows_new_users_complete() will still use Rcpp::sample() to calculate the arma::uvec index. Replacement of Rcpp::sample() with arma::rand*() is encouraged, but left to any future developer aware of how to include probability weights on arma::rand*(). For more details, see conversation in issue #90. * Rearranged inline comments Top comment was relocated and rewritten on https://github.com/ocbe-uio/BayesMallows/issues/90#issuecomment-866614296 for better visibility and organization. Mid-code comment added for future reference. * Syntax fix * Reduced example length (closes #96) * Increment version number * Reduced unit test parameters (resolves #100) * Dropped usage of deprecated function (closes #99) * Added original scripts (#106) * Fitting scripts to package format (#106) * Added original scripts * Removed source calls, moved unit tests * Syntax fixes * Updated docs, exported new functions * Added placeholders for unit tests * Commented out failing tests These tests trigger errors on get_rank_distance(), to be investigated later (see issue #98 comments section for more details). * Increment version number * Increment version number * Syntax fix aug_prob is a vector, so we need to select just one element to perform those operations. * Fixed function name Function was using a deprecated, alternative name. * Fixed calls to get_mallows_loglik (#98, #109) * Reduced number of iterations on test * Restyled file * Fixes tests (#109) * Implemented tests (#98) * Edited test titles * Removed TODO * Improved SMC tests' speed (fixes #102) * Moved get_sample_probabilities() to src folder * Translated get_sample_probabilities + docs (#98) * Moved calculate_forward_probability to src folder * Exporting empty C++ function * Partial translation of calculate_forward_probability * Added get_sample_probabilities to smc.h * Finished translation of calculate_forward_probability Also: - Updated build version + Rcpp exports - Increment version number * Updated unit test expectations * Removed unnecessary library call * Translated calculate_backward_probability to C++ * Increment version number * Syntax fixes + refactoring * Changed file Unix permissions to match other files Used chmod to change the file permissions from 755 to 644 so it matches the rest of the files on the folder. * Added files for SMC-Mallows new item rank * Updated SMC partial rankings functions and tests * Restyled files * Syntax fixes * Commented out code to be worked on (#110) * Increment version number * Syntax fix * Formatted unit tests (#110) * Reduced test time (#110) Further test optimization Check fixes * Improvements to validation * Added SMC dataset * Improved partial ranking tests (#110) * Improved API feedback * Adapted test units for new item rank (#110) * Optimized unit tests (#110) * Minor fixes for clean check * Translated metropolis_hastings_aug_ranking_pseudo (#98) - Added skeleton of C++ metropolis_hastings_aug_ranking_pseudo - Translated metropolis_hastings_aug_ranking_pseudo - Replaced R version with C++ version - Fixed behavior of metropolis_hastings_aug_ranking_pseudo - Improved test format and updated expectations * Increment version number and R version dependency * Refactoring for easier debugging * Fixed RNG behavior on unit test * Removed superseded function * Added translation of metropolis_hastings_aug_ranking * Fixed documentation The docs for metropolis_hastings_aug_ranking_CPP() had text from the pseudo function. * Replaced R version of mh_aug_ranking with C++ (#98) Also, adjusted unit test expectations accordingly * Increment version number * Adjusted tests and renamed arguments (#98) * Added original code for correction_kernel C++ (#111) * Syntax fixes * Increment version number * Replaced R with C++ version of correction_kernel (#111) * Refactoring * Code optimization * Renamed cpp file * Added original code for correction_kernel_pseudo C++ (#111) * Syntax fixes * Replaced R with C++ of correction_kernel_pseudo (#111) * Increment version number * Replaced calculation of remaining_set * Translated smc_mallows_new_users_partial (#107) - Added C++ skeleton of smc_mallows_new_users_partial - Translated function * Set more seeds in unit tests This avoids random errors in unit testing. * Increment version number * Fixed calculation on smc_mallows_new_users_complete * Replaced R version with C++ version (#107) Of smc_mallows_new_users_partial(). * cal_fwd_prob() now works with both R and C++ indices * Refactoring * Adjusting unit tests * Returning test units to their original expectation * Updated Roxygen version * cal_bwd_prob() now works with both R and C++ indices This is basically a copy-paste from commit ce5d52cd. I smell a function coming... * Refactoring * Adjusting test expectations to new code output The differing output is caused by `set.seed(101)` having a different effect on the new C++ functions, particularly the output of `test_1_forward$aug_ranking`, which trickles down into the calculation of `test_1_backward_b`, thus causing different probabilities. The code was back-checked with the original R code, in which case the output seems the same. However, this should be checked with Anja. * Moved common code into function As "promised" on e497763640992f788c4ff0c98f6f127b99d4d785. * Translated partial ranks alpha fixed to C++ (#107) - Added skeleton of C++ alpha_fixed function - Finished translation - Switched R and C++ versions - Updated unit test expectations - Removed the R version of the function * Added parameters to SMC new users complete Added alpha_prob_sd, lambda and alpha_max, which were new arguments to metropolis_hastings_alpha and were internally defined as constants. * Added knitr as vignette engine Now both R.rsp and knitr are used as vignette builders. The former is used to add the BM paper in PDF format, the latter is hosting the SMC Rmarkdown vignette (yet a mockup). * Added mockup of SMC vignette * Updated .gitignore Update generated by `devtools::build_vignettes()`. * Updated build version * Translated new_item_rank to C++ (#113) * Replaced R new_item_rank with C++ version (#113) * Increment version number * Opening CI to all branches r.yml is currently configured for only triggering GitHub Actions CI workflow for the `master` and the `main` (inexistent here) branches. Opening it up to any branch so commits to `smc-mallows` also get triggered. This is important so we can better foresee problems in the upcoming merge with `master`. Opening up to any branch name shouldn't be a problem on this repository, since `master` is the only long-lived branch at the moment. * Syntax fixes * Refactoring * More specific seed setting * Fixing tests for Ubuntu Tests for Mac and Windows are still failing due to RNG. To be addressed later. * Investigate tests (#127) * Added prints statements to `arma::shuffle` * Added unique sort to `setdiff` * Updated tests Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> * Updates to smc_post_processing_functions.R (#119) * Updates to smc_post_processing_functions.R Hi, Just done a bit of tidying with the post_processing_functions. Here is a summary of my proposed changes: 1. edited `smc_processing` to allow the option to print the `col_names` of the original dataset if appropriate 2. edited `compute_consensus` to print the output correctly in the `MAP` case and to print the `colnames` of a dataset if appropriate instead of listing items as 'item 1, item 2, ... etc'. 3. edited `plot_posterior_intervals_rho` to print the `colnames` of a dataset if appropriate instead of listing items as 'item 1, item 2, ... etc'. 4. adjusted the font sizes of the axis labels in `plot_heatplot_rho` 5. removed the variable `verbose` from `plot_posterior_alpha` so that it now prints when calling the functions and doesn't do duplicate plots. 6. commented out any unused post-processing functions I have added some general comments, which begin with `#AS:` to explain why I have made the following changes (even though Github will highlight them). Let me know if you disagree or think any changes are unnecessary. I am planning on renaming the variables in the functions `heatMat` and `heatplot_fixed` so that they are consistent with the other heatplot functions, but I shall do this once this pull request has been completed/resolved(?). Waldir's changes: * Changed test unit expectations * Documentation fixes * Removed commented-out code * Replaced dplyr call with base R Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Updated smc.rmd Copy-pasted vignette script to github. Need to upload the matching .bib file containing the references. * create vignette.bib This file contains the references to be printed in the smc.Rmd file * Remove unused columns The final columns of rho_samples and alpha_samples do not get populated with non-zero values, so they are redundant. The same change applies to smc_mallows_new_item_rank_alpha_fixed, so this will appear as another pull request. * Remove unused column Extra column in rho_samples is redundant * Update compute_posterior_intervals_rho Reordered column in output to print item names in correct numerical order "item 1, item 2, ..., item 10" instead of "item 1, item 10, item 2, ..., item 9" * Cosmetic changes to heatplot functions Renamed variables to keep variable names consistent. Added some comments to explain the steps in the functions. * Updated test expectation Test units should be reset to expect one fewer columns, given the most recent code changes proposed. * Updated test expectations The previous changes on this branch reduce the number of columns by 1, so this must be reflected in the relevant unit test expectations. * Syntax fixes + doc update * Syntax fixes * Increment version number * Syntax adjustments * Changed test expectations back to what they should be See comment https://github.com/ocbe-uio/BayesMallows/issues/116#issuecomment-938583180 for more details. * Trying to reproduce Anja's seed and output * Increment version number * Added C++ version of smc_mallows_new_item_rank_alpha_fixed (#113) * Replaced R with C++ of smc_mallows_new_item_rank_alpha_fixed (#113) * Added C++ function of SMC new item alpha fixed (#113) * Added C++ version of smc_mallows_new_item_rank_alpha_fixed (#113) * Replaced R with C++ of smc_mallows_new_item_rank_alpha_fixed (#113) * Added C++ function of SMC new item alpha fixed (#113) * Added unit tests for #134 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> * Reduced test time * get_mallows_loglik now transposes as needed (#134) This eliminated the bug when passing rankings as a row vector and rho as a column vector (or vice-versa). Both still need to be matrices, though. * Increment version Increment version number to 1.0.3.9002 Increment version number to 1.0.3.9003 Increment version number to 1.0.3.9004 * Updated build version * Exported all functions from #117 - Exported `plot_rho_heatplot()` - Exported `plot_alpha_posterior()` - Exported `compute_posterior_intervals_alpha()` - Exported `compute_posterior_intervals_rho()` - Exported `compute_rho_consensus()` Also, some function names were renamed in comments and the SMC vignette text due to slight differences between their names there and the one on the code. The names on the code were preferred. Namely, the changes were: 1. `plot_heatplot_rho` into `plot_rho_heatplot` 2. `compute_consensus_rho` into `compute_rho_consensus` * Refactoring * Increment version number to 1.0.3.9006 * Added print argument to internal function * Updated test expectation, added comments * Added temporary print statements for debugging * Increment version number to 1.0.3.9007 * Added function plot_rho_posterior.R in smc_post_processing_functions.R (#137) * Added function plot_rho_posterior.R in smc_post_processing_functions.R * Synxtax fixes + whitespace removal * Exporting function with documentation Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Changing output of SMC function to new class Including change in test expectation. * Added generics, methods for compute_posterior_intervals * Changed classes of Mallows objects (#80) Generics and methods related to `compute_posterior_intervals()` had some class additions to allow for better dispatching between BayesMallows and SMC-Mallows methods. * Moved methods to same file (#80) Moved all methods of `compute_posterior_intervals()` and `.compute_posterior_intervals()` to the same file (easier to manage). * Syntax and documentation fixes/updates * Increment version number to 1.0.3.9006 * Updated TODOs * Update smc.Rmd Removed the heatplot function and replaced it with the plot rho posterior function. Some descriptions have changed to fit the description of the posterior function. * Remove heatplot functions Since we now have the `plot_rho_posterior` function to clearer visualisation, we can discontinue this function. * Deleted commented-out code * Updated docs * Removed unit test for dropped function * Increment version number to 1.0.3.9007 * Moved gtools from Suggests to Depends Also, standardized indentation. * Updated build version * added print statements to calculate_forward_probability.cpp Added lots of print statements to help with debugging * added print statements to calculate_backwards_probability.cpp added extra print statements for debugging * Fixed bug causing issue #116 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * Removed temporary code * Updated test expectations * Removed gtools dependency on SMC (#142) Removed dependency on gtools::mixedorder Works by extracting everything that isn't a digit ([0-9]) and ultimately using the index of the sorted elements to sort `rho_posterior_interval`. Works well for the standard "Item DD" format that SMC uses, and probably for other formats as well, but this wasn't extensively tested. * Replaced purrr::map with lapply on SMC (#142) * Replaced tidyr calls in SMC functions (#142) - Replaced tidyr::gather with stats::reshape - Replaced tidyr::spreadh with stats::reshape * Minor adjustments to SMC vignette Removed unused dependencies, Removed usage of , automatic whitespace adjustments. * Renamed SMC-Mallows vignette file So it matches the capitalization of "BayesMallows.pdf.asis" * Removed unneeded suggestions from DESCRIPTION * pedantic point * I suggest using a single file for references, to avoid duplication of data. * fixed some typos and tried to make the vignette code more consistent with the rest of the package, include <- for assignment * changed assignment operator in vignette * renamed all testfiles from test_ to test- * updated testthat version number in DESCRIPTION * ran styler on vignette * Created test which catches the warning in #159 * Fixed the warning, closes #159 * Mentions SMC in DESCRIPTION. * slight update in DESCRIPTION * updated news.md and incremented version number Co-authored-by: Anja Stein <anjastein@users.noreply.github.com> Co-authored-by: Anja Stein <anjastein@noreply.users.github.com> Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * corrected a bunch of typos and updated readme * corrected more typos with devtools::spellcheck() * accidentally deleted vignettes/BayesMallows.pdf in previous commit. fixed here * Convert MAP output to tibble (fixes #163) (#164) * Added test script for compute_rho_consensus (#163) * Minor test optimizations Restyling + shortening * Casting df as tibble (fixes #163) Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * Changed classes for compute_posterior_interval methods (#80) * Added tests to check BM and SMC classes (#80) * Implement generics to close #80 (#161) * Replaced Rcpp vector with arma vector (#90) * Removed TODO For the moment, smc_mallows_new_users_complete() will still use Rcpp::sample() to calculate the arma::uvec index. Replacement of Rcpp::sample() with arma::rand*() is encouraged, but left to any future developer aware of how to include probability weights on arma::rand*(). For more details, see conversation in issue #90. * Rearranged inline comments Top comment was relocated and rewritten on https://github.com/ocbe-uio/BayesMallows/issues/90#issuecomment-866614296 for better visibility and organization. Mid-code comment added for future reference. * Syntax fix * Reduced example length (closes #96) * Increment version number * Reduced unit test parameters (resolves #100) * Dropped usage of deprecated function (closes #99) * Added original scripts (#106) * Fitting scripts to package format (#106) * Added original scripts * Removed source calls, moved unit tests * Syntax fixes * Updated docs, exported new functions * Added placeholders for unit tests * Commented out failing tests These tests trigger errors on get_rank_distance(), to be investigated later (see issue #98 comments section for more details). * Increment version number * Increment version number * Syntax fix aug_prob is a vector, so we need to select just one element to perform those operations. * Fixed function name Function was using a deprecated, alternative name. * Fixed calls to get_mallows_loglik (#98, #109) * Reduced number of iterations on test * Restyled file * Fixes tests (#109) * Implemented tests (#98) * Edited test titles * Removed TODO * Improved SMC tests' speed (fixes #102) * Moved get_sample_probabilities() to src folder * Translated get_sample_probabilities + docs (#98) * Moved calculate_forward_probability to src folder * Exporting empty C++ function * Partial translation of calculate_forward_probability * Added get_sample_probabilities to smc.h * Finished translation of calculate_forward_probability Also: - Updated build version + Rcpp exports - Increment version number * Updated unit test expectations * Removed unnecessary library call * Translated calculate_backward_probability to C++ * Increment version number * Syntax fixes + refactoring * Changed file Unix permissions to match other files Used chmod to change the file permissions from 755 to 644 so it matches the rest of the files on the folder. * Added files for SMC-Mallows new item rank * Updated SMC partial rankings functions and tests * Restyled files * Syntax fixes * Commented out code to be worked on (#110) * Increment version number * Syntax fix * Formatted unit tests (#110) * Reduced test time (#110) Further test optimization Check fixes * Improvements to validation * Added SMC dataset * Improved partial ranking tests (#110) * Improved API feedback * Adapted test units for new item rank (#110) * Optimized unit tests (#110) * Minor fixes for clean check * Translated metropolis_hastings_aug_ranking_pseudo (#98) - Added skeleton of C++ metropolis_hastings_aug_ranking_pseudo - Translated metropolis_hastings_aug_ranking_pseudo - Replaced R version with C++ version - Fixed behavior of metropolis_hastings_aug_ranking_pseudo - Improved test format and updated expectations * Increment version number and R version dependency * Refactoring for easier debugging * Fixed RNG behavior on unit test * Removed superseded function * Added translation of metropolis_hastings_aug_ranking * Fixed documentation The docs for metropolis_hastings_aug_ranking_CPP() had text from the pseudo function. * Replaced R version of mh_aug_ranking with C++ (#98) Also, adjusted unit test expectations accordingly * Increment version number * Adjusted tests and renamed arguments (#98) * Added original code for correction_kernel C++ (#111) * Syntax fixes * Increment version number * Replaced R with C++ version of correction_kernel (#111) * Refactoring * Code optimization * Renamed cpp file * Added original code for correction_kernel_pseudo C++ (#111) * Syntax fixes * Replaced R with C++ of correction_kernel_pseudo (#111) * Increment version number * Replaced calculation of remaining_set * Translated smc_mallows_new_users_partial (#107) - Added C++ skeleton of smc_mallows_new_users_partial - Translated function * Set more seeds in unit tests This avoids random errors in unit testing. * Increment version number * Fixed calculation on smc_mallows_new_users_complete * Replaced R version with C++ version (#107) Of smc_mallows_new_users_partial(). * cal_fwd_prob() now works with both R and C++ indices * Refactoring * Adjusting unit tests * Returning test units to their original expectation * Updated Roxygen version * cal_bwd_prob() now works with both R and C++ indices This is basically a copy-paste from commit ce5d52cd. I smell a function coming... * Refactoring * Adjusting test expectations to new code output The differing output is caused by `set.seed(101)` having a different effect on the new C++ functions, particularly the output of `test_1_forward$aug_ranking`, which trickles down into the calculation of `test_1_backward_b`, thus causing different probabilities. The code was back-checked with the original R code, in which case the output seems the same. However, this should be checked with Anja. * Moved common code into function As "promised" on e497763640992f788c4ff0c98f6f127b99d4d785. * Translated partial ranks alpha fixed to C++ (#107) - Added skeleton of C++ alpha_fixed function - Finished translation - Switched R and C++ versions - Updated unit test expectations - Removed the R version of the function * Added parameters to SMC new users complete Added alpha_prob_sd, lambda and alpha_max, which were new arguments to metropolis_hastings_alpha and were internally defined as constants. * Added knitr as vignette engine Now both R.rsp and knitr are used as vignette builders. The former is used to add the BM paper in PDF format, the latter is hosting the SMC Rmarkdown vignette (yet a mockup). * Added mockup of SMC vignette * Updated .gitignore Update generated by `devtools::build_vignettes()`. * Updated build version * Translated new_item_rank to C++ (#113) * Replaced R new_item_rank with C++ version (#113) * Increment version number * Opening CI to all branches r.yml is currently configured for only triggering GitHub Actions CI workflow for the `master` and the `main` (inexistent here) branches. Opening it up to any branch so commits to `smc-mallows` also get triggered. This is important so we can better foresee problems in the upcoming merge with `master`. Opening up to any branch name shouldn't be a problem on this repository, since `master` is the only long-lived branch at the moment. * Syntax fixes * Refactoring * More specific seed setting * Fixing tests for Ubuntu Tests for Mac and Windows are still failing due to RNG. To be addressed later. * Investigate tests (#127) * Added prints statements to `arma::shuffle` * Added unique sort to `setdiff` * Updated tests Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> * Updates to smc_post_processing_functions.R (#119) * Updates to smc_post_processing_functions.R Hi, Just done a bit of tidying with the post_processing_functions. Here is a summary of my proposed changes: 1. edited `smc_processing` to allow the option to print the `col_names` of the original dataset if appropriate 2. edited `compute_consensus` to print the output correctly in the `MAP` case and to print the `colnames` of a dataset if appropriate instead of listing items as 'item 1, item 2, ... etc'. 3. edited `plot_posterior_intervals_rho` to print the `colnames` of a dataset if appropriate instead of listing items as 'item 1, item 2, ... etc'. 4. adjusted the font sizes of the axis labels in `plot_heatplot_rho` 5. removed the variable `verbose` from `plot_posterior_alpha` so that it now prints when calling the functions and doesn't do duplicate plots. 6. commented out any unused post-processing functions I have added some general comments, which begin with `#AS:` to explain why I have made the following changes (even though Github will highlight them). Let me know if you disagree or think any changes are unnecessary. I am planning on renaming the variables in the functions `heatMat` and `heatplot_fixed` so that they are consistent with the other heatplot functions, but I shall do this once this pull request has been completed/resolved(?). Waldir's changes: * Changed test unit expectations * Documentation fixes * Removed commented-out code * Replaced dplyr call with base R Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Updated smc.rmd Copy-pasted vignette script to github. Need to upload the matching .bib file containing the references. * create vignette.bib This file contains the references to be printed in the smc.Rmd file * Remove unused columns The final columns of rho_samples and alpha_samples do not get populated with non-zero values, so they are redundant. The same change applies to smc_mallows_new_item_rank_alpha_fixed, so this will appear as another pull request. * Remove unused column Extra column in rho_samples is redundant * Update compute_posterior_intervals_rho Reordered column in output to print item names in correct numerical order "item 1, item 2, ..., item 10" instead of "item 1, item 10, item 2, ..., item 9" * Cosmetic changes to heatplot functions Renamed variables to keep variable names consistent. Added some comments to explain the steps in the functions. * Updated test expectation Test units should be reset to expect one fewer columns, given the most recent code changes proposed. * Updated test expectations The previous changes on this branch reduce the number of columns by 1, so this must be reflected in the relevant unit test expectations. * Syntax fixes + doc update * Syntax fixes * Increment version number * Syntax adjustments * Changed test expectations back to what they should be See comment https://github.com/ocbe-uio/BayesMallows/issues/116#issuecomment-938583180 for more details. * Trying to reproduce Anja's seed and output * Increment version number * Added C++ version of smc_mallows_new_item_rank_alpha_fixed (#113) * Replaced R with C++ of smc_mallows_new_item_rank_alpha_fixed (#113) * Added C++ function of SMC new item alpha fixed (#113) * Added C++ version of smc_mallows_new_item_rank_alpha_fixed (#113) * Replaced R with C++ of smc_mallows_new_item_rank_alpha_fixed (#113) * Added C++ function of SMC new item alpha fixed (#113) * Added unit tests for #134 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> * Reduced test time * get_mallows_loglik now transposes as needed (#134) This eliminated the bug when passing rankings as a row vector and rho as a column vector (or vice-versa). Both still need to be matrices, though. * Increment version Increment version number to 1.0.3.9002 Increment version number to 1.0.3.9003 Increment version number to 1.0.3.9004 * Updated build version * Exported all functions from #117 - Exported `plot_rho_heatplot()` - Exported `plot_alpha_posterior()` - Exported `compute_posterior_intervals_alpha()` - Exported `compute_posterior_intervals_rho()` - Exported `compute_rho_consensus()` Also, some function names were renamed in comments and the SMC vignette text due to slight differences between their names there and the one on the code. The names on the code were preferred. Namely, the changes were: 1. `plot_heatplot_rho` into `plot_rho_heatplot` 2. `compute_consensus_rho` into `compute_rho_consensus` * Refactoring * Increment version number to 1.0.3.9006 * Added print argument to internal function * Updated test expectation, added comments * Added temporary print statements for debugging * Increment version number to 1.0.3.9007 * Added function plot_rho_posterior.R in smc_post_processing_functions.R (#137) * Added function plot_rho_posterior.R in smc_post_processing_functions.R * Synxtax fixes + whitespace removal * Exporting function with documentation Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Changing output of SMC function to new class Including change in test expectation. * Added generics, methods for compute_posterior_intervals * Changed classes of Mallows objects (#80) Generics and methods related to `compute_posterior_intervals()` had some class additions to allow for better dispatching between BayesMallows and SMC-Mallows methods. * Moved methods to same file (#80) Moved all methods of `compute_posterior_intervals()` and `.compute_posterior_intervals()` to the same file (easier to manage). * Syntax and documentation fixes/updates * Increment version number to 1.0.3.9006 * Updated TODOs * Update smc.Rmd Removed the heatplot function and replaced it with the plot rho posterior function. Some descriptions have changed to fit the description of the posterior function. * Remove heatplot functions Since we now have the `plot_rho_posterior` function to clearer visualisation, we can discontinue this function. * Deleted commented-out code * Updated docs * Removed unit test for dropped function * Increment version number to 1.0.3.9007 * Moved gtools from Suggests to Depends Also, standardized indentation. * Updated build version * added print statements to calculate_forward_probability.cpp Added lots of print statements to help with debugging * added print statements to calculate_backwards_probability.cpp added extra print statements for debugging * Fixed bug causing issue #116 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * Removed temporary code * Updated test expectations * Removed gtools dependency on SMC (#142) Removed dependency on gtools::mixedorder Works by extracting everything that isn't a digit ([0-9]) and ultimately using the index of the sorted elements to sort `rho_posterior_interval`. Works well for the standard "Item DD" format that SMC uses, and probably for other formats as well, but this wasn't extensively tested. * Replaced purrr::map with lapply on SMC (#142) * Replaced tidyr calls in SMC functions (#142) - Replaced tidyr::gather with stats::reshape - Replaced tidyr::spreadh with stats::reshape * Minor adjustments to SMC vignette Removed unused dependencies, Removed usage of , automatic whitespace adjustments. * Renamed SMC-Mallows vignette file So it matches the capitalization of "BayesMallows.pdf.asis" * Removed unneeded suggestions from DESCRIPTION * Created generic for compute_consensus * Generalized compute_consensus subfunctions (#80) Tests started failing due to different output structure from the previous expectation. To be investigated. * Fixed leftover merge conflict from develop * Increment version number to 1.0.4.9002 * Dropped usage of dplyr::do * Updated docs * Increment version number to 1.0.4.9003 * Reindented test code to aid debugging * Removed duplicated unit tests with wrong name Apparently git didn't pickup on the renaming of "test_" to "test-" * (Re)deleted redundant bib file All vignettes point to a common inst/REFERENCES.bib, no need for a new file. * sorted the consensus output * Renamed class of compute_consensus.BayesMallows output (#80) * Renamed test file Since it contains tests for both `compute_consensus()` and `compute_posterior_intervals()`. * Added class tests for compute_rho_consensus (#80) * Introducing consensus_SMCMallows class (#80) * Moved compute_consensus methods together (#80) * Updated docs * Removed finished TODOs from code Co-authored-by: Anja Stein <anjastein@users.noreply.github.com> Co-authored-by: Anja Stein <anjastein@noreply.users.github.com> Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * incremented version number and updated CRAN note * corrected spelling error in smc vignette * recompiled documentation after resolving conflicts with master branch * recompiled readme and update some citations * Added linter CI workflow * Using <- for assignment * Removed commented out code * Improved spacing around commas and operators * Replaced tab with space for indentation * Fixed spacing before curly brace * Replaced single quotes with double * Adjusting space before left parenthesis * Replaced F with FALSE * Removed superfluous trailing blank lines * Removed unnecessary concatenation Co-authored-by: Øystein Sørensen <oystein@ysteins-mbp.lan> Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> Co-authored-by: Anja Stein <anjastein@users.noreply.github.com> Co-authored-by: Anja Stein <anjastein@noreply.users.github.com> Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> * fixed #168 and added unit test * issue 112 smc memory (#169) * Improved variable declaration on maybe_offset_indices() (#112) * Improved variable declaration on calculate_backward_probability() (#112) * Replaced redundancies with two functions (#112) (#170) New C++ functions: - `arma_setdiff_vec()` - `Rcpp_setdiff_arma()` Both are slight variations of `arma_setdiff()` using different-classed objects. Code could be further optimized by merging the new functions into arma_setdiff(). Good luck dealing with all the vec-uvec conversions, though. * Declared constants and references (#112) (#172) * Removed trailing blank line [Linter](https://github.com/ocbe-uio/BayesMallows/pull/170/files) was complaining. * Declaring constants and references on SMC (#112) * Replaced SMC code with functions (#112, #114) (#173) This was primarily done as a stepping stone to replacing some Armadillo/Rcpp back-and-forth (see issue #112). Removing duplicated code makes it easier to replace Rcpp crutches later. The newly-created functions were also simplified as much as I could to get #112 solved. * Fix boolean operands (#175) * Increment version number to 1.1.0.9001 * Fixed boolean operands This should solve the eventual warnings for using bitwise `|` or `&` with boolean operands. * Fix oldrel errors (#176) * Increment version number to 1.1.0.9001 * Fixed boolean operands This should solve the eventual warnings for using bitwise `|` or `&` with boolean operands. * Refactored reshaping on smc_processing() #174 There seems to be a problem with setting `idvar` to `NULL` in R-oldrel, possibly due to some change on the `stats::reshape()` function. This change intends to fix it without changing the output. * Excluding RcppExports.R from linter This file is generated automatically and it keeps triggering a warning on GitHub Actions about it containing a superfluous trailing blank line. * Increment version number to 1.1.0.9002 * Addressing #181 (#182) * Issue 184 cpp (#187) * fixed return type of sample_one_with_prob #184 * updated news * Clean up headers (#196) * removed unnecessary include from distances.h * removed unnecessary statements from missing_data.h * a lot of DRY-ing of header files * corrected typo in function name * removed include for algorithm as it is already included by RcppCommon.h * deleted some more unnecessary includes * incremented to development version * updated news * Update smc_mallows_new_users_complete.cpp (#189) * Update smc_mallows_new_users_complete.cpp Include a vector named ESS_vec (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. * Update smc_mallows_new_users_complete.cpp * Update smc_mallows_new_users_complete.cpp * Update smc_mallows_new_users_complete.cpp * Fixed calculation of ESS_vec elements `^` is not a valid Armadillo operator (see list [here](http://arma.sourceforge.net/docs.html#operators)). The usual way to square a matrix is to multiply it by its transpose, so that's what I proposed here. The operation was also separated from the sum so arma would stop complaining (maybe this could be a one-liner again by using `conv_to()`, but I didn't wanna do that. * Fixup for 06d7c87 Previous commit was syntatically OK, but issues arised when running tests. This fixes it * Adjusted unit tests to ESS addition * Update smc_mallows_new_users_complete.cpp Changed the calculation for ESS - I was using the incorrect formula. * Added unit test for ESS Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Replaced all arma::*word (#202) * Replaced all arma::*word (#199) * Increment version number to 1.1.2.9001 * Reverted changes from ba7c5527f on misc.h Using `using namespace` in header files should be avoided, as their effect trickle down to any other file using them. * Removal of arma:: qualifier from functions (#205) * replaced arma::*class* in mixtures.cpp * removed arma:: in distances.cpp * replaced arma:: in importance_sampling.cpp * leapandshift * removed more arma:: in misc.cpp * removed arma::*class* in missing_data.cpp * removing arma:: in pairwise_comparisons.cpp * removing arma:: in parameterupdates.cpp * removing arma:: in partitionfuns.cpp * removing arma:: in rmallows.cpp * removing arma:: in run_mcmc.cpp * removed arma::*class* from smc functions * replaced arma::ones with ones * replaced arma::zeros and arma::rand* with zeros and rand* * replaced arma::fill* with fill* * replaced arma::span with span * replaced arma::exp with exp * replaced arma::log with log * replaced arma::accu with accu * replaced arma::conv_to with conv_to * replaced arma::max and arma::min with max and min * replaced arma::sum with sum * replaced arma::normalise with normalise * replaced arma::find with find * replaced arma::regspace and arma::linspace with regspace and linspace * replaced arma::shuffle with shuffle * replaced arma::as_scalar with as_scalar * removed arma:: from various not-so-frequently-used functions * removal of arma:: qualifier from more functions * Revert "Removal of arma:: qualifier from functions (#205)" (#206) This reverts commit 3ec2432e218b8f35dccdbe55197229573c97241a. * More work towards #199 (#203) * replaced arma::*class* in mixtures.cpp * removed arma:: in distances.cpp * replaced arma:: in importance_sampling.cpp * leapandshift * removed more arma:: in misc.cpp * removed arma::*class* in missing_data.cpp * removing arma:: in pairwise_comparisons.cpp * removing arma:: in parameterupdates.cpp * removing arma:: in partitionfuns.cpp * removing arma:: in rmallows.cpp * removing arma:: in run_mcmc.cpp * removed arma::*class* from smc functions * Issue 200 (#204) * replaced arma::*class* in mixtures.cpp * removed arma:: in distances.cpp * replaced arma:: in importance_sampling.cpp * leapandshift * removed more arma:: in misc.cpp * removed arma::*class* in missing_data.cpp * removing arma:: in pairwise_comparisons.cpp * removing arma:: in parameterupdates.cpp * removing arma:: in partitionfuns.cpp * removing arma:: in rmallows.cpp * removing arma:: in run_mcmc.cpp * removed arma::*class* from smc functions * replaced arma::ones with ones * replaced arma::zeros and arma::rand* with zeros and rand* * replaced arma::fill* with fill* * replaced arma::span with span * Issue 201 (#207) * replaced arma::*class* in mixtures.cpp * removed arma:: in distances.cpp * replaced arma:: in importance_sampling.cpp * leapandshift * removed more arma:: in misc.cpp * removed arma::*class* in missing_data.cpp * removing arma:: in pairwise_comparisons.cpp * removing arma:: in parameterupdates.cpp * removing arma:: in partitionfuns.cpp * removing arma:: in rmallows.cpp * removing arma:: in run_mcmc.cpp * removed arma::*class* from smc functions * replaced arma::ones with ones * replaced arma::zeros and arma::rand* with zeros and rand* * replaced arma::fill* with fill* * replaced arma::span with span * replaced arma::exp with exp * replaced arma::log with log * replaced arma::accu with accu * replaced arma::conv_to with conv_to * replaced arma::max and arma::min with max and min * replaced arma::sum with sum * replaced arma::normalise with normalise * replaced arma::find with find * replaced arma::regspace and arma::linspace with regspace and linspace * replaced arma::shuffle with shuffle * replaced arma::as_scalar with as_scalar * removed arma:: from various not-so-frequently-used functions * removal of arma:: qualifier from more functions * added pdf(NULL) (#208) * Update smc_mallows_new_users_partial_alpha_fixed.cpp (#191) * Update smc_mallows_new_users_partial_alpha_fixed.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_users_partial_alpha_fixed.cpp * Syntax fix, updated test expectations * Update smc_mallows_new_users_partial_alpha_fixed.cpp Updated L28 to explain the output. Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Update smc_mallows_new_users_partial.cpp (#190) * Update smc_mallows_new_users_partial.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_users_partial.cpp * Syntax fix * Adjusted unit test expectations * Update smc_mallows_new_users_partial.cpp Updated L34 to explain the output. * Update smc_mallows_new_users_partial.cpp Updated L34 Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Issue 162 (#211) * replaced two dplyr::filter with [ * replaced some more dplyr::filter * replaced more dplyr * replaced more dplyr::filter * replaced dplyr::filter in plot.BayesMallows * replaced more dplyr::filter * replaced more dplyr::filter * replaced more dplyr::filter * replaced the easy dplyr::filter in compute_consensus.R * replaced more easy dplyr::filters * fixed a line to avoid soft-deprecated dplyr syntax * more complicated un-dplyr-ing in assign_cluster.R * some reordering of test output * simplified a group-by * removed dplyr from map cluster * eliminated dplyr from assign_cluster.R * removed dplyr::mutate a few more places * removed a dplyr::mutate in assess_convergence.R * removed another dplyr::mutate * un-dplyred assess_convergence.R * replaced a dplyr::if_else * replaced some dplyr::select * replaced another mutate * replaced a dplyr::semi_join with base::merge in generate_transitive_closure.R * replaced more dplyr with base * replaced two dplyr::filter with [ * replaced some more dplyr::filter * replaced more dplyr * replaced more dplyr::filter * replaced dplyr::filter in plot.BayesMallows * replaced more dplyr::filter * replaced more dplyr::filter * replaced more dplyr::filter * replaced the easy dplyr::filter in compute_consensus.R * replaced more easy dplyr::filters * fixed a line to avoid soft-deprecated dplyr syntax * more complicated un-dplyr-ing in assign_cluster.R * some reordering of test output * simplified a group-by * removed dplyr from map cluster * eliminated dplyr from assign_cluster.R * removed dplyr::mutate a few more places * removed a dplyr::mutate in assess_convergence.R * removed another dplyr::mutate * un-dplyred assess_convergence.R * if_else to ifelse * replaced some dplyr::select * replaced another mutate * replaced a dplyr::semi_join with base::merge in generate_transitive_closure.R * replaced more dplyr with base * more dplyr replacements * incorporating some updates * some more replacements * replacement in compute_consensus.R * more replacements of dplyr * fixed small issue * replaced a select * changed return values to dataframes * more changes from tibble to data.frame * fixed tests due to sorting * replaced dplyr in estimate_partition_function * simplified naming of columns * replaced dplyr in plot.BayesMallows.R * small change in assign_cluster.R * replaced a dplyr in plot_top_k.R * discovered a code duplication which could easily be fixed * removed a lot of dplyr in compute_consensus.R * updated classes in tests and return values * base function for finding unique values * replaced group and count with aggregate * DRY-ing #114 and base-r-ification * the two find_cpc functions were identical, so I merged them * replaced a group-count with an aggregate * replaced a dplyr in map consensus * DRYing #114 and conversion to base R * all dplyr in compute_consensus.R replaced by base * enormous DRY-ing * replaced more dplyr with base * all tests passing * removed dplyr in example and added import * fixed misspelled import * styling assign_cluster * styling compute_consensus.R * styling compute_posterior_intervals * more styling * increased test coverage of expected_dist * styling of test files * DRY-ing while fixing a false negative in codecov * added more complete tests for consensus with SMC * Addressed "unneded concatenation of a constant" linting * Added change notice on predict_top_k * Added change notice to predict_top_k * improved the message * incremented development version * Adding space between parentheses Should solve linting warnings from 5b64da93. Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Added CodeFactor badge (#213) * Added CodeFactor badge * Moved changes to Rmd file, rebuilt md README.md was rebuilt using `devtools::build_readme()`, which triggered some past changes which should be double-checked. * compiled README.Rmd locally by pressing the knit button Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> * Issue 214 (#215) * created test that catches #214 * updated test so it does not produce pdf file * solve #214 * updated news * Issue 212 (#216) * Started replacing dplyr in test files * removed another dplyr * removed dplyr from test-compute_mallows.R * replaced dplyr in test-compute_consensus.R * replaced dplyr in test-plot_top_k.R * all dplyr dependencies in tests removed * removed dplyr from obs_freq_example * removed dplyr from compute_consensus_example * removed dplyr from plot_top_k_example * added plot_top_k example to predict_top_k * removed dplyr from estimate_partition_function_example * removed more dplyr from examples * replaced dplyr in generate_transitive_closure_example.R * removed dplyr from compute_mallows_example.R * removed two unnecessary library() statements in SMC-Mallows vignette * converted partition function data from tibble to data.frame * simplified script for generating beach data * updated documentation * removed dplyr from DESCRIPTION * updated NEWS.md * updated development version * ran styler on R/ * Followed the advice of CodeFactor, replacing mapply with Map * fixed some forgotten dplyr code which did not cause error due to 'dontrun' * Removed comment referring to #91 * replacing sink() with capture.output() * Dry (#217) * DRY-ed log_lik_db function * added internal documentation * styling * formatted documentation * Update smc_mallows_new_item_rank.cpp (#192) * Update smc_mallows_new_item_rank.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_item_rank.cpp * Fixed syntax, added FIXME * Update smc_mallows_new_item_rank.cpp Updated L33 * Update smc_mallows_new_item_rank.cpp Corrected lines involving `ESS_vec`. * Updated @return documentation * Changed initialization of `ESS_vec` It is now declared later in the code so its initial values can be calculated first. * Updated unit test expectations * Updated Rd docs * Updated docs * Updated initialization of ESS_vec Following https://github.com/ocbe-uio/BayesMallows/commit/156ae3727b20690a25ccb320657659db78e368dd#r72662511 and https://github.com/ocbe-uio/BayesMallows/pull/192#discussion_r862766447, `ESS_vec` starts with `ess_init` on index 0 and zero on indices {1, ..., Time - 1}. Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Dry (#218) * used existing function for computing distance * updated documentation * fixing CodeFactor issue * increasing test coverage * simplified code in lik_db_mix (#220) * simplified code in lik_db_mix * fixed some duplication on my side * fixed error causing tests to fail * renamed get_mallows_loglik (#221) * renamed get_mallows_loglik * fixed CodeFactor issues * using boost factorial function instead * simplified factorials * deleted unnecesary headers * added header * added a comment and replaced math.h with cmath * Binomial coefficient (#222) * DRY logz_cardinalities * DRY log_expected_dist * replaced code duplication with a function * realized we can use binomial coefficient from Rmath.h * got rid of an unnecessary statement in mixtures.cpp * Vec seq (#223) * DRY logz_cardinalities * DRY log_expected_dist * replaced code duplication with a function * realized we can use binomial coefficient from Rmath.h * got rid of an unnecessary statement in mixtures.cpp * replaced arma_vec_seq with regspace * Setdiff (#225) * DRY logz_cardinalities * DRY log_expected_dist * replaced code duplication with a function * realized we can use binomial coefficient from Rmath.h * got rid of an unnecessary statement in mixtures.cpp * replaced arma_vec_seq with regspace * got rid of one of the may setdiff functions * created a single setdiff function (#226) * created a single setdiff function * changed setdiff.hpp to setdiff.h * some cleaning of header files (#230) * replaced Rcpp::sample with arma::shuffle, #227 (#228) * replaced Rcpp::sample with arma::shuffle, #227 * replaced formatting of include * created sampling function, let's see if it passes the tests * removed require() from test * got rid of sample_int * got rid of sample_one_with_prob * got rid of permute_with_weights * added two more tests to understand platform dependency * replaced one new_pseudo_proposal * got rid of new_pseudo_proposal. tests succeeding locally * replaced more shuffle(). * updated unit tests * removed library statement * made setdiff function call by reference * replaced .size() with .n_elem for arma objects * removed some empty lines * turned back a shuffle * another shuffle * checking no windows * updated tests * another update * updated tests * should not test ESS due to bug * updated test * testing on windows * replaced a shuffle with a randperm * replaced unnecessary headers * updated dev version and wrote a line in NEWS.md * renamed a file * Rename loglik (#231) * renamed lik_db_mix to get_mallows_loglik and deprecated it * fixed deprecation notice * Dry smc (#232) * DRY-ed augmentation of ranks for new users * DRY-ed the reweighting for smc_new_users * DRY-ed new_users_complete as well * First DRY-ing of smc_mallows_new_users * had forgot an & * reduced the number of arguments * reorganized code and solved #219 * made an initializer for alpha_samples * refactored a little bit more * Small code modifications (#234) * some small simplification * Update smc_leap_and_shift_probs.cpp Using default argument * put forward and backward probability into a single function (#235) * some small changes (#236) * some improvements of the all_topological_sorts function (#237) * some improvements of the all_topological_sorts function * fixed CodeFactor issue * create a single function for smc_mallows_new_users* (#238) * create a single function for smc_mallows_new_users* * some DRY-ing * fixed documentation issue causing tests to fail * Leap and shift (#240) * cleaning of leap-and-shift code * moved SMC shift step for easier comparison with the other leap and shift function * removed static_cast in leap-and-shift * simplified by using regspace * more code cleaning * deleted whitespace * Ls issue 239 (#241) * cleaning of leap-and-shift code * moved SMC shift step for easier comparison with the other leap and shift function * removed static_cast in leap-and-shift * simplified by using regspace * more code cleaning * deleted whitespace * fixed leap-and-shift bug in #239 * updated NEWS.md and version number * Update smc_mallows_new_item_rank_alpha_fixed.cpp (#193) * Update smc_mallows_new_item_rank_alpha_fixed.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_item_rank_alpha_fixed.cpp * Update smc_mallows_new_item_rank_alpha_fixed.cpp Include a vector named `ESS_vec` (a vector of length Time) which contains the Effective Sample Size of the particles in each iteration. Return the `aug_rankings` at end of SMC algorithm. * Update smc_mallows_new_item_rank_alpha_fixed.cpp * Syntax fix * Removed duplicated code * Update smc_mallows_new_item_rank_alpha_fixed.cpp Updated L39 to explain the output. * Update smc_mallows_new_item_rank_alpha_fixed.cpp Updated lines involving `ESS_vec` * Update test-smc_mallows_new_item_rank.R Updated test script for smc_mallows_new_item_rank_alpha_fixed Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> * Testing of C++ functions (#242) * added framework for unit testing of C++ functions and wrote unit test for leapandshift.cpp * fixed CodeFactor issue * another attempt at making CodeFactor happy * SMC now uses the same leap-and-shift function as BayesMallows. Turned the SMC function into a thin wrapper for now. * made leap_and_shift_probs internal * updated readme * Small vignette edits * Dry new item (#243) * DRY-ed initialize_rho function * made common initialize_rho function and updated tests for BayesMallows * refactored initialize_alpha * merged new_item_rank functions * deprecated smc_mallows_new_item_rank_alpha_fixed * extracted a function for the move step * some refactoring * fixed CodeFactor issue! * Updated NEWS.md and incremented development version * made aug_ranking function call by reference * Added tests with explicit expections of numeric output for new_item_rank to make sure #243 is safe * tests passing on mac * fixed CodeFactor issue * another DRY-ing * added a function for normalizing weights * Incremented version and updated news and cran-comments #249 * Updated NEWS.md and cran-comments.md * Update smc_mallows_new_users.cpp (#251) * Update smc_mallows_new_users.cpp - added loop for `partial` and `partial fixed` case to lines 191 and - adjusted loop start and endpoints lines 209 and 220 * updated tests * tiny style update * Updated NEWS.md * Changed divide_by_fact to make it more readable Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> * updated news and incremented development version * Fixed CI linter (#253) * Updated linter YAML * Auto-updated docs * Fix @title for sample_dataset (#256) * Improved title of `sample_dataset` * Increment version to 1.2.0.9001, updated NEWS * Updating new rank functions (#252) * Added original script (#198) From @anjastein > The script called `updated_rankings_functions_for_waldir.R` contains the new functions that would benefit from being translated from R to C++. A lot of the code suffers from DRY (two very similar functions but in one of them the variable alpha is fixed) and probably uses a lot of code that you have created in the BayesMallows SMC extension of the CRAN package already, so I hope it won't be time-consuming. * Roxygenized docs, split unit tests (#198) * Commented out temporarily-broken tests (#198) * Removed explicit calls to the function (#198) * Replaced `abort()` calls with `stop()` (#198) * Updated renamed functions See commit 375a6f6f0aeefb9b019bc11eec3d3a28528485e5 for details. * Updated proposed code to the 1.2.0 API * Restyled file * Added TODOs * Minor doc fix (#198) * Adding `smc_mallows_new_item_rank_updated_cpp()` (#198) * Adding default value to `alpha_samples_init` The alpha-fixed variant does not use it. * Wrapping unit tests around `test_that()` (#198) * Updated build version * Added TODO * Improved variable declaration * Updated docs and Rcpp exports * Increment version number to 1.2.0.9002 * Syntax fixes (#198) * Updated unit tests to use C++ version (#198) * Improved handling of alpha_fixed without alpha_samples_init (#198) * Updated docs, RoxygenNote version * Replaced original R functions with C++ (#198) * Merged identical functions (#198) * Replaced `smc_mallows_new_item_rank()` (#198) Subfunction was also moved away from _back_ into , since it's not being used anywhere else * Updated deprecated smc_mallows_new_rank funcs Rerouting to new function deleted because the arguments mismatch. squash! fixup! Updated deprecated smc_mallows_new_rank funcs * Added default to `rho_samples_init` (#198) Defaults to NULL, in which case `initialize_rho()` is called, as per the previous implementation. squash! Added default to `rho_samples_init` (#198) * Adapted unit tests accordingly to #198 updates * Removed warning when `alpha_samples_init` is not provided (#198) This restores the behavior from the previous version, which is to _silently_ generate alpha_samples. Since the warning introduced on commit f2bd74c4ce7b97fca5d6a3871f3c0ea4332fbde1 was removed, the test unit introduced there makes no sense anymore, so it was removed. * Added function to augment rankings (#198) Copy-pasted from previous version of `smc_mallows_new_item_rank()`. * Augment ranking if empty aug_rankings_init (#198) * Added error expectation to unit tests * Fixed warnings caused by comparison between int and uword * Fixed test unit syntax The removed bit was depending on `smc_test_new_user_unif`, an object which has not been created at that point. This issue was present in the original script. Also, the error message is now explicitly mentioned to match the purpose of this particular test unit. * Added TODO * Simplified syntax (#198) * Moved test further down the script To a place where all inputs are already defined. * Allowing `aug_rankings_init` to be nullable * Adapted test expectations * Code style adjustments * Drastically reduced test execution time (#198) Test script modified to reduce code footprint and execution time. Test on local machine showed a reduction from 144 s to 0.3 s to run the affected script. * Replacing casting function with one-liner (#198) Source: https://github.com/ocbe-uio/BayesMallows/pull/252#discussion_r978953965 * Replacing arma for Rcpp on function argument (#198) Source: https://github.com/ocbe-uio/BayesMallows/pull/252#discussion_r978955092 Co-authored-by: Anja Stein <a.stein1@lancaster.ac.uk> Co-authored-by: Øystein Sørensen <oystein_sorensen@hotmail.com> * codefactor issue * CodeFactor issue * CodeFactor issues * Adding data-raw to directories lintr should ignore * Added main testthat file to linter-ignore * Minor code style adjustments Addressed redundant blank lines accused by CodeFactor to clear up the number of issues raised by the system. We're not far from an A+ rating! :) * Updated testthat.R * Updated NEWS.md * Changing to forward slash in codecov.yml * Revert "Changing to forward slash in codecov.yml" This reverts commit c8cda93db3ab2496c1835ca78c12a6b6195674f6. * Changing to forward slash in codecov.yml * Added example to linter-ignore Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Øystein Sørensen <oystein@ysteins-mbp.lan> Co-authored-by: Anja Stein <anjastein@users.noreply.github.com> Co-authored-by: Anja Stein <anjastein@noreply.users.github.com> Co-authored-by: Øystein Sørensen <oyss@medisin.uio.no> Co-authored-by: Anja Stein <anja.stein@peak.ai> Co-authored-by: Anja Stein <anja.stein@btopenworld.com> Co-authored-by: Anja Stein <a.stein1@lancaster.ac.uk> * Got rid of PerMallows in unit tests by hard-coding expected return values * Got rid of another PerMallows dependency by hard-coding expected values in unit tests * Added comment * Removed part of example using PerMallows. Its only purpose was to demonstrate that our algorithm is correct * Removed PerMallows from Imports Co-authored-by: Waldir Leoncio <w.l.netto@medisin.uio.no> Co-authored-by: Øystein Sørensen <oystein@ysteins-mbp.lan> Co-authored-by: Anja Stein <anjas…
Hi both,
The functions with names beginning with
smc_mallows_new_item_rank_*
would benefit from using output fromsmc_mallows_new_users_*
to be the initial sample ofrho
andalpha
in the system. I have the proposed code written in R which could benefit from being translated into C++. @wleoncio, would you be interested in this? The code still suffers from DRY issues, but it does mean the translation should not be time-consuming.... What do you think?The text was updated successfully, but these errors were encountered: