According to this post, https://www.rdocumentation.org/packages/splines/versions/3.6.2/topics/ns, "These enforce the constraint that the function is linear beyond the boundary knots, which can either be supplied or default to the extremes of the data." However, when I tried to use the spline::ns() function I found that there is no linear part of the spline beyond the boundary knots. I also looked up this post Interpreting spline results and found that beyond the boundary knots(200 and 800 respectively), the natural cubic spline is not linear either. Could you help explain the reasons? Also, could you help explain what each of the 4 column mean in the natural spline below? x <- 1:1000 n <- ns(x, knots=c(200, 500, 800)) Thanks
Asked
Active
Viewed 110 times
spline:ns(). Indeed, it seems to behave exactly as described. Demonstration:x <- seq(0, 1, length.out = 101); pairs(cbind(x, splines::ns(x, df = 4, Boundary.knots = c(0.2, 0.8))), verInd = 1)This plot of the four components of a spline exhibits linear behavior in both tails for all components. For more information, please read the help page for this function. (This example might also help you understand some issues raised in your previous question: it shows how each spline component varies continuously.) – whuber Jan 04 '23 at 15:33