function [X] = gen_global_linear_seasonal_indicator_X(s,n) % GEN_GLOBAL_LINEAR_SEASONAL_INDICATOR - Gen(erate) Global Linear Seasonal Indicator design matrix X % % Input: % s : total number of seasons = seasonal indicators. % n : the number of data points % % Our assumed model is a globaly constant LINEAR model with "s" seasonal indicators: % % z_{t} = \beta_0 + \beta_1 t + \sum_{i=1}^{s-1} \delta_i \mathrm{IND}_{ti} + \varepsilon_{t} % % See the book by Abraham % % 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. % %----- % this requirement is not nessesary but makes the code below simpleer, since we don't have to deal with any remainder terms: if( mod(n,s)~=0 ) fprintf('we need n=%10d exactly divisable by s=%10d and n/s=%10.6f\n',n,s,n/s); X=[]; return; end % make blocks of size s x (s-1) representing the seasonal indicators IND = eye( s, s-1 ); ALL_IND = []; for t = 1:(n/s), ALL_IND = [ ALL_IND; IND ]; end % make the part of X due to the global linear piece TMP = [ ones(n,1), (1:n).' ]; % form the entire matrix of regressands X = [ TMP, ALL_IND ];