Skip to contents

Returns X / sup_ub, which has expectation at most 1 under every distribution in H0. If sup_ub <= 1, X is returned unchanged. The result keeps X's log form.

Usage

e_variable(x, ...)

Arguments

x

A ripr_certificate, as returned by certify().

...

Unused, for methods.

Value

A random_variable with expectation at most 1 under the null.

Details

X must be non-negative (e.g. a likelihood ratio), but this is not checked. A lower bound via ripr_search from sup_lb() is illegal!

See also

Examples

fam <- multinomial_family(n_trials = 4L, k = 3L)
plurality <- null_model(
  fam,
  list(
    simplex_region(vertices = rbind(c(0.5, 0.5, 0), c(0, 1, 0), c(0, 0, 1))),
    simplex_region(vertices = rbind(c(0.5, 0, 0.5), c(0, 1, 0), c(0, 0, 1)))
  )
)
# Against a uniform null point that is not the RIPr, the likelihood ratio
# is not an e-variable as it stands, and the certificate says by how much.
Q <- fam(c(0.4, 0.35, 0.25))
X <- likelihood(Q) / likelihood(fam(c(1, 1, 1) / 3))
cert <- certify(X, plurality, tol = 1e-6)
cert@sup_ub
#> [1] 1.601807

E <- e_variable(cert)
E
#> <random_variable> P[theta = (0.4, 0.35, 0.25)] / P[theta = (0.333, 0.333, 0.333)] / 1.601807 
#>   on count_space, dimension 3 
E(c(2, 1, 1))
#> [1] 0.7079506