我的问题类似于here,但其答案并没有真正解决我的问题。
dd <- structure(list(Score = c(0.00850444357692308, 0.020584329, 0.00850444357692308,
0.030544489, 0.020584329, 0.0351414854615385, 0.030544489, 0.040504648,
0.0351414854615385, 0.051128818, 0.040504648, 0.062416999, 0.051128818,
0.07436919, 0.062416999, 0.086985392, 0.07436919, 0.099601594,
0.086985392, 0.113545817, 0.099601594, 0.131474104, 0.113545817,
0.14940239, 0.131474104, 0.17065073, 0.14940239, 0.193891102,
0.17065073), Age = c(1, 2, 2, 3, 3, 4, 4, 5, 5, 11, 11, 14, 14,
16, 16, 23, 23, 26, 26, 31, 31, 44, 44, 46, 46, 53, 53, 56, 56
)), .Names = c("Score", "Age"), row.names = c("1", "2", "15",
"3", "21", "4", "32", "5", "41", "11", "51", "14", "6", "16",
"7", "23", "8", "26", "9", "31", "10", "44", "111", "46", "12",
"53", "13", "56", "141"), class = "data.frame")
plot(x = dd$Age, y = dd$Score, pch = 16)
lines(smooth.spline(dd$Age, dd$Score), lty = 2, col = "red")
lines(spline(dd$Age, dd$Score, method = "hyman", n = 56), lty = 2)
我的目标是通过我的数据(黑点)拟合平滑,单调增加的样条曲线。使用smooth.spline
给我一条非常流畅的肉眼线条(红色)。然而,它并不局限于单调增加(尽管在这种情况下)。为了解决单调性问题,我们转向spline
,我们可以在其中指定生成单调递增样条(黑色点缀)的方法,但很明显,它非常摇摆并且不像红色那样平滑。
我想要一个具有spline
(黑色点缀)单调递增特征的样条曲线,以及smooth.spline
(红色)的非摆动。
有没有办法设置smooth.spline
的参数,以便它总是单调增加?或者替代方法是使用某种形式的平滑参数,以便spline
能够提供更平滑的拟合?