or use nls.lm as in

install.packages("minpack.lm")
library(minpack.lm)

x <- c(2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 74)
y <- c(100, 99, 99, 98, 97, 94, 82, 66, 48, 38, 22, 10, 1)

res <- function(p, x, y) y - ff(p,x)
ff <- function(p, x) 100*exp(p[1]*(1-exp(p[2]*x))/p[2])
aa <- nls.lm(par=c(.0001,.0001), fn=res, x=x, y=y)

plot(x,y)
lines(x, ff(coef(aa), x))

On Tue, 12 May 2009, Jorge Ivan Velez wrote:

> Dear Dmitry,
> Take a look at ?nls and its examples.
>
> HTH,
>
> Jorge
>
>
> On Tue, May 12, 2009 at 5:44 PM, Dmitry Gospodaryov
> <gospodar...@rambler.ru>wrote:
>
> > I have the data:
> > for x: 2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 74,
> > for y: 100, 99, 99, 98, 97, 94, 82, 66, 48, 38, 22, 10, 1.
> > y depends on x by equation: y = 100*exp(b*(1-exp(c*x))/c),
> > where b and c are coefficients. I need to find coefficients in this
> > equation for given data. How can I do that by means of R?
> > Thank you for advance. With regard, Dmitry.
> >
> > ______________________________________________
> > R-help@r-project.org mailing list
> > 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.
> >
>
>       [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> 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.
>

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to