Skip to contents

N_1 = 1, N_2 = x, N_(k+2) = d_k - d_(K-1) with d_k = ((x - xi_k)+^3 - (x - xi_K)+^3) / (xi_K - xi_k) (ESL eqs 5.4-5.5); linear beyond the boundary knots.

Usage

morie_esl_natural_spline(x, knots)

Arguments

x

Evaluation points.

knots

At least three distinct knots.

Value

Named list: estimate (number of basis functions), basis (n by K), n_basis, knots, n.

References

Hastie, Tibshirani & Friedman (2009), sec. 5.2.1.

Examples

morie_esl_natural_spline(c(0.1, 0.35, 0.6, 0.9), c(0.2, 0.5, 0.8))$basis
#>      [,1] [,2]      [,3]
#> [1,]    1 0.10 0.0000000
#> [2,]    1 0.35 0.0056250
#> [3,]    1 0.60 0.1033333
#> [4,]    1 0.90 0.3600000