-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTSAprojNaivePred.m
98 lines (71 loc) · 2.02 KB
/
TSAprojNaivePred.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
%% TSA Project naive estimators on val and test data
clear
clc
load('climate67.dat')
Mdldata=climate67(3400:5000,:);
Valdata=climate67(5001:5600,:);
Test1data=climate67(5601:5768,:);
Test2data=climate67(7501:7668,:);
meanY=mean(Mdldata(:,8));
y=climate67(1:7668,8); % All data up to and including Test2 in one vector
%% Naive 1 step prediction yhat(t+1|t)=y(t) on val. data
yhat=y(1:end-1); % This vector contains the 1-step predictions for y(2:end)
% Val.
peVal=y(5001:5600)-yhat(5000:5599);
figure(1)
plot(y(5001:5600))
hold on
plot(yhat(5000:5599));
hold off
legend('true y','naive 1-step pred')
title("Naive 1-step prediction on validation data");
VarVal=var(peVal)
meanVal=mean(peVal)
%% Naive 7-step val. data and test data, yhat(t+7|t)=y(t+7-24)
yhat=y(1:7644); % This vector contains the 7-step predictions yhat(25|18)...yhat(7668|7661)
% Val. data
peVal=y(5001:5600)-yhat(4977:5576);
figure(1)
plot(y(5001:5600))
hold on
plot(yhat(4977:5576));
hold off
legend('true y','naive 7-step pred')
title("Naive 7-step prediction on validation data");
VarVal=var(peVal) %=5.4563
meanVal=mean(peVal) %=-0.1633
% Test1
figure(2)
peTest1=y(5601:5768)-yhat(5577:5744);
plot(y(5601:5768))
hold on
plot(yhat(5577:5744));
hold off
legend('true y','naive 7-step pred')
title("Naive 7-step prediction on test1 data");
VarTest1=var(peTest1) %=1.8964
meanTest1=mean(peTest1) %=0.1817
% Test2
figure(3)
peTest2=y(7501:7668)-yhat(7477:7644);
plot(y(7501:7668))
hold on
plot(yhat(7477:7644));
hold off
legend('true y','naive 7-step pred')
title("Naive 7-step prediction on test2 data");
VarTest2=var(peTest2) % =3.7225
meanTest2=mean(peTest2) % =0.3704
%% Naive 26-step val. data data, yhat(t+26|t)=y(t+26-48)=y(t-22)
yhat=y(1:7620); % This vector contains the 7-step predictions yhat(49|23)...yhat(7668|7661)
% Val. data
peVal=y(5001:5600)-yhat(4953:5552);
figure(1)
plot(y(5001:5600))
hold on
plot(yhat(4953:5552));
hold off
legend('true y','naive 26-step pred')
title("Naive 26-step prediction on validation data");
VarVal=var(peVal)
meanVal=mean(peVal)