On Fri, 31 Dec 2021 07:59:11 +0000 PIKAL Petr <petr.pi...@precheza.cz> wrote:
> x <- (0:100)/100 > y1 <- dnorm((x, mean=.3, sd=.1) > y2 <- dnorm((x, mean=.7, sd=.1) > ymix <- ((y1+2*y2)/max(y1+2*y2)) > My question is if there is some package or function which could get > those values ***directly from x and ymix values***, which is > basically what is measured in my case. Apologies if I'm missing something, but, this being a peak fitting problem, shouldn't nls() (or something from the minpack.lm or nlsr packages) work for you here? minpack.lm::nlsLM( ymix ~ a1 * dnorm(x, mu1, sigma1) + a2 * dnorm(x, mu2, sigma2), start = c(a1 = 1, mu1 = 0, sigma1 = 1, a2 = 1, mu2 = 1, sigma2 = 1), lower = rep(0, 6) # help minpack avoid NaNs ) # Nonlinear regression model # model: ymix ~ a1 * dnorm(x, mu1, sigma1) + a2 * dnorm(x, mu2, sigma2) # data: parent.frame() # a1 mu1 sigma1 a2 mu2 sigma2 # 0.1253 0.3000 0.1000 0.2506 0.7000 0.1000 # residual sum-of-squares: 1.289e-31 # # Number of iterations to convergence: 23 # Achieved convergence tolerance: 1.49e-08 (Some nonlinear least squares problems will be much harder to solve though.) -- Best regards, Ivan ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.