Attachment 'DetrendDataSet.m'
Download 1 function [Data,Tendance] = DetrendDataSet(Data,PolyOrder,VarLog,info)
2 % stephane.adjemian@ens.fr [03-09-2006]
3
4 T = size(Data,1);
5 k = size(Data,2);
6
7 if nargin <= 1
8 PolyOrder = 1;
9 VarLog = [];
10 end
11 if nargin <= 2
12 VarLog = [];
13 end
14
15 if nargin <=3
16 info = 0;
17 end
18
19 if ~isempty(VarLog)
20 Data(:,VarLog) = log(Data(:,VarLog));
21 end
22
23 X = zeros(T,PolyOrder+1);
24 order = 0;
25 while order <= PolyOrder
26 X(:,order+1) = transpose(1:T).^order;
27 order = order+1;
28 end
29 Y = Data(:,1);
30 Ahat = inv(X'*X)*X'*Y;
31 Resids = Y-X*Ahat;
32 Data(:,1) = Resids;
33 if k>= 2
34 Data(:,2:k) = Data(:,2:k)-X(:,2:PolyOrder+1)*Ahat(2:PolyOrder+1);
35 Data(:,2:k) = Data(:,2:k)-kron(mean(Data(:,2:k)),ones(T,1));
36 end
37 Tendance = exp(X*Ahat);
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.