Ops.hyper2 {hyper2}R Documentation

Arithmetic Ops Group Methods for hyper2 objects

Description

Allows arithmetic operators “+”, “*” and comparison operators “==” and “!=”, to be used for hyper2 objects.

Specifically, H1 + H2 implements addition of two log-likelihood functions, corresponding to incorporation of additional independent observational data; and n*H1 implements H1+H1+...+H1, corresponding to repeated independent observations of the same data.

There are no unary operations for this class.

Usage

## S3 method for class 'hyper2'
Ops(e1, e2 = NULL)
## S3 method for class 'hyper2'
sum(x,...,na.rm=FALSE)
hyper2_add(e1,e2)
hyper2_sum_numeric(H,r)

Arguments

e1, e2

Objects of class hyper2, here interpreted as hyperdirichlet distributions

x, ..., na.rm

In the sum() method, objects to be summed; na.rm is currently ignored

H, r

In function hyper2_sum_numeric(), object H is a hyper2 object and r is a length-one real vector (a number)

Details

If two independent datasets have hyper2 objects H1 and H2, then package idiom for combining these would be H1+H2; the additive notation “+” corresponds to addition of the support (or multiplication of the likelihood). So hyper2 objects are better thought of as support functions than likelihood functions; this is reflected in the print method which explicitly wraps the likelihood function in a “log()”.

Idiom H1-H1 returns H1 + (-1)*H2, useful for investigating the difference between likelihood functions arising from two different observations, or different probability models. An example is given in inst/soling.Rmd.

Testing for equality is not straightforward for two implementation reasons. Firstly, the object itself is stored internally as a stl map, which does not store keys in any particular order; and secondly, the stl set class is used for the brackets. A set does not include information about the order of its elements; neither does it admit repeated elements. See examples.

Function hyper2_sum_numeric() is defined so that idiom like icons["L"] + 5 works as expected. This means that icons["L"] <- icons["L"] + 3 and icons["L"] %<>%inc(3) work (without this, one has to type icons["L"] <- powers(icons["L"]) + 3, which sucks).

Raising a hyper2 object to a power returns an error.

Value

Returns a hyper2 object or a Boolean.

Author(s)

Robin K. S. Hankin

Examples


chess2 <- hyper2(list("Kasparov","Karpov",c("Kasparov","Karpov")),c(2,3,-5))

chess + chess2

maxp(chess+chess2)



[Package hyper2 version 3.1-0 Index]