{"id":24992032,"url":"https://github.com/hturner/plackettluce","last_synced_at":"2026-03-16T00:45:54.784Z","repository":{"id":52199771,"uuid":"86344815","full_name":"hturner/PlackettLuce","owner":"hturner","description":"PlackettLuce package for Plackett-Luce models in R","archived":false,"fork":false,"pushed_at":"2023-06-16T13:49:07.000Z","size":17988,"stargazers_count":20,"open_issues_count":5,"forks_count":5,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-12T02:13:21.706Z","etag":null,"topics":["plackett-luce-models","preferences","r","ranking","rankings-data","statistical-models"],"latest_commit_sha":null,"homepage":"https://hturner.github.io/PlackettLuce/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hturner.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-03-27T14:22:40.000Z","updated_at":"2024-12-20T03:15:05.000Z","dependencies_parsed_at":"2022-08-21T00:40:33.387Z","dependency_job_id":"7b04f69d-a95e-42ef-afed-7f50b6546f2e","html_url":"https://github.com/hturner/PlackettLuce","commit_stats":{"total_commits":434,"total_committers":4,"mean_commits":108.5,"dds":"0.16589861751152069","last_synced_commit":"fcb637addfc3b5895789ac9bfa2be73c6b19f91c"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hturner%2FPlackettLuce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hturner%2FPlackettLuce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hturner%2FPlackettLuce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hturner%2FPlackettLuce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hturner","download_url":"https://codeload.github.com/hturner/PlackettLuce/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505925,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["plackett-luce-models","preferences","r","ranking","rankings-data","statistical-models"],"created_at":"2025-02-04T13:53:31.521Z","updated_at":"2026-03-16T00:45:54.738Z","avatar_url":"https://github.com/hturner.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\nbibliography: [\"readme.bib\"]\n---\n\n```{r rmd-setup, include = FALSE}\nknitr::opts_chunk$set(fig.path = \"man/figures/\")\n```\n\n# PlackettLuce\n\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/PlackettLuce)](https://cran.r-project.org/package=PlackettLuce)\n[![R-CMD-check](https://github.com/hturner/PlackettLuce/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/hturner/PlackettLuce/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/hturner/PlackettLuce/branch/main/graph/badge.svg)](https://app.codecov.io/gh/hturner/PlackettLuce?branch=main)\n\nPackage website: https://hturner.github.io/PlackettLuce/.\n\n## Overview\n\nThe **PlackettLuce** package implements a generalization of the model jointly \nattributed to @Plackett1975 and @Luce1959 for modelling rankings data. \nExamples of rankings data might be the finishing order of competitors in a race,\nor the preference of consumers over a set of competing products. \n\nThe output of the model is an estimated **worth** for each item that appears in \nthe rankings. The parameters are generally presented on the log scale for \ninference.\n\nThe implementation of the Plackett-Luce model in **PlackettLuce**:\n\n - Accommodates ties (of any order) in the rankings, e.g.\n  bananas $\\succ$ {apples, oranges} $\\succ$ pears.\n - Accommodates sub-rankings, e.g. pears $\\succ$ apples, when the full set of items is {apples, bananas, oranges, pears}.\n - 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 \nhypothetical or ghost item.\n\n```{r always-loses, message = FALSE, echo = FALSE, fig.width = 3.5, fig.height = 3.5}\nlibrary(PlackettLuce)\nlibrary(igraph)\nR \u003c- matrix(c(1, 2, 0, 0,\n              2, 0, 1, 0,\n              1, 0, 0, 2,\n              2, 1, 0, 0,\n              0, 1, 2, 0), byrow = TRUE, ncol = 4,\n            dimnames = list(NULL, LETTERS[1:4]))\nR \u003c- as.rankings(R)\nA \u003c- adjacency(R)\nnet \u003c- graph_from_adjacency_matrix(A)\nplot(net, edge.arrow.size = 0.5, vertex.size = 30)\n```\n  \u003c/br\u003e\n\nIn addition the package provides methods for\n\n - Obtaining quasi-standard errors, that don't depend on the constraints applied\n to the worth parameters for identifiability.\n - Fitting Plackett-Luce trees, i.e. a tree that partitions the rankings by \n covariate values, such as consumer attributes or racing conditions, identifying \n subgroups with different sets of worth parameters for the items.\n \n## Installation\n\nThe package may be installed from CRAN via\n\n```{r, eval = FALSE}\ninstall.packages(\"PlackettLuce\")\n```\n\nThe development version can be installed via\n\n```{r, eval = FALSE}\n# install.packages(\"devtools\")\ndevtools::install_github(\"hturner/PlackettLuce\")\n```\n\n## Usage\n\nThe [Netflix Prize](https://en.wikipedia.org/wiki/Netflix_Prize) was a competition devised by \nNetflix to improve the accuracy of its recommendation system. To facilitate \nthis they released ratings about movies from the users of the system that have \nbeen transformed to preference data and are available from \n[PrefLib](https://www.preflib.org/dataset/00004), [@Bennett2007]. Each data set \ncomprises rankings of a set of 3 or 4 movies selected at random. Here we \nconsider rankings for just one set of movies to illustrate the functionality of \n**PlackettLuce**.\n\nThe data can be read in using the `read.soc` function in **PlackettLuce**\n```{r}\nlibrary(PlackettLuce)\npreflib \u003c- \"https://www.preflib.org/static/data/\"\nnetflix \u003c- read.soc(file.path(preflib, \"netflix/00004-00000138.soc\"))\nhead(netflix, 2)\n```\nEach row corresponds to a unique ordering of the four movies in this data set. \nThe number of Netflix users that assigned that ordering is given in the first \ncolumn, followed by the four movies in preference order. So for example, 68 \nusers ranked movie 2 first, followed by movie 1, then movie 4 and finally movie\n3. \n\n`PlackettLuce`, the model-fitting function in **PlackettLuce** requires that \nthe data are provided in the form of *rankings* rather than *orderings*, i.e. \nthe rankings are expressed by giving the rank for each item, rather than \nordering the items. We can create a `\"rankings\"` object from a set of orderings\nas follows\n```{r}\nR \u003c- as.rankings(netflix[,-1], input = \"orderings\",\n                 items = attr(netflix, \"items\"))\nR[1:3, as.rankings = FALSE]\n```\nNote that `read.soc` saved the names of the movies in the `\"items\"` attribute of\n`netflix`, so we have used these to label the items. Subsetting the\nrankings object `R` with `as.rankings = FALSE`, returns the underlying matrix of \nrankings corresponding to the subset. So for example, in the first ranking the \nsecond movie (Beverly Hills Cop) is ranked number 1, followed by the first movie\n(Mean Girls) with rank 2, followed by the fourth movie (Mission: Impossible II) \nand finally the third movie (The Mummy Returns), giving the same ordering as in \nthe original data.\n\nVarious methods are provided for `\"rankings\"` objects, in particular if we \nsubset the rankings without `as.rankings = FALSE`, the result is again a \n`\"rankings\"` object and the corresponding print method is used:\n\n```{r}\nR[1:3]\nprint(R[1:3], width = 60)\n```\n\nThe rankings can now be passed to `PlackettLuce` to fit the Plackett-Luce model.\nThe counts of each ranking provided in the downloaded data are used as weights \nwhen fitting the model.\n```{r}\nmod \u003c- PlackettLuce(R, weights = netflix$Freq)\ncoef(mod, log = FALSE)\n```\nCalling `coef` with `log = FALSE` gives the worth parameters, constrained to\nsum to one. These parameters represent the probability that each movie is ranked \nfirst.\n\nFor inference these parameters are converted to the log scale, by default \nsetting the first parameter to zero so that the standard errors are estimable:\n```{r}\nsummary(mod)\n```\nIn this way, Mean Girls is treated as the reference movie, the positive \nparameter for Beverly Hills Cop shows this was more popular among the users, \nwhile the negative parameters for the other two movies show these were less \npopular.\n\nComparisons between different pairs of movies can be made visually by plotting\nthe log-worth parameters with comparison intervals based on quasi standard\nerrors.\n```{r qv, fig.width = 9}\nqv \u003c- qvcalc(mod)\nplot(qv, ylab = \"Worth (log)\", main = NULL)\n```\n\nIf the intervals overlap there is no significant difference. So we can see that \nBeverly Hills Cop is significantly more popular than the other three movies,\nMean Girls is significant more popular than The Mummy Returns or \nMission: Impossible II, but there was no significant difference in users' \npreference for these last two movies.\n\n## Going Further\n\nThe core functionality of **PlackettLuce** is illustrated in the package \nvignette, along with details of the model used in the package and a comparison\nto other packages. The vignette can be found on the [package website](https://hturner.github.io/PlackettLuce/) or from within R once the \npackage has been installed, e.g. via \n\n    vignette(\"Overview\", package = \"PlackettLuce\")\n\n## Code of Conduct\n\nPlease 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.\n\n## References\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhturner%2Fplackettluce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhturner%2Fplackettluce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhturner%2Fplackettluce/lists"}