---
title: "Iteration techniques for Plackett-Luce likelihood functions and the `hyper2` package"
author: "R. K. S. Hankin"
output: bookdown::html_document2
bibliography: hyper2.bib  # copy vignettes/hyper2.bib to inst/
---


```{r setup, include=FALSE}
set.seed(0)
knitr::opts_chunk$set(echo = TRUE)
library("hyper2")
library("magrittr")
options("digits" = 5)
```

```{r out.width='20%', out.extra='style="float:right; padding:10px"',echo=FALSE}
knitr::include_graphics(system.file("help/figures/hyper2.png", package = "hyper2"))
```

To cite the `hyper2` package in publications, please use @hankin2017_rmd.
Here I discuss why implementing equation 30 of [@hunter2004] for
`hyper2` objects representing Plackett-Luce likelihood functions is
difficult.  Consider the following rank observations: `724356` [that
is, 7 came first, then 2, then 4 then 3 then 5 then 6] and `1372`
[that is, 1 came first, then 3 then 7 then 2].  If these two
observations are independent, we would have a Plackett-Luce likelihood
function of

\[
\left(
\frac{[7]}{[234567]}\cdot\frac{[2]}{[23456]}\cdot\frac{[4]}{[3456]}\cdot\frac{[3]}{[356]}\cdot\frac{[5]}{[56]}
\right)\left(\frac{[1]}{[1237]}\cdot\frac{[3]}{[237]}\cdot\frac{[7]}{[27]}\right)
\]

(where $[1234]$ is short for $p_1+p_2+p_3+p_4$).  Then Hunter's
iteration formula gives, for example:

\[
p_3\longrightarrow\frac{2}{
(p_7+p_2+p_4+p_3+p_5+p_6)^{-1}+
(    p_2+p_4+p_3+p_5+p_6)^{-1}+
(        p_4+p_3+p_5+p_6)^{-1}+
(            p_3+p_5+p_6)^{-1}+
(p_1+p_3+p_7+p_2)^{-1}+
(    p_3+p_7+p_2)^{-1}
}\]

or, more compactly,
\[p_3\longrightarrow
\frac{2}{[724356]^{-1}+[24356]^{-1}+[4356]^{-1}+[356]^{-1}+[1372]^{-1}+[372]^{-1}}.
\]


However, the `hyper2` object corresponding to the PL likelihood function would be

\[
\frac{
  [1][2][3]^2[4][5][7]^2
}{
  [1237]\cdot [23456]\cdot [234567]\cdot [237]\cdot [27]
\cdot [3456] \cdot [356]\cdot[56]
}
\]

(Note that the brackets have been rearranged and also the brackets
themselves.  Also we have no idea which term on the numerator goes
with which one on the denominator).  The desired iterative step would
be

$p_1\longrightarrow\frac{1}{[1237]^{-1}}$

$p_2\longrightarrow\frac{1}{[234567]^{-1}+[23456]^{-1}}$

$p_3\longrightarrow
\frac{2}{[273456]^{-1}+[23456]^{-1}+[3456]^{-1}+[356]^{-1}+[1237]^{-1}+[237]^{-1}}$

$p_4 \longrightarrow\frac{1}{[724356]^{-1}+[24356]^{-1}+[4356]^{-1}}$

$p_5\longrightarrow\frac{1}{[273456]^{-1}+[23456]^{-1}+[3456]^{-1}+[356]^{-1}+[56]^{-1}}$

$p_6 \longrightarrow\frac{0}{[6]^{-1}}$

$p_7 \longrightarrow\frac{2}{[273456]^{-1}+[27]^{-1}}$


and it does not seem at all easy to convert the `hyper2` object to
Hunter's iteration scheme.  The numerators of the fractions are just
the powers of the singleton terms in the likelihood function.  But the
denominators are harder.  To update $p_3$, for example, we would start
with the denominator $[1237]\cdot[23456]\cdot[234567]\cdot
[237]\cdot[27]\cdot[3456]\cdot[356]\cdot[56]$ and then extract just
the brackets containing 3 to get $[1237]\cdot[23456]\cdot[234567]\cdot
[237]\cdot[3456]\cdot[356]$ and then somehow identify two increasing
chains

$[27]\longrightarrow[237]\longrightarrow [1237]$

and 

$[356]\longrightarrow[3456]\longrightarrow[23456]\longrightarrow[234567]$



### References {-}

