Constraints for nls coefficients
问题 I'm trying to fit data with nls() function where the nature of data gives me bounds for one coefficient and for sum of two coefficients. Let me introduce short example to see where is the problem. I want parameter b1 to be between 0 and 1 and I want sum of parameters b1 and b2 to be between 0 and 1 as well. set.seed(123) # example where everything is OK x <- 1:200 g <- rbinom(200, 1, 0.5) y <- 3 + (0.7 + 0.2 * g) * x yeps <- y + rnorm(length(y), sd = 0.1) # both parameter b1 and sum of