Reputation: 15
I'm trying to fit some data with a negative exponential model in R, but it doesn't seem to work and I can't find the error or a way to work around it.
t<-c(1,4,16)
y<-c(0.8,0.45,0.04)
tabla<-data.frame(t,y)
reg<-nls(y~exp(-b*t),tabla,start = list(t=0,b=0))
I get the following error after running the code
Error in qr(.swts * attr(rhs, "gradient")) :
dims [product 2] do not match the length of object [3]
In addition: Warning message:
In .swts * attr(rhs, "gradient") :
longer object length is not a multiple of shorter object length
Upvotes: 0
Views: 123
Reputation: 531
You are trying to estimate t
, when it is the independent variable in your formula
t<-c(1,4,16)
y<-c(0.8,0.45,0.04)
tabla<-data.frame(t,y)
reg<-nls(y~exp(-b*t),tabla,start = list(b=0))
This works fine
Upvotes: 1