3 %>@brief Spline decomposition
7 %> [X_after, x_after, Basis] =
11 %> <h3>References</h3>
12 %> [1] J. Ramsay, G. Hooker, and S. Graves, Functional Data Analysis with R and MATLAB. New York: Springer, 2009.
13 %> Function @c create_bspline_basis
14 %> [2] Jim Ramsay, B. W. Silverman. Functional Data Analysis. 2nd Ed. Springer. 2005.
21 function varargout =
splinedecomp(X, x, no_basis, breaks, order)
26 if ~exist(
'order',
'var')
29 if ~exist('breaks', 'var') || isempty(breaks)
30 breaks = linspace(1, nf, no_basis-order+2);
33 if ~exist('x', 'var') || isempty(x)
37 bb = create_bspline_basis([1, nf], no_basis, order, round(breaks));
39 % First makes a new x vector.
40 % It will contain the x-axis location where the splines peak
41 PREC = 1000; % This number only determines the precision and does not affect anything else.
42 tt2 = linspace(1, nf, PREC);
43 p = polyfit(tt, [data.fea_x], min(nf-1, 10)); % Gives a warning but who cares
45 basismat = eval_basis(tt2, bb); % bases
as columns
46 [vals, idxs] = max(basismat);
51 % We gotta get the loadings matrix
53 B = eval_basis(tt3, bb);
54 L = B*inv(B'*B); % L, the "loadings" matrix
63 varargout = {X, xx, B};
Analysis Session (AS) base class.
function splinedecomp(in X, in x, in no_basis, in breaks, in order)