This implementation is primarily intended to be called from other
maximization routines, such as maxNR.
sumt(fn, grad=NULL, hess=NULL,
start,
maxRoutine, constraints,
SUMTTol = sqrt(.Machine$double.eps),
SUMTPenaltyTol = sqrt(.Machine$double.eps),
SUMTQ = 10,
SUMTRho0 = NULL,
printLevel=print.level, print.level = 0, SUMTMaxIter = 100, ...)fn. NULL if missingfn. NULL if missingmaxNReqA and eqB
for linear equality constraints: $A \beta + B = 0$. The user must ensure that the matrices A and
Note this does not necessarily mean that
SUMTTol, the algorithm stopsrho
as described in Details. Defaults to 10.rho. If not specified, a (possibly)
suitable value is
selected. See Details. One should consider supplying SUMTRho0 in case where the
unconstrained problem does not have a maximum, or the maxi
maxRoutine and fn. Any of
the maximization algorithms in the maxNR, can be used for the unconstrained step.
Analytic gradient and hessian are used if provided.
sumt in package ## We maximize exp(-x^2 - y^2) where x+y = 1
hatf <- function(theta) {
x <- theta[1]
y <- theta[2]
exp(-(x^2 + y^2))
## Note: you may prefer exp(- theta \%*\% theta) instead
}
## use constraints: x + y = 1
A <- matrix(c(1, 1), 1, 2)
B <- -1
res <- sumt(hatf, start=c(0,0), maxRoutine=maxNR,
constraints=list(eqA=A, eqB=B))
print(summary(res))Run the code above in your browser using DataLab