估计非单调双指数曲线拟合

问题描述 投票:0回答:1

我正在做一些药代动力学分析,并且对非房室方法没问题。但我也尝试学习一些非线性曲线拟合技术。

如果我们有以下数据:

df <-  data.frame(x = c(0,2,4,8,12,24,48,72), y = c(0.000,0.05,0.0671,0.068,0.05,0.0250,0.0103,0.0043))
plot(df$x, df$y)

enter image description here

我想按照本书第579页所述,使用下面突出显示的方程来拟合一条非单调双指数曲线:

enter image description here

我对标准双指数形式很满意,并使用

Sbiexp
查找起始值,但不知道如何找到该方程的起始值。有人可以给我一些指点吗?

> nls_mod_bi <-  nls(y ~ k * (exp(-b1*x) - exp(-b2*x)), start = c(k = 1, b1 = 1, b2 = 1), data = df)
Error in nlsModel(formula, mf, start, wts, scaleOffset = scOff, nDcentral = nDcntr) : 
  singular gradient matrix at initial parameter estimates
r non-linear-regression nls non-linear
1个回答
0
投票

我认为你可以在

SSbiexp
 中使用 
nls

fit <- nls(y ~ SSbiexp(x, k1, b1, k2, b2), data = df)

f <- function(x, p = coef(fit)) {
  p["k1"] * exp(-exp(p["b1"]) * x) + p["k2"] * exp(-exp(p["b2"]) * x)
}

plot(y ~ x, df, type = "p", col = "blue")
curve(f, range(df$x), col = "red", add = TRUE)

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.