I am interested in understanding how does the splines2
library from R
place the knots when computing periodic splines. I understand the logic when splines are not periodic, for example, I know that if the knots are not specified, the number of knots is equal to
$$knots = df - degree $$
where 'df' refers to the degrees of freedom of the spline basis, and 'degree' refers to the degree of the polinomial, and they are placed on the quantiles. For example:
library(splines2)
library(splines)
df = 8
degree = 3
x = seq(0, 1, length.out=15)
knots = seq(0, 1, length.out = df - degree + 2)
knots = knots[2:(length(knots)-1)]
# df - degree = length(knots)
spline_basis1 = splines2::mSpline(x, degree=degree, df=df)
spline_basis2 = splines2::mSpline(x, degree=degree, knots=knots)
spline_basis1
and spline_basis2
will return the same result. But if I consider periodic splines, this is no longer true:
# Periodic splines
spline_basis1 = splines2::mSpline(x, degree=degree, df=df, periodic=T)
spline_basis2 = splines2::mSpline(x, degree=degree, knots=knots, periodic=T)
My guess is that when computing periodic splines, the number of parameters to be estimated (the degrees of freedom) is different, but I would like to understand how are knots placed by default when splines are periodic.