increment.RdSyntactic sugar for incrementing and decrementing likelihood functions.
Frankly they don't do anything that magrittr:add() and
magrittr:subtract() don't (except have a default value of 1
(which is surprisingly useful).
inc(H, val = 1)
dec(H, val = 1)
trial(winners,players,val=1)A very frequent operation is to increment a single term in a
hyper2 object. If
> H <- hyper2(list("a",c("a","b"),"c",c("a","b","c")),c(1:3,-6))
> H
log( a * (a + b + c)^-6 * b^2 * c^3)
Suppose we wish to increment the power of a+b. We could do:
(see the discussion of hyper2_sum_numeric at
Ops.hyper2.Rd; also vignette zeropower). Alternatively we
could use magrittr pipes:
H[c("a","b")] %<>% add(1)But inc and dec furnish convenient idiom to accomplish the
same thing:
H[c("a","b")] %<>% incFunctions inc and dec default to adding or subtracting 1,
but other values can be supplied:
Or even
The convenience function trial() takes this one step further and
increments the ‘winning team’ and decrements the bracket
containing all players. The winners are expected to be players.
> trial(c("a","b"),c("a","b","c"))
> (a + b) * (a + b + c)^-1
Using trial() in this way ensures that the powers sum to zero.
The inc and dec operators and the trial()
function are used in inst/kka.Rmd.