1

My question is similar to the one here, but its answers did not really address my concerns.

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)

enter image description here

My goal is to fit a smooth, monotonically increasing spline through my data (black dots). Using smooth.spline gives me a very smooth line to the naked eye (red). However, it's not constrained to be monotonically increasing (though it is in this case). To address the monotonicity issue, we turn to spline, in which we can specify the method to produce a monotonically increasing spline (dotted black), but clearly, it's very wiggly and not as smooth as the red.

I want a spline that has the monotonically increasing feature of spline (dotted black) but also the non-wiggliness of smooth.spline (red).

Is there a way to set the parameters for smooth.spline so that it'll always be monotonically increasing? Or the alternative is to play with some form of smoothing parameter so that spline will give a smoother fit?

Adrian
  • 9,229
  • 24
  • 74
  • 132

0 Answers0