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)A hyper2 object
A list with elements all hyper2 objects
A vector of probabilities
Boolean, with default FALSE meaning to return just
the evaluate (including fillup), and TRUE meaning to return
the entire formal output of the optimization routine
Further problem-specific constraints
Number of start points to use
Boolean, with TRUE meaning to show successive
estimates
Boolean, with TRUE meaning to return just a
vector of estimated likelihoods
Numerical minimum for probabilities
Integer specifying maximum number of times to try
constrOptim() with slightly differing start points, to avoid
a known R bug which reports wmmin is not finite, bugzilla
id 17703
Further arguments which maxp() passes to
constrOptim()
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\leq p < 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.
# NOT RUN {
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)
# }
# NOT RUN {
# takes a long time to maximize a suplist
# }
Run the code above in your browser using DataLab