-
Notifications
You must be signed in to change notification settings - Fork 8
/
displayResults.m
172 lines (152 loc) · 5.32 KB
/
displayResults.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
%Displays and plots the results as well as some convergence diagnostics
cumsums = cumsum(ones(1,settings.draws));
disp('Unconditional Posterior Estimates AR Coefficients')
for i = 1:settings.pMax
disp(['Order: ', num2str(i)]);
if i <= size(arParametersSeries,1)
temp=arParametersSeries(i,:);
if settings.doPlots
figure;
temp2 = temp;
temp2(isnan(temp2))= 0;
plot(cumsum(temp2) ./ cumsums);
title(['Unconditional Recursive Mean AR Parameter ' num2str(i)]);
end;
temp = temp(settings.burnIn+1:end);
disp(['Mean: ' num2str(mean(temp(isfinite(temp)==1)))]);
disp(['Median: ' num2str(median(temp(isfinite(temp)==1)))]);
else
disp('NaN');
end;
end;
disp('Unconditional Posterior Estimates MA Coefficients')
for i = 1:settings.qMax
disp(['Order: ', num2str(i)]);
if i <= size(maParametersSeries,1)
temp=maParametersSeries(i,:);
if settings.doPlots
figure;
temp2 = temp;
temp2(isnan(temp2))= 0;
plot(cumsum(temp2) ./ cumsums);
title(['Unconditional Recursive Mean MA Parameter ' num2str(i)]);
end;
temp = temp(settings.burnIn+1:end);
disp(['Mean: ' num2str(mean(temp(isfinite(temp)==1)))]);
disp(['Median: ' num2str(median(temp(isfinite(temp)==1)))]);
else
disp('NaN');
end;
end;
disp('Unconditional Mean and Median Sigma');
if settings.doPlots
figure;
plot(cumsum(transpose(sigmaESeries)) ./ cumsums);
title(['Unconditional Recursive Mean Sigma']);
end;
disp(['Mean: ' num2str(mean(sigmaESeries(settings.burnIn+1:end)))]);
disp(['Median: ' num2str(median(sigmaESeries(settings.burnIn+1:end)))]);
pqMatrix = [pSeries(settings.burnIn+1:end) qSeries(settings.burnIn+1:end)];
x = 0:1:settings.pMax;
z = 0:1:settings.qMax;
bintest = cell(1);
bintest{1} = x;
bintest{2} = z;
[nelements, centers] = hist3(pqMatrix,'Edges',bintest);
[maxPQ, ind] = max(nelements(:));
[m,n] = ind2sub(size(nelements),ind);
pPostMax = m-1;
qPostMax = n-1;
pqSieve = ((pqMatrix(:,1) == pPostMax) & (pqMatrix(:,2) == qPostMax));
disp('Conditional Means and Medians AR');
for i = 1:settings.pMax
disp(['Order: ', num2str(i)]);
if i <= size(arParametersSeries,1)
temp=arParametersSeries(i,settings.burnIn+1:end);
if settings.doPlots && (i <= pPostMax)
figure;
plot(transpose(cumsum(temp(pqSieve))) ./ cumsum(pqSieve(pqSieve == 1)));
title(['Conditional Recursive Mean AR Parameter ' num2str(i)]);
end;
temp = temp(pqSieve);
disp(['Mean: ' num2str(mean(temp))]);
disp(['Median: ' num2str(median(temp))]);
else
disp('NaN');
end;
end;
disp('Conditional Means and Medians MA');
for i = 1:settings.qMax
disp(['Order: ', num2str(i)]);
if i <= size(maParametersSeries,1)
temp=maParametersSeries(i,settings.burnIn+1:end);
if settings.doPlots && (i <= qPostMax)
figure;
plot(transpose(cumsum(temp(pqSieve))) ./ cumsum(pqSieve(pqSieve == 1)));
title(['Conditional Recursive Mean MA Parameter ' num2str(i)]);
end;
temp = temp(pqSieve);
disp(['Mean: ' num2str(mean(temp))]);
disp(['Median: ' num2str(median(temp))]);
else
disp('NaN');
end;
end;
disp('Conditional Mean and Median Sigma');
temp = sigmaESeries(settings.burnIn+1:end);
if settings.doPlots
figure;
plot(cumsum(temp(pqSieve)) ./ cumsum(pqSieve(pqSieve == 1)));
title(['Conditional Recursive Mean Sigma']);
end;
temp = temp(pqSieve);
disp(['Mean: ' num2str(mean(temp))]);
disp(['Median: ' num2str(median(temp))]);
x = 0:1:settings.pMax;
z = 0:1:settings.qMax;
figure;
hist(pSeries(settings.burnIn:end),x);
figure;
hist(qSeries(settings.burnIn:end),z);
figure;
bintest = cell(1);
bintest{1} = x;
bintest{2} = z;
hist3(pqMatrix,'Edges',bintest);
if settings.priorPosteriorPlots && settings.doPlots
%plot Prior vs ConditionalPosterior
arPacsSeriesCropped = arPacsSeries(:,settings.burnIn+1:end);
arPacsSeriesCropped = arPacsSeriesCropped(:,pqSieve);
for cntr = 1: pPostMax
figure; hold on;
temp = arPacsSeriesCropped(cntr,:);
% temp = temp(pqSieve);
[f, xi] = ksdensity(temp);
plot(xi,f,'k','LineWidth',1.5);
ezplot(@(x) settings.priorsARMA.priorAR(x),[-1.1,1.1]);
title(['AR PAC ' num2str(cntr)]);
axis('auto');
legend('Conditional Posterior','Prior');
end;
maPacsSeriesCropped = maPacsSeries(:,settings.burnIn+1:end);
maPacsSeriesCropped = maPacsSeriesCropped(:,pqSieve);
for cntr = 1:qPostMax
figure; hold on;
temp = maPacsSeriesCropped(cntr,:);
% temp = temp(pqSieve);
[f, xi] = ksdensity(temp);
plot(xi,f,'k','LineWidth',1.5);
ezplot(@(x) settings.priorsARMA.priorMA(x),[-1.1,1.1]);
title(['MA PAC ' num2str(cntr)]);
legend('Conditional Posterior','Prior');
end;
temp = sigmaESeries(settings.burnIn+1:end);
temp = temp(pqSieve);
figure;
hold on;
[f, xi] = ksdensity(temp);
plot(xi,f,'k','LineWidth',1.5);
ezplot(@(x) settings.priorsARMA.priorSigmaE(x),[-0.1,max(temp)+1]);
title(['\sigma_\epsilon']);
legend('Conditional Posterior','Prior');
end;