如何在 R 中对 y = a*(1- exp(-b*t) 进行指数曲线拟合

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

我有时间序列数据,其中值随着时间(t)增加然后变得稳定:我想拟合一条指数曲线 NPQ_Lss = a*(1- exp(-b*t)。稍后我想比较拟合的曲线群体(P1 和 P2)之间的曲线,以确定它们是否显着不同。

我怎样才能在 R 中做到这一点?我了解我的数据点很少的限制。

我的数据如下所示:

t NPQ_Lss 人口
-2 1.777 P2
0 2.224 P2
3 2.492 P2
5 2.384 P2
7 2.407 P2
-2 1.719 P1
0 2.191 P1
3 2.418 P1
5 2.303 P1
7 2.403 P1

谢谢!

我对任何建模都是新手。

r exponential nls
1个回答
0
投票

假设最后的注释中显示的数据可重复显示,请使用单独的参数拟合每个数据,然后使用相同的参数拟合两个数据,然后进行方差分析。它给出的 P 值为 0.998,这并不显着,因此我们可以对两者使用相同的参数。

# separate parameters
DF$Population <- factor(DF$Population)
fo1 <- NPQ_Lss ~ a[Population]*(1 - exp(-b[Population]*t))
fm1 <- nls(fo2, DF, start = list(a = c(-2, -2), b = c(-0.2, -0.2)))

# same parameters
fo2 <- NPQ_Lss ~ cbind(a = (1 - exp(-b*t)))
fm2 <- nls(fo, DF, start = list(b = -0.2), alg = "plinear")

anova(fm2, fm1)

## Analysis of Variance Table
##
## Model 1: NPQ_Lss ~ cbind(a = (1 - exp(-b * t)))
## Model 2: NPQ_Lss ~ a[Population] * (1 - exp(-b[Population] * t))
##   Res.Df Res.Sum Sq Df   Sum Sq F value Pr(>F)
## 1      8     25.136                           
## 2      6     25.134  2 0.001791   2e-04 0.9998

注意

DF <- data.frame(
  t = rep(c(-2L, 0L, 3L, 5L, 7L), 2),
  NPQ_Lss = c(1.777, 2.224, 2.492, 2.384, 2.407, 1.719, 2.191, 2.418, 2.303, 2.403),
  Population = rep(c("P2", "P1"), each = 5L)
)
© www.soinside.com 2019 - 2024. All rights reserved.