-
Notifications
You must be signed in to change notification settings - Fork 8
/
evaluatePrior.m
36 lines (34 loc) · 1.35 KB
/
evaluatePrior.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
function [priorValue] = evaluatePrior(state, settings)
priorValue = 0;
if state.ps > 0 %Only evaluate if at least one AR lag exists
priorAR = settings.priorsARMA.priorAR(state.arPacs);
if settings.priorsARMA.isLog
priorValue = priorValue + sum(priorAR);
else
priorValue = priorValue + sum(log(priorAR));
end;
end;
if state.qs > 0 %Only evaluate if at least one MA lag exists
priorMA = settings.priorsARMA.priorMA(state.maPacs);
if settings.priorsARMA.isLog
priorValue = priorValue + sum(priorMA);
else
priorValue = priorValue + sum(log(priorMA));
end;
end;
if settings.priorsARMA.isLog
priorValue = priorValue + ...
settings.priorsARMA.priorP(state.ps);
priorValue = priorValue + ...
settings.priorsARMA.priorQ(state.qs);
priorValue = priorValue + ...
settings.priorsARMA.priorSigmaE(state.sigmaEs);
else
priorValue = priorValue + ...
log(settings.priorsARMA.priorP(state.ps));
priorValue = priorValue + ...
log(settings.priorsARMA.priorQ(state.qs));
priorValue = priorValue + ...
log(settings.priorsARMA.priorSigmaE(state.sigmaEs));
end;
end