如何在 R 中拟合指数曲线,例如 A*B^T

  • 本文关键字:例如 曲线 指数 拟合 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)是适合的,如何使用nls函数来获取它?
也许问题是如何表达公式?

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

尝试

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

nls需要为每个参数提供一个良好的起点

相关内容

最新更新