R Recommendation Grid Search Optimization

R Recommendation Grid Search Optimization

I have a self-developed function foo(a,b) taking two Parameters and Returns a value that I want to minimize. I know that a is between 0 and 1 but b is unconstrained.

Do you have some recommoendation, which package / function I can use to find the Minimum depending on my Parameters a and b?

I can use gridSearch(foo, a, b) (NMOF package) but this is just brute-force.

Thank you for the discussion!

1 Answer

optim() is a base R function that will do what you want. It implements a bunch of optimization routines. Some methods such as L-BFGS-B also allow for box constraints if you know the range of the parameters.

If this does not fit your needs, there are lots of packages offering more optimization algorithms, have a look at the CRAN task view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.