[R] how to fit exponential curve such as a*b^t in r?
Berend Hasselman
bhh at xs4all.nl
Mon Dec 16 09:03:31 CET 2013
On 16-12-2013, at 08:52, 水静流深 <1248283536 at qq.com> wrote:
> input <- "
> t y
> 1 5.3
> 2 7.2
> 3 9.6
> 4 12.9
> 5 17.1
> 6 23.2"
> dat<-read.table(textConnection(input),header=TRUE,sep="")
> t<-dat[,1]
> y<-dat[,2]
>
> `y=3.975*(1.341^t)` is the resule of fit,how can i use `nls` function to get it?
Have you looked at ?nls.
Have you simply tried
nls(y~a*b^t,data=dat)
You can also do a linear regression on log(y) ~ A + B* t.
And afterwards transform to the original coefficients.
Berend
> [[alternative HTML version deleted]]
>
Please do not post in html.
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list