Re: [R] Optimisation with Normalisation Constraint

2018-06-22 Thread Hans W Borchers
One way will be to solve this as an ordinary optimization problem with an equality constraint. Function `alabama::auglag` can do this: library(alabama) fn <- function(p) sum((df$y - p[1]*exp(-p[2]*df$x))^2) heq <- function(p) sum(p[1]*exp(-p[2]*df$x)) - 5 # Start with initial

Re: [R] Optimisation with Normalisation Constraint

2018-06-20 Thread David Winsemius
> On Jun 20, 2018, at 8:50 AM, Lorenzo Isella wrote: > > Dear All, > I have a problem I haver been struggling with for a while: I need to > carry out a non-linear fit (and this is the > easy part). > I have a set of discrete values {x1,x2...xN} and the corresponding > {y1, y2...yN}. The

Re: [R] Optimisation with Normalisation Constraint

2018-06-20 Thread Jeff Newmiller
I recommend posting this on a mathematics discussion forum like Stack Exchange and (re-)reading the Posting Guide for this mailing list. I think you are going to need to re-write your model function to algebraically combine your original model along with the constraint, and then use the

[R] Optimisation with Normalisation Constraint

2018-06-20 Thread Lorenzo Isella
Dear All, I have a problem I haver been struggling with for a while: I need to carry out a non-linear fit (and this is the easy part). I have a set of discrete values {x1,x2...xN} and the corresponding {y1, y2...yN}. The difficulty is that I would like the linear fit to preserve the sum of the