[R] How to find a split point in a curve?

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Thu May 14 17:12:08 CEST 2020


Dear all,
I am trying to find a turning point in some data. In the initial phase, the
data increases more or less exponentially (thus it is linear in a nat log
transform), then reaches a plateau. I would like to find the point that
marks the end of the exponential phase.
I understand that the function spline can build a curve; is it possible
with it to find the turning points? I have no idea of how to use spline
though.
Here is a working example.
Thank you

```
Y = c(259, 716, 1404, 2173, 3944, 5403, 7140, 9121,
      11220, 13809, 16634, 19869, 23753, 27447,
      30590, 33975, 36627, 39600, 42067, 44082,
      58190, 63280, 65921, 67929, 69977, 71865,
      73614, 74005, 74894, 75717, 76365, 76579,
      77087, 77493, 77926, 78253, 78680, 79253,
      79455, 79580, 79699, 79838, 79981, 80080,
      80124, 80164, 80183, 80207, 80222, 80230,
      80241, 80261, 80261, 80277, 80290, 80303,
      80337, 80376, 80422, 80461, 80539, 80586,
      80653, 80708, 80762, 80807, 80807, 80886,
      80922, 80957, 80988, 81007, 81037, 81076,
      81108, 81108, 81171, 81213, 81259, 81358,
      81466, 81555, 81601, 81647, 81673, 81998,
      82025, 82041, 82053, 82064, 82094, 82104,
      82110, 82122, 82133, 82136, 82142, 82164,
      82168, 82180, 82181, 82184, 82187, 82188,
      82190, 82192, 82193, 82194)
Y = log(Y)
X = 1:length(Y)
plot(Y ~ X, ylab = "Ln(Y)", xlim=c(0,10, main="zoomed in"))
abline(lm(Y[1:3] ~ X[1:3]))
abline(lm(Y[1:5] ~ X[1:5]), lty=2)
text(7, 6, "After third or fifth point, there is deviance", pos=3)
text(2.5, 10, "Solid line: linear model points 1:3", pos =3)
text(2.5, 9, "Dashed line: linear model points 1:5", pos =3)
plot(Y ~ X, ylab = "Ln(Y)", xlim=c(0,10, main="overall"))
abline(lm(Y[1:3] ~ X[1:3]))
```

	[[alternative HTML version deleted]]



More information about the R-help mailing list