Skip to content

Commit 996e2ef

Browse files
Copilotosorensen
andcommitted
Render README.md with example, plots, and references
Co-authored-by: osorensen <21175639+osorensen@users.noreply.github.com>
1 parent e32e48f commit 996e2ef

File tree

5 files changed

+72
-6
lines changed

5 files changed

+72
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
.Ruserdata
55
parameter_trace
66
*.Rcheck
7-
*.tar.gz
7+
*.tar.gz
8+
README.html

README.md

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
<!-- badges: end -->
1010

1111
BayesMallowsSMC2 provides functions for performing sequential inference
12-
in the Bayesian Mallows model using the SMC2 algorithm.
12+
in the Bayesian Mallows model using the SMC2 algorithm (Sørensen et al.
13+
2025).
1314

1415
## Installation
1516

@@ -21,8 +22,72 @@ You can install the development version of BayesMallowsSMC2 from
2122
devtools::install_github("osorensen/BayesMallowsSMC2")
2223
```
2324

24-
## Usage
25+
## Example
2526

26-
This package is under development, and is not yet well documented. For
27-
examples on how to use it, see the code in the OSF repository
28-
<https://osf.io/pquk4/>.
27+
Here is a basic example using the included `complete_rankings` dataset:
28+
29+
``` r
30+
library(BayesMallowsSMC2)
31+
32+
# Fit the model with complete rankings
33+
set.seed(123)
34+
mod <- compute_sequentially(
35+
complete_rankings,
36+
hyperparameters = set_hyperparameters(n_items = 5),
37+
smc_options = set_smc_options(n_particles = 100, n_particle_filters = 1)
38+
)
39+
40+
# Print model summary
41+
print(mod)
42+
#> BayesMallowsSMC2 Model
43+
#> ======================
44+
#>
45+
#> Number of particles: 100
46+
#> Number of timepoints: 100
47+
#> Number of items: 5
48+
#> Number of clusters: 1
49+
#>
50+
#> Log marginal likelihood: -472.34
51+
#> Final ESS: 63.55
52+
#> Resampling events: 5/100
53+
```
54+
55+
### Posterior Summaries
56+
57+
We can visualize the posterior distributions of the parameters:
58+
59+
``` r
60+
# Posterior distribution of alpha (dispersion parameter)
61+
plot(mod, parameter = "alpha")
62+
```
63+
64+
<img src="man/figures/README-posterior-alpha-1.png" width="100%" />
65+
66+
``` r
67+
# Posterior distribution of tau (precision parameter)
68+
plot(mod, parameter = "tau")
69+
```
70+
71+
<img src="man/figures/README-posterior-tau-1.png" width="100%" />
72+
73+
``` r
74+
# Posterior distribution of rho (ranking positions)
75+
plot(mod, parameter = "rho", items = c(1, 2, 3))
76+
```
77+
78+
<img src="man/figures/README-posterior-rho-1.png" width="100%" />
79+
80+
## References
81+
82+
<div id="refs" class="references csl-bib-body hanging-indent">
83+
84+
<div id="ref-10.1214/25-BA1564" class="csl-entry">
85+
86+
Sørensen, Øystein, Anja Stein, Waldir Leoncio Netto, and David S.
87+
Leslie. 2025. “<span class="nocase">Sequential Rank and Preference
88+
Learning with the Bayesian Mallows Model</span>.” *Bayesian Analysis*,
89+
1–26. <https://doi.org/10.1214/25-BA1564>.
90+
91+
</div>
92+
93+
</div>
9.3 KB
Loading
14.2 KB
Loading
9.71 KB
Loading

0 commit comments

Comments
 (0)