| maxp {hyper2} | R Documentation |
Find the maximum likelihood estimate for p, also equal probabilities
maxp(H, startp=NULL, give=FALSE, fcm=NULL, fcv=NULL, SMALL=1e-6, n=10, show=FALSE, justlikes=FALSE, ...) maxplist(Hlist, startp=NULL, give=FALSE, fcm=NULL, fcv=NULL, SMALL=1e-6, ...) maxp_single(H, startp=NULL, give=FALSE, fcm=NULL, fcv=NULL, SMALL=1e-6, maxtry=100, ...) maxp_simplex(H, n=100, show=FALSE, give=FALSE, ...) equalp(H)
H |
A |
Hlist |
A list with elements all |
startp |
A vector of probabilities |
give |
Boolean, with default |
fcm,fcv |
Further problem-specific constraints |
n |
Number of start points to use |
show |
Boolean, with |
justlikes |
Boolean, with |
SMALL |
Numerical minimum for probabilities |
maxtry |
Integer specifying maximum number of times to try
|
... |
Further arguments which |
Function maxp() returns the maximum likelihood estimate for
p, which has the unit sum constraint implemented.
Function maxplist() does the same but takes a list of
hyper2 objects (for example, the output of ggrl()).
Note that maxplist() does not have access to the gradient of
the objective function, which makes it slow.
If function maxp() is given a suplist object it
dispatches to maxplist().
Function maxp_simplex() is intended for complicated or flat
likelihood functions where finding local maxima might be a problem.
It repeatedly calls maxp_single(), starting from a different
randomly chosen point in the simplex each time. This function does
not take fcm or fcv arguments, it operates over the
whole simplex (hence the name). Further arguments, ..., are
passed to maxp_single().
The functions do not work for the masterchef_series6 likelihood
function. These require a bespoke optimization as shown in the
vignette.
Function equalp() returns the value of p for which all
elements are the same.
In functions maxp() etc, arguments fcm and fcv
implement linear constraints to be passed to constrOptim().
These constraints are in addition to the usual nonnegativity
constraints and unit-sum constraint, and are added to the ui
and ci arguments of constrOptim() with rbind()
and c() respectively. The operative lines are in
maxp_single():
UI <- rbind(diag(nrow = n - 1), -1, fcm)
CI <- c(rep(SMALL, n - 1), -1 + SMALL, fcv)
where in UI, the first n-1 rows enforce nonnegativity of
p_i, 1<=i<n; row n enforces
nonnegativity of the fillup value p_n; and the remaining
(optional) rows enforce additional linear constraints. Argument
CI is a vector with corresponding elements.
Examples of their use are given in the “icons” vignette.
In manpages elsewhere, n=2 is used for speed reasons. Use the
default n=10 or greater in production work.
This functionality is peculiarly susceptible to off-by-one errors.
The built-in datasets generally include a pre-calculated result of
running maxp(); thus hyper2 object icons and
icons_maxp are included in the same .rda file.
Function maxp() can trigger a known R bug (bugzilla id 17703)
which reports “wmmin is not finite”.
Robin K. S. Hankin
maxp(icons) W <- hyper2(pnames=letters[1:5]) W1 <- ggrl(W, 'a', letters[2:3],'d') # W1 is a suplist object ## Not run: maxp(W1) # takes a long time to maximize a suplist