Description Usage Arguments Details Value Author(s) See Also Examples
This function takes basically the same arguments as optim
with a lower and upper bound for optimization as required by the method "L-BFGS-B"
,
and is intended for optimization over the parameter set of a LuckModel
.
1 2 |
par |
Initial values for the parameters to be optimzed over,
typically one of the "corners" of the prior parameter set
defined by a |
fn |
The function to be minimized or maximized. The first argument must be named |
method |
The optimization method to be used, see |
control |
A list of control parameters, see |
lower |
Lower bound for the optimization, in the same format as |
upper |
Upper bound for the optimization, in the same format as |
... |
Further arguments to be passed to |
Depending wether lower
and upper
coincide in none
or either of n^(0) or y^(0),
optim
or optimize
are called.
If lower
and upper
coincide in both elements,
then no optimization is performed and the value of fn
at lower
(=upper
) is returned.
This function was programmed before the method "Brent"
in optim
existed,
which seems to provide a similar functionality.
The return value is the return object of optim
(or pretends to be so).
See optim
for details.
Gero Walter
luck
for a general description of the package,
optim
,
optimize
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # function to optimize over
testfn <- function (.n0y0, arg2) {
if (arg2) return(.n0y0[1]^2 + .n0y0[2])
else return (.n0y0[2]^2 + .n0y0[1])
}
# minimize
wrapOptim(par = c(1,1), fn = testfn, lower = c(1,1), upper = c(5,5), arg2 = FALSE)
wrapOptim(par = c(1,1), fn = testfn, lower = c(1,1), upper = c(5,5), arg2 = TRUE)
wrapOptim(par = c(1,1), fn = testfn, lower = c(1,1), upper = c(1,1), arg2 = TRUE)
wrapOptim(par = c(1,5), fn = testfn, lower = c(1,1), upper = c(1,5), arg2 = TRUE)
wrapOptim(par = c(2,1), fn = testfn, lower = c(1,1), upper = c(5,1), arg2 = TRUE)
# maximize
wrapOptim(par = c(1,1), fn = testfn, lower = c(1,1), upper = c(5,5), arg2 = FALSE,
control = list(fnscale=-1))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.