如何计算出 R 中逻辑模型中渐近线出现的时间?

How to work out the time of when the asymptote occurs in a logistic model in R?

我已经使用 nls 函数在 R 中拟合逻辑增长模型。

pop.ss <- nls(MRDRSLT ~ SSlogis(TIME, phi1, phi2, phi3), data = testing, na.action = na.omit)

Formula: MRDRSLT ~ SSlogis(TIME, phi1, phi2, phi3)

Parameters:
      Estimate Std. Error t value Pr(>|t|)   
phi1   0.23179    0.03317   6.988  0.00602 **
phi2 431.16641   36.68846  11.752  0.00132 **
phi3  79.58386   29.09809   2.735  0.07164 . 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.01824 on 3 degrees of freedom

Number of iterations to convergence: 3 
Achieved convergence tolerance: 7.55e-06

PH1 是模型开始趋于平稳的增长率。有没有很容易找到发生这种情况的时间?

或者我是否需要存储系数并重新排列以使 t 成为主题?

让我们尝试通过使用我们自己的参数创建我们自己的逻辑曲线来澄清我们的想法。

我们将查看 1:100 的时间间隔,并使时间 = 50 成为我们曲线的中点。在 y 轴上,我们的曲线将从左侧的 0 开始,并在右侧的 20 处达到稳定状态。请注意,由于 logistic 曲线的形状,高原只会在时间 = 无穷大时“达到”。

我们还将添加一些随机噪声,这样我们就不会在 nls 拟合中出现奇点。

phi1  <- 20
phi2  <- 50
phi3  <- 0.1
TIME  <- 1:100

testing <- data.frame(
  TIME,
  MRDRSLT = phi1/(1 + exp(phi3 * (phi2 - TIME))) + rnorm(length(TIME))
)

plot(testing$TIME, testing$MRDRSLT)

这显然具有逻辑形状。现在让我们看看我们是否可以对这些参数进行逆向工程:

pop.ss <- nls(MRDRSLT ~ SSlogis(TIME, phi1, phi2, phi3), 
              data = testing, na.action = na.omit)

summary(pop.ss)
#> 
#> Formula: MRDRSLT ~ SSlogis(TIME, phi1, phi2, phi3)
#> 
#> Parameters:
#>      Estimate Std. Error t value Pr(>|t|)    
#> phi1  20.3840     0.2751   74.09   <2e-16 ***
#> phi2  50.0940     0.5863   85.45   <2e-16 ***
#> phi3  10.4841     0.4722   22.20   <2e-16 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Residual standard error: 1.057 on 97 degrees of freedom
#> 
#> Number of iterations to convergence: 0 
#> Achieved convergence tolerance: 4.528e-06

现在让我们绘制这些参数在数据上实际代表的内容:

plot(testing$TIME, testing$MRDRSLT)
abline(h = summary(pop.ss)$coef["phi1", 1], col = "red")
abline(v = summary(pop.ss)$coef["phi2", 1], col = "red")

我们可以看到phi1是上平台y的值,phi2是拐点出现的中点

现在,您正在寻找曲线“开始趋于平稳”的时间点。这是一个模糊的概念,但从技术上讲,曲线 开始 到平台的点是曲线的二阶导数变为负的点。这发生在拐点处,等于 phi2。曲线可能“看起来不像”它在那个点处处于稳定状态,但是您在曲线上选择的任何其他点来称为稳定状态的“开始”是完全任意的。

reprex package (v0.3.0)

于 2020-09-21 创建