You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The **PlackettLuce** package implements a generalization of the model jointly attributed to Plackett (1975) and Luce (1959) 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.
15
+
The **PlackettLuce** package implements a generalization of the model
16
+
jointly attributed to Plackett (1975) and Luce (1959) for modelling
17
+
rankings data. Examples of rankings data might be the finishing order of
18
+
competitors in a race, or the preference of consumers over a set of
19
+
competing products.
13
20
14
-
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.
21
+
The output of the model is an estimated **worth** for each item that
22
+
appears in the rankings. The parameters are generally presented on the
23
+
log scale for inference.
15
24
16
25
The implementation of the Plackett-Luce model in **PlackettLuce**:
17
26
18
-
- Accommodates ties (of any order) in the rankings, e.g. bananas ≻ {apples, oranges} ≻ pears.
19
-
- Accommodates sub-rankings, e.g. pears ≻ apples, when the full set of items is {apples, bananas, oranges, pears}.
20
-
- 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.
27
+
- Accommodates ties (of any order) in the rankings, e.g. bananas
28
+
\(\succ\) {apples, oranges} \(\succ\) pears.
29
+
- Accommodates sub-rankings, e.g. pears \(\succ\) apples, when the
30
+
full set of items is {apples, bananas, oranges, pears}.
31
+
- Handles disconnected or weakly connected networks implied by the
32
+
rankings, e.g. where one item always loses as in figure below. This
33
+
is achieved by adding pseudo-rankings with a hypothetical or ghost
34
+
item.
21
35
22
-
 </br>
36
+
<!----> </br>
23
37
24
38
In addition the package provides methods for
25
39
26
-
- Obtaining quasi-standard errors, that don't depend on the constraints applied to the worth parameters for identifiability.
27
-
- 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.
40
+
- Obtaining quasi-standard errors, that don’t depend on the
41
+
constraints applied to the worth parameters for identifiability.
42
+
- Fitting Plackett-Luce trees, i.e. a tree that partitions the
43
+
rankings by covariate values, such as consumer attributes or racing
44
+
conditions, identifying subgroups with different sets of worth
45
+
parameters for the items.
28
46
29
-
Installation
30
-
------------
47
+
## Installation
31
48
32
49
The package may be installed from GitHub via
33
50
@@ -36,12 +53,19 @@ The package may be installed from GitHub via
36
53
devtools::install_github("hturner/PlackettLuce")
37
54
```
38
55
39
-
Usage
40
-
-----
56
+
## Usage
41
57
42
-
The [Netflix Prize](http://www.netflixprize.com/) 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](http://www.preflib.org/data/election/netflix/). 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**.
58
+
The [Netflix Prize](http://www.netflixprize.com/) was a competition
59
+
devised by Netflix to improve the accuracy of its recommendation system.
60
+
To facilitate this they released ratings about movies from the users of
61
+
the system that have been transformed to preference data and are
62
+
available from [PrefLib](http://www.preflib.org/data/election/netflix/).
63
+
Each data set comprises rankings of a set of 3 or 4 movies selected at
64
+
random. Here we consider rankings for just one set of movies to
65
+
illustrate the functionality of **PlackettLuce**.
43
66
44
-
The data can be read in using the `read.soc` function in **PlackettLuce**
67
+
The data can be read in using the `read.soc` function in
68
+
**PlackettLuce**
45
69
46
70
```r
47
71
library(PlackettLuce)
@@ -54,9 +78,17 @@ head(netflix, 2)
54
78
## 1 68 2 1 4 3
55
79
## 2 53 1 2 4 3
56
80
57
-
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.
81
+
Each row corresponds to a unique ordering of the four movies in this
82
+
data set. The number of Netflix users that assigned that ordering is
83
+
given in the first column, followed by the four movies in preference
84
+
order. So for example, 68 users ranked movie 2 first, followed by movie
85
+
1, then movie 4 and finally movie 3.
58
86
59
-
`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
87
+
`PlackettLuce`, the model-fitting function in **PlackettLuce** requires
88
+
that the data are provided in the form of *rankings* rather than
89
+
*orderings*, i.e. the rankings are expressed by giving the rank for each
90
+
item, rather than ordering the items. We can create a `"rankings"`
91
+
object from a set of orderings as follows
60
92
61
93
```r
62
94
R<- as.rankings(netflix[,-1], input="ordering")
@@ -69,9 +101,19 @@ R[1:3, as.rankings = FALSE]
69
101
## 2 1 2 4 3
70
102
## 3 2 1 3 4
71
103
72
-
Note that `read.soc` saved the names of the movies in the `"item"` 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.
104
+
Note that `read.soc` saved the names of the movies in the `"item"`
105
+
attribute of `netflix`, so we have used these to label the items.
106
+
Subsetting the rankings object `R` with `as.rankings = FALSE`, returns
107
+
the underlying matrix of rankings corresponding to the subset. So for
108
+
example, in the first ranking the second movie (Beverly Hills Cop) is
109
+
ranked number 1, followed by the first movie (Mean Girls) with rank 2,
110
+
followed by the fourth movie (Mission: Impossible II) and finally the
111
+
third movie (The Mummy Returns), giving the same ordering as in the
112
+
original data.
73
113
74
-
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:
114
+
Various methods are provided for `"rankings"` objects, in particular if
115
+
we subset the rankings without `as.rankings = FALSE`, the result is
116
+
again a `"rankings"` object and the corresponding print method is used:
75
117
76
118
```r
77
119
R[1:3]
@@ -95,7 +137,9 @@ print(R[1:3], width = 60)
95
137
## 3
96
138
## "Beverly Hills Cop > Mean Girls > The Mummy Returns > Mis ..."
97
139
98
-
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.
140
+
The rankings can now be passed to `PlackettLuce` to fit the
141
+
Plackett-Luce model. The counts of each ranking provided in the
142
+
downloaded data are used as weights when fitting the model.
99
143
100
144
```r
101
145
mod<- PlackettLuce(R, weights=netflix$n)
@@ -107,9 +151,13 @@ coef(mod, log = FALSE)
107
151
## Mission: Impossible II
108
152
## 0.1498342
109
153
110
-
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.
154
+
Calling `coef` with `log = FALSE` gives the worth parameters,
155
+
constrained to sum to one. These parameters represent the probability
156
+
that each movie is ranked first.
111
157
112
-
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:
158
+
For inference these parameters are converted to the log scale, by
159
+
default setting the first parameter to zero so that the standard errors
160
+
are estimable:
113
161
114
162
```r
115
163
summary(mod)
@@ -130,34 +178,60 @@ summary(mod)
130
178
## AIC: 3499.5
131
179
## Number of iterations: 5
132
180
133
-
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.
181
+
In this way, Mean Girls is treated as the reference movie, the positive
182
+
parameter for Beverly Hills Cop shows this was more popular among the
183
+
users, while the negative parameters for the other two movies show these
184
+
were less popular.
134
185
135
-
Comparisons between different pairs of movies can be made visually by plotting the log-worth parameters with comparison intervals based on quasi standard errors.
186
+
Comparisons between different pairs of movies can be made visually by
187
+
plotting the log-worth parameters with comparison intervals based on
188
+
quasi standard errors.
136
189
137
190
```r
138
191
qv<- qvcalc(mod)
139
192
plot(qv)
140
193
```
141
194
142
-

195
+
<!---->
143
196
144
-
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.
197
+
If the intervals overlap there is no significant difference. So we can
198
+
see that Beverly Hills Cop is significantly more popular than the other
199
+
three movies, Mean Girls is significant more popular than The Mummy
200
+
Returns or Mission: Impossible II, but there was no significant
201
+
difference in users’ preference for these last two movies.
145
202
146
-
Going Further
147
-
-------------
203
+
## Going Further
148
204
149
-
The full 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
205
+
The full functionality of **PlackettLuce** is illustrated in the package
206
+
vignette, along with details of the model used in the package and a
207
+
comparison to other packages. The vignette can be found on the [package
208
+
website](https://hturner.github.io/PlackettLuce/) or from within R once
209
+
the package has been installed, e.g. via
150
210
151
211
vignette("Overview", package = "PlackettLuce")
152
212
153
-
Code of Conduct
154
-
---------------
213
+
## Code of Conduct
155
214
156
-
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.
215
+
Please note that this project is released with a [Contributor Code of
216
+
Conduct](CONDUCT.md). By participating in this project you agree to
217
+
abide by its terms.
157
218
158
-
References
159
-
----------
219
+
## References
160
220
161
-
Luce, R. Duncan. 1959. *Individual Choice Behavior: A Theoretical Analysis*. doi:[10.2307/2282347](https://doi.org/10.2307/2282347).
221
+
<divid="refs"class="references">
162
222
163
-
Plackett, Robert L. 1975. “The Analysis of Permutations.” *Appl. Statist* 24 (2): 193–202. doi:[10.2307/2346567](https://doi.org/10.2307/2346567).
223
+
<divid="ref-Luce1959">
224
+
225
+
Luce, R. Duncan. 1959. *Individual Choice Behavior: A Theoretical
226
+
Analysis*. New York: Wiley.
227
+
228
+
</div>
229
+
230
+
<divid="ref-Plackett1975">
231
+
232
+
Plackett, Robert L. 1975. “The Analysis of Permutations.” *Appl.
\AppData\Local\Temp\RtmpyQZw3Z\READMEcf025d05abf.html"' had status 99
23
+
* checking CRAN incoming feasibility ...Warning: running command '"pandoc" "C:\Users\hturner\PlackettLuce.Rcheck\00_pkg_src\PlackettLuce\README.md" -s --email-obfuscation=references --self-contained -o "C:\Users\hturner\AppData\Local\Temp\RtmpyQZw3Z\READMEcf025d05abf.html"' had status 99
22
24
23
-
The warning seems to be due to pandoc not finding image files in `man/figures`.
24
-
I could successfully run the pandoc command by either changing directory to
25
-
"C:\Users\hturner\PlackettLuce.Rcheck\00_pkg_src\PlackettLuce" and calling
26
-
pandoc on "README.md", or adding `--resource-path
27
-
"C:\Users\hturner\PlackettLuce.Rcheck\00_pkg_src\PlackettLuce` to the call shown
28
-
in the warning.
25
+
The warning seems to be due to pandoc not finding image files in `man/figures`. I could successfully run the pandoc command by either changing directory to "C:\Users\hturner\PlackettLuce.Rcheck\00_pkg_src\PlackettLuce" and calling pandoc on "README.md", or adding `--resource-path "C:\Users\hturner\PlackettLuce.Rcheck\00_pkg_src\PlackettLuce` to the call shown in the warning.
0 commit comments