在 R 中使用 nls 函数时出错,无法获得 LS 估计
Error while using nls function in R, can't get LS estimates
我试图用 R 中的负指数模型拟合一些数据,但它似乎不起作用,我找不到错误或解决方法。
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))
我在 运行 代码
之后得到以下错误
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
您正在尝试估计 t
,而它是您公式中的自变量
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))
这个很好用
我试图用 R 中的负指数模型拟合一些数据,但它似乎不起作用,我找不到错误或解决方法。
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))
我在 运行 代码
之后得到以下错误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
您正在尝试估计 t
,而它是您公式中的自变量
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))
这个很好用