Build a standardised P-Spline design matrix and the associated P-Spline penalty matrix
Build a standardised P-Spline design matrix and the associated P-Spline penalty matrix
This function builds the B-spline design matrix for a given data vector. Importantly, the B-spline basis functions are normalised such that the integral of each basis function is 1, hence this basis can be used for spline-based density estimation, when the basis functions are weighted by non-negative weights summing to one.
type: type of the data, either "real" for data on the reals, "positive" for data on the positive reals or "circular" for circular data like angles.
degree: degree of the B-spline basis functions, defaults to cubic B-splines
npoints: number of points used in the numerical integration for normalizing the B-spline basis functions
diff_order: order of differencing used for the P-Spline penalty matrix for each data stream. Defaults to second-order differences.
pow: power for polynomial knot spacing
Such non-equidistant knot spacing is only used for type = "positive".
Returns
list containing the design matrix Z, the penalty matrix S, the prediction design matrix Z_predict, the prediction grid xseq, and details for the basis expansion.
Examples
modmat = make_matrices_dens(x =(-50):50, k =20)modmat = make_matrices_dens(x =1:100, k =20, type ="positive")modmat = make_matrices_dens(x = seq(-pi,pi), k =20, type ="circular")