pwa.RdConfer additional BT strength on specified players, either by
introducing a reified entity (hyper2) or an increased weight
(hyper3).
pwa(H, pwa, chameleon = "S")
pwa3_single(H3, pwa, lambda)
pwa3(H3, ...)Commonly, when considering competitive situations we suspect that one player has an advantage of some type which we would like to quantify in terms of an additional strength. Examples might include racing at pole position, playing white in chess, or playing soccer at one's home ground.
Function pwa() (“player with advantage”) returns a
modified hyper2 object with the additional strength represented
as a reified entity.
Given H of class hyper2 and a competitor a,
pwa(H, "a") replaces every occurrence of a in H
with a+S, with S representing the extra strength
conferred.
Argument a may be a vector of competitors: each bracket
containing any member of a has S added to it. If a
includes more than one competitor, the resulting likelihood function
does not seem to instantiate any simple situation.
Function pwa3() is the hyper3 equivalent; it modifies the
weight of specified players. The named argument mechanism
[e.g. pwa3(H, e=1.2, f=3.4)] is the same as that of subs()
in the mvp package. If there is exactly one ellipsis
argument, and it is a named vector, the elements are interpreted as
name/value pairs, so pwa3(H, c(e=1.2, f=3.4)) works. Function
pwa3_single() is a lower-level helper function that takes a
single player name and its lambda value as second and third arguments.
Nice examples of pwa() are given in inst/cook.Rmd and
inst/universities.Rmd, and some discussion of pwa3() is
given in inst/pwa3.Rmd.
Returns an object of class hyper2 or hyper3.
Earlier versions of this package gave a contrived sequence of
observations, presented as an example of pwa() with multiple
advantaged competitors. I removed it because the logic was flawed, but
it featured a chameleon who could impersonate (and indeed eat) certain
competitors, which is why the third argument is so named.
The aliases commemorate some uses of the function in the vignettes and
markdown files in the inst/ directory.
summary(formula1 |> pwa("Hamilton","pole"))
#> A hyper2 object of size 26.
#> pnames: Alonso Bottas Button Ericsson Gasly Giovinazzi Grosjean Hamilton Hartley Hulkenberg Kvyat Magnussen Massa Ocon Palmer Perez Raikkonen Resta Ricciardo Sainz Stroll Vandoorne Verstappen Vettel Wehrlein pole
#> Number of brackets: 262
#> Sum of powers: 0
#>
#> Table of bracket lengths:
#> 1 2 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#> 22 1 3 6 12 16 18 19 20 19 20 18 19 18 11 11 10 9 5 4 1
#>
#> Table of powers:
#> -20 -9 -6 -5 -4 -3 -2 -1 1 2 5 11 12 13 14 15 16 17 18 19
#> 1 1 3 1 3 4 12 214 1 1 1 3 1 1 4 2 1 3 1 3
#> 20
#> 1
H <- ordervec2supp(c(a = 2, b = 3, c = 1, d = 5, e = 4))
pwa(H,'a')
#> log( (S + a) * (S + a + b + c + d + e)^-1 * (S + a + b + d + e)^-1 * b
#> * (b + d + e)^-1 * c * (d + e)^-1 * e)
pwa3_single(H, "a", 1.888)
#> log( (a=1.888)^1 * (a=1.888, b=1, c=1, d=1, e=1)^-1 * (a=1.888, b=1,
#> d=1, e=1)^-1 * (b=1)^1 * (b=1, d=1, e=1)^-1 * (c=1)^1 * (d=1, e=1)^-1 *
#> (e=1)^1)
pwa3(H, b=1.8, c=0.7)
#> log( (a=1)^1 * (a=1, b=1.8, c=0.7, d=1, e=1)^-1 * (a=1, b=1.8, d=1,
#> e=1)^-1 * (b=1.8)^1 * (b=1.8, d=1, e=1)^-1 * (c=0.7)^1 * (d=1, e=1)^-1
#> * (e=1)^1)
## Four races between a,b,c,d:
H1 <- ordervec2supp(c(a = 1, b = 3, c = 4, d = 2))
H2 <- ordervec2supp(c(a = 0, b = 1, c = 3, d = 2))
H3 <- ordervec2supp(c(a = 4, b = 2, c = 1, d = 3))
H4 <- ordervec2supp(c(a = 3, b = 4, c = 1, d = 2))
## Now it is revealed that a,b,c had some advantage in races 1,2,3
## respectively. Is there evidence that this advantage exists?
if (FALSE) # takes ~10 seconds, too long for here
specificp.test(pwa(H1,'a') + pwa(H2,'b') + pwa(H3,'c') + H4,"S")
# \dontrun{}