showkey
showkey

Reputation: 298

how to fit exponential curve such as a*b^t in r?

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?
maybe the problem is how to express the formula?

nls(y~(a*b^t))
Error in getInitial.default(func, data, mCall = as.list(match.call(func,  : 
no 'getInitial' method found for "function" objects

Upvotes: 0

Views: 953

Answers (1)

J&#246;rg M&#228;der
J&#246;rg M&#228;der

Reputation: 677

Try

nls(y~(a*b^t),start=c(a=4,b=1))

nls needs a good starting point for each parameter

Upvotes: 2

Related Questions