0

When using the fminsearch function of the neldermead package

library(neldermead)

foo <- function(x){
  -exp(-x**2)
}
sol <- fminsearch(fun = foo, x0 = -10)

How can I get the optimum values?

I see I can print sol and that this gives the correct value:

> sol

Number of Estimated Variable(s): 1

Estimated Variable(s):
  Initial Final
1     -10     0

But I would need to store that value in a variable. The examples in the documentation do not say how to access to that value, so I guess it is trivial, but I don't find the way to do it.

alberto
  • 2,625
  • 4
  • 29
  • 48

1 Answers1

1

Not sure the above answer is correct, my understanding is that you need

neldermead.get(sol, "xopt")

as sol is a neldermead object, see the documentation here

Nils Gudat
  • 13,222
  • 3
  • 39
  • 60
  • Thanks Nils ! Just for curiosity, was it possible to see this `xopt` field by inspecting the output object? It is not in names(sol), for instance. Or it is only in the documentation? – alberto May 21 '16 at 11:28
  • 1
    Not at my computer right now but when checking earlier I couldn't find it in the output object via `names`, nor via tab complete in R studio. Only figured it out from the docs myself. – Nils Gudat May 21 '16 at 15:51