| Ops.hyper2 | R Documentation |
Allows arithmetic operators “+”, “*” and
comparison operators “==” and “!=”, to be
used for hyper2 objects.
## S3 method for class 'hyper2'
Ops(e1, e2 = NULL)
## S3 method for class 'hyper2'
sum(x, ..., na.rm=FALSE)
hyper2_sum_hyper2(e1, e2)
hyper2_sum_numeric(H, r)
e1, e2 |
Objects of class |
x, ..., na.rm |
In the |
H, r |
In function |
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()”.
Scalar multiplication is defined: n*H1 returns
H1+H1+...+H1, corresponding to n repeated independent
observations of the same data.
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.
A hyper2 object may be added to a numeric vector under some
circumstances. If H is a hyper2 object and n a
numeric vector, then “H+n” returns a disord
object corresponding to powers(H) + n, if this is allowed.
Function hyper2_sum_numeric() is defined so that idiom like
icons["L"] <- icons["L"] + 3 and icons["L"] %<>%inc(3)
work as expected (without this, one has to type icons["L"] <-
powers(icons["L"]) + 3, which sucks).
Formerly, this operation returned an error if the powers have length
exceeding one, so “icons[list("NB","L")] + 5” failed.
But because the sum is now defined to be a disord object,
errors are flagged, correctly, as disordR discipline
violations.
Raising a hyper2 object to a power returns an error. There are
no unary operations for this class.
Returns a hyper2 object or a Boolean.
Robin K. S. Hankin
chess2 <- hyper2(list("Kasparov","Karpov",c("Kasparov","Karpov")),c(2,3,-5))
chess + chess2
maxp(chess + chess2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.