function [X] = gen_global_linear_seasonal_trigonometric_X(s,m,n) % GEN_GLOBAL_LINEAR_SEASONAL_TRIGONOMETRIX - Gen(erate) Global Linear Seasonal Trigonometric design matrix X % % Input: % s : total number of seasons = seasonal indicators. % m : the number of trigonometric functions to consider % n : the number of data points % % Our assumed model is a globaly constant LINEAR model with "s" seasons and "m=s/2" trigonometric functions: % % z_{t} = \beta_0 + \beta_1 t + \sum_{i=1}^{m} \beta_{1i} \sin( f_i t ) + \beta_{2i} \cos( f_i t ) % % See page 150 in the book by Abraham. Note we assume that s is even. % % Written by: % -- % John L. Weatherwax 2009-06-01 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- if( mod(m,2)~=0 ) fprintf('we need m=%10d even\n',m); X=[]; return; end % make the part of X due to the trigonometric terms: f = (2*pi/s); fs_array = f * (1:m); t_array = (1:n).'; t_prod_f = t_array * fs_array; t_sin = sin( t_prod_f ); t_cos = cos( t_prod_f ); % make a matrix in the format of sin( f_i t ), cos( f_i t ), sin( f_{i+1} t ), cos( f_{i+1} t ) etc ... T1 = []; for jj=1:m, T1 = [ T1, t_sin(:,jj), t_cos(:,jj) ]; end % make the part of X due to the global linear piece T2 = [ ones(n,1), (1:n).' ]; % form the entire matrix of regressands X = [ T2, T1 ];