Re: [R] Problem with minimization that I failed to understand

2025-03-28 Thread Daniel Lobo
Hi Rui, I was not aware of this function, however it looks like it should work for me. Many thanks for this intuition. However, in my optimization there are 3 constraints as below, 1) sum of all parameters should be 1 2) all parameters should be positive 3) last parameter should be greater than

Re: [R] Problem with minimization that I failed to understand

2025-03-28 Thread Rui Barradas
Às 13:59 de 28/03/2025, Daniel Lobo escreveu: Hi Duncan, Thanks for your comment, I agree with that. But, how it can be justified that an Optimizer gives a result which is inferior to the starting value? At most, resulting value can remain at the same level, isnt it? On Fri, 28 Mar 2025 at 14:

Re: [R] Problem with minimization that I failed to understand

2025-03-28 Thread Duncan Murdoch
That's a question for the maintainer of the package you used. Duncan Murdoch On 2025-03-28 9:59 a.m., Daniel Lobo wrote: Hi Duncan, Thanks for your comment, I agree with that. But, how it can be justified that an Optimizer gives a result which is inferior to the starting value? At most, resu

Re: [R] Problem with minimization that I failed to understand

2025-03-28 Thread J C Nash
Every time I give a seminar on optimization (most recently in Feb at Univ Cote d'Azur -- thank you Yassine for the welcome!) I point out Algorithms CONVERGE Programs TERMINATE If you race a Maserati (fmincon?) on a dirt bike course, you'll likely get stuck on the first mud mound, which co

Re: [R] Problem with minimization that I failed to understand

2025-03-28 Thread Daniel Lobo
Hi Duncan, Thanks for your comment, I agree with that. But, how it can be justified that an Optimizer gives a result which is inferior to the starting value? At most, resulting value can remain at the same level, isnt it? On Fri, 28 Mar 2025 at 14:34, Duncan Murdoch wrote: > I haven't run your

Re: [R] Problem with minimization that I failed to understand

2025-03-28 Thread Duncan Murdoch
I haven't run your code, but since Kendall correlation is based on ranks, your Fn is probably locally constant with jumps when the ranks change. That's a really hard kind of function to maximize, and the algorithm used by fmincon is not appropriate to do it. Sorry, but I don't know if there i

Re: [R] Problem with minimization that I failed to understand

2025-03-27 Thread Daniel Lobo
The objective is to MAXIMIZE the Kendall Correlation. Given that ?pracma::fmincon minimizes the function, I added a negative sign in the objective function. Description Find minimum of multivariable functions with nonlinear constraints. Therefore we should not remove the negative sign. On Fri,

Re: [R] Problem with minimization that I failed to understand

2025-03-27 Thread Rui Barradas
Às 19:36 de 27/03/2025, Daniel Lobo escreveu: My code is to minimize the objective function therefore, shouldnt I expect that StartingValue = c(0.12, 0.04, 0.07, 0.03, 0.06, 0.07, 0.07, 0.04, 0.09, 0.08, 0.02, 0.02, 0.03, 0.06, 0.02, 0, 0.07, 0.05, 0.02, 0.02, 0.02) Fn(q1$par) < Fn(StartingValu

Re: [R] Problem with minimization that I failed to understand

2025-03-27 Thread Daniel Lobo
My code is to minimize the objective function therefore, shouldnt I expect that StartingValue = c(0.12, 0.04, 0.07, 0.03, 0.06, 0.07, 0.07, 0.04, 0.09, 0.08, 0.02, 0.02, 0.03, 0.06, 0.02, 0, 0.07, 0.05, 0.02, 0.02, 0.02) Fn(q1$par) < Fn(StartingValue) ## FALSE Below is the corrected code that ca

Re: [R] Problem with minimization that I failed to understand

2025-03-27 Thread Rui Barradas
Às 18:35 de 27/03/2025, Daniel Lobo escreveu: Hi, I have below minimization problem MyDat = structure(list(c(50L, 0L, 0L, 50L, 75L, 100L, 50L, 0L, 50L, 0L, 25L, 50L, 50L, 75L, 75L, 75L, 0L, 75L, 75L, 75L, 0L, 25L, 75L, 75L, 0L, 75L, 100L, 0L, 25L, 100L), c(75L, 0L, 0L, 50L, 100L, 50L, 75L, 75L