PlackettLuce
PlackettLuce package for Plackett-Luce models in R
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
2 of 4 committers (50.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.6%) to scientific vocabulary
Keywords
plackett-luce-models
preferences
r
ranking
rankings-data
statistical-models
Last synced: 6 months ago
·
JSON representation
Repository
PlackettLuce package for Plackett-Luce models in R
Basic Info
- Host: GitHub
- Owner: hturner
- Language: HTML
- Default Branch: main
- Homepage: https://hturner.github.io/PlackettLuce/
- Size: 17.2 MB
Statistics
- Stars: 21
- Watchers: 5
- Forks: 5
- Open Issues: 6
- Releases: 11
Topics
plackett-luce-models
preferences
r
ranking
rankings-data
statistical-models
Created almost 9 years ago
· Last pushed over 2 years ago
Metadata Files
Readme
README.Rmd
---
output: github_document
bibliography: ["readme.bib"]
---
```{r rmd-setup, include = FALSE}
knitr::opts_chunk$set(fig.path = "man/figures/")
```
# PlackettLuce
[](https://cran.r-project.org/package=PlackettLuce)
[](https://github.com/hturner/PlackettLuce/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/hturner/PlackettLuce?branch=main)
Package website: https://hturner.github.io/PlackettLuce/.
## Overview
The **PlackettLuce** package implements a generalization of the model jointly
attributed to @Plackett1975 and @Luce1959 for modelling rankings data.
Examples of rankings data might be the finishing order of competitors in a race,
or the preference of consumers over a set of competing products.
The output of the model is an estimated **worth** for each item that appears in
the rankings. The parameters are generally presented on the log scale for
inference.
The implementation of the Plackett-Luce model in **PlackettLuce**:
- Accommodates ties (of any order) in the rankings, e.g.
bananas $\succ$ {apples, oranges} $\succ$ pears.
- Accommodates sub-rankings, e.g. pears $\succ$ apples, when the full set of items is {apples, bananas, oranges, pears}.
- Handles disconnected or weakly connected networks implied by the rankings, e.g. where one item always loses as in figure below. This is achieved by adding pseudo-rankings with a
hypothetical or ghost item.
```{r always-loses, message = FALSE, echo = FALSE, fig.width = 3.5, fig.height = 3.5}
library(PlackettLuce)
library(igraph)
R <- matrix(c(1, 2, 0, 0,
2, 0, 1, 0,
1, 0, 0, 2,
2, 1, 0, 0,
0, 1, 2, 0), byrow = TRUE, ncol = 4,
dimnames = list(NULL, LETTERS[1:4]))
R <- as.rankings(R)
A <- adjacency(R)
net <- graph_from_adjacency_matrix(A)
plot(net, edge.arrow.size = 0.5, vertex.size = 30)
```
In addition the package provides methods for
- Obtaining quasi-standard errors, that don't depend on the constraints applied
to the worth parameters for identifiability.
- Fitting Plackett-Luce trees, i.e. a tree that partitions the rankings by
covariate values, such as consumer attributes or racing conditions, identifying
subgroups with different sets of worth parameters for the items.
## Installation
The package may be installed from CRAN via
```{r, eval = FALSE}
install.packages("PlackettLuce")
```
The development version can be installed via
```{r, eval = FALSE}
# install.packages("devtools")
devtools::install_github("hturner/PlackettLuce")
```
## Usage
The [Netflix Prize](https://en.wikipedia.org/wiki/Netflix_Prize) was a competition devised by
Netflix to improve the accuracy of its recommendation system. To facilitate
this they released ratings about movies from the users of the system that have
been transformed to preference data and are available from
[PrefLib](https://www.preflib.org/dataset/00004), [@Bennett2007]. Each data set
comprises rankings of a set of 3 or 4 movies selected at random. Here we
consider rankings for just one set of movies to illustrate the functionality of
**PlackettLuce**.
The data can be read in using the `read.soc` function in **PlackettLuce**
```{r}
library(PlackettLuce)
preflib <- "https://raw.githubusercontent.com/PrefLib/PrefLib-Data/main/datasets"
netflix <- read.soc(file.path(preflib, "00004%20-%20netflix/00004-00000138.soc"))
head(netflix, 2)
```
Each row corresponds to a unique ordering of the four movies in this data set.
The number of Netflix users that assigned that ordering is given in the first
column, followed by the four movies in preference order. So for example, 68
users ranked movie 2 first, followed by movie 1, then movie 4 and finally movie
3.
`PlackettLuce`, the model-fitting function in **PlackettLuce** requires that
the data are provided in the form of *rankings* rather than *orderings*, i.e.
the rankings are expressed by giving the rank for each item, rather than
ordering the items. We can create a `"rankings"` object from a set of orderings
as follows
```{r}
R <- as.rankings(netflix[,-1], input = "orderings",
items = attr(netflix, "items"))
R[1:3, as.rankings = FALSE]
```
Note that `read.soc` saved the names of the movies in the `"items"` attribute of
`netflix`, so we have used these to label the items. Subsetting the
rankings object `R` with `as.rankings = FALSE`, returns the underlying matrix of
rankings corresponding to the subset. So for example, in the first ranking the
second movie (Beverly Hills Cop) is ranked number 1, followed by the first movie
(Mean Girls) with rank 2, followed by the fourth movie (Mission: Impossible II)
and finally the third movie (The Mummy Returns), giving the same ordering as in
the original data.
Various methods are provided for `"rankings"` objects, in particular if we
subset the rankings without `as.rankings = FALSE`, the result is again a
`"rankings"` object and the corresponding print method is used:
```{r}
R[1:3]
print(R[1:3], width = 60)
```
The rankings can now be passed to `PlackettLuce` to fit the Plackett-Luce model.
The counts of each ranking provided in the downloaded data are used as weights
when fitting the model.
```{r}
mod <- PlackettLuce(R, weights = netflix$Freq)
coef(mod, log = FALSE)
```
Calling `coef` with `log = FALSE` gives the worth parameters, constrained to
sum to one. These parameters represent the probability that each movie is ranked
first.
For inference these parameters are converted to the log scale, by default
setting the first parameter to zero so that the standard errors are estimable:
```{r}
summary(mod)
```
In this way, Mean Girls is treated as the reference movie, the positive
parameter for Beverly Hills Cop shows this was more popular among the users,
while the negative parameters for the other two movies show these were less
popular.
Comparisons between different pairs of movies can be made visually by plotting
the log-worth parameters with comparison intervals based on quasi standard
errors.
```{r qv, fig.width = 9}
qv <- qvcalc(mod)
plot(qv, ylab = "Worth (log)", main = NULL)
```
If the intervals overlap there is no significant difference. So we can see that
Beverly Hills Cop is significantly more popular than the other three movies,
Mean Girls is significant more popular than The Mummy Returns or
Mission: Impossible II, but there was no significant difference in users'
preference for these last two movies.
## Going Further
The core functionality of **PlackettLuce** is illustrated in the package
vignette, along with details of the model used in the package and a comparison
to other packages. The vignette can be found on the [package website](https://hturner.github.io/PlackettLuce/) or from within R once the
package has been installed, e.g. via
vignette("Overview", package = "PlackettLuce")
## Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](https://github.com/hturner/PlackettLuce/blob/master/CONDUCT.md). By participating in this project you agree to abide by its terms.
## References
Owner
- Name: Heather Turner
- Login: hturner
- Kind: user
- Location: Newport, United Kingdom
- Company: University of Warwick
- Website: https://warwick.ac.uk/heatherturner
- Twitter: HeathrTurnr
- Repositories: 84
- Profile: https://github.com/hturner
Research Software Engineering Fellow, Department of Statistics, University of Warwick
GitHub Events
Total
- Issues event: 1
- Watch event: 4
- Issue comment event: 1
- Push event: 2
Last Year
- Issues event: 1
- Watch event: 4
- Issue comment event: 1
- Push event: 2
Committers
Last synced: over 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Heather Turner | ht@h****t | 374 |
| Ioannis Kosmidis | i****s@u****k | 67 |
| David Firth | d****h@w****k | 3 |
| kauedesousa | k****a@i****o | 2 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 44
- Total pull requests: 15
- Average time to close issues: 3 months
- Average time to close pull requests: about 3 hours
- Total issue authors: 9
- Total pull request authors: 2
- Average comments per issue: 0.8
- Average comments per pull request: 0.07
- Merged pull requests: 15
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 2
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 2
- Pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- hturner (29)
- kauedesousa (8)
- dbrownf (1)
- ttrodrigz (1)
- Kishor-Kayyar (1)
- jacobvanetten (1)
- DavidFirth (1)
- semer94 (1)
- fleverest (1)
Pull Request Authors
- hturner (14)
- kauedesousa (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- cran 563 last-month
- Total docker downloads: 42,005
-
Total dependent packages: 3
(may contain duplicates) -
Total dependent repositories: 5
(may contain duplicates) - Total versions: 16
- Total maintainers: 1
cran.r-project.org: PlackettLuce
Plackett-Luce Models for Rankings
- Homepage: https://hturner.github.io/PlackettLuce/
- Documentation: http://cran.r-project.org/web/packages/PlackettLuce/PlackettLuce.pdf
- License: GPL-3
-
Latest release: 0.4.4
published 6 months ago
Rankings
Docker downloads count: 0.6%
Forks count: 10.8%
Dependent packages count: 10.9%
Average: 12.2%
Dependent repos count: 13.0%
Stargazers count: 13.7%
Downloads: 24.3%
Maintainers (1)
Last synced:
6 months ago
conda-forge.org: r-plackettluce
- Homepage: https://hturner.github.io/PlackettLuce/
- License: GPL-3.0-only
-
Latest release: 0.4.2
published over 3 years ago
Rankings
Dependent repos count: 34.0%
Average: 45.2%
Forks count: 47.7%
Stargazers count: 47.8%
Dependent packages count: 51.2%
Last synced:
6 months ago
Dependencies
DESCRIPTION
cran
- R >= 2.10 depends
- CVXR * imports
- Matrix * imports
- R6 * imports
- RSpectra * imports
- igraph * imports
- matrixStats * imports
- methods * imports
- partykit * imports
- psychotools * imports
- psychotree * imports
- qvcalc * imports
- sandwich * imports
- stats * imports
- BayesMallows * suggests
- BiocStyle * suggests
- BradleyTerry2 * suggests
- PLMIX * suggests
- ROlogit * suggests
- StatRank * suggests
- bookdown * suggests
- covr * suggests
- gnm * suggests
- hyper2 * suggests
- kableExtra * suggests
- knitr * suggests
- lbfgs * suggests
- pmr * suggests
- prefmod * suggests
- rmarkdown * suggests
- survival * suggests
- testthat * suggests