我的数据如下:
df<-read.table (text=" cup size
12 30.76923077
13 38.46153846
14 53.84615385
15 76.92307692
16 92.30769231
17 100", header=TRUE)
我已经使用以下代码来获取结果
y=as.vector(df$cup)
x=as.vector(df$size)
fit <- nls(1/y ~ 1 + exp(-b*(x-c)), start = list(b = 0.01, c = 12), alg = "plinear")
我想分别提取值b,c,.lin 像这样:
b= 0.01552
c= 5.98258
lin= 0.04887
我使用过fit [[2]],但对我不起作用。
You can extract the coefficients using
coef
. So use然后,您可以使用向量索引来获取各个系数。
Within the
fit
object there are also functions to extract items: you can see these withstr(fit)
; for example , you could runfit$m$getPars()
to get the parameters of the model.