provisions for analytic 1st and 2nd derivatives
parent
4acd50bdaf
commit
bd26eb2251
|
@ -1,4 +1,4 @@
|
|||
function logged_prior_density = priordens(x, pshape, p6, p7, p3, p4,initialization)
|
||||
function [logged_prior_density, dlprior, d2lprior] = priordens(x, pshape, p6, p7, p3, p4,initialization)
|
||||
% Computes a prior density for the structural parameters of DSGE models
|
||||
%
|
||||
% INPUTS
|
||||
|
@ -81,6 +81,11 @@ if tt1
|
|||
if isinf(logged_prior_density)
|
||||
return
|
||||
end
|
||||
if nargout == 2,
|
||||
[tmp, dlprior(id1)]=lpdfgbeta(x(id1),p6(id1),p7(id1),p3(id1),p4(id1));
|
||||
elseif nargout == 3
|
||||
[tmp, dlprior(id1), d2lprior(id1)]=lpdfgbeta(x(id1),p6(id1),p7(id1),p3(id1),p4(id1));
|
||||
end
|
||||
end
|
||||
|
||||
if tt2
|
||||
|
@ -88,10 +93,20 @@ if tt2
|
|||
if isinf(logged_prior_density)
|
||||
return
|
||||
end
|
||||
if nargout == 2,
|
||||
[tmp, dlprior(id2)]=lpdfgam(x(id2)-p3(id2),p6(id2),p7(id2));
|
||||
elseif nargout == 3
|
||||
[tmp, dlprior(id2), d2lprior(id2)]=lpdfgam(x(id2)-p3(id2),p6(id2),p7(id2));
|
||||
end
|
||||
end
|
||||
|
||||
if tt3
|
||||
logged_prior_density = logged_prior_density + sum(lpdfnorm(x(id3),p6(id3),p7(id3))) ;
|
||||
if nargout == 2,
|
||||
[tmp, dlprior(id3)]=lpdfnorm(x(id3),p6(id3),p7(id3));
|
||||
elseif nargout == 3
|
||||
[tmp, dlprior(id3), d2lprior(id3)]=lpdfnorm(x(id3),p6(id3),p7(id3));
|
||||
end
|
||||
end
|
||||
|
||||
if tt4
|
||||
|
@ -99,6 +114,11 @@ if tt4
|
|||
if isinf(logged_prior_density)
|
||||
return
|
||||
end
|
||||
if nargout == 2,
|
||||
[tmp, dlprior(id4)]=lpdfig1(x(id4)-p3(id4),p6(id4),p7(id4));
|
||||
elseif nargout == 3
|
||||
[tmp, dlprior(id4), d2lprior(id4)]=lpdfig1(x(id4)-p3(id4),p6(id4),p7(id4));
|
||||
end
|
||||
end
|
||||
|
||||
if tt5
|
||||
|
@ -107,6 +127,12 @@ if tt5
|
|||
return
|
||||
end
|
||||
logged_prior_density = logged_prior_density + sum(log(1./(p4(id5)-p3(id5)))) ;
|
||||
if nargout >1,
|
||||
dlprior(id5)=zeros(length(id5),1);
|
||||
end
|
||||
if nargout == 3
|
||||
d2lprior(id5)=zeros(length(id5),1);
|
||||
end
|
||||
end
|
||||
|
||||
if tt6
|
||||
|
@ -114,4 +140,13 @@ if tt6
|
|||
if isinf(logged_prior_density)
|
||||
return
|
||||
end
|
||||
if nargout == 2,
|
||||
[tmp, dlprior(id6)]=lpdfig2(x(id6)-p3(id6),p6(id6),p7(id6));
|
||||
elseif nargout == 3
|
||||
[tmp, dlprior(id6), d2lprior(id6)]=lpdfig2(x(id6)-p3(id6),p6(id6),p7(id6));
|
||||
end
|
||||
end
|
||||
|
||||
if nargout==3,
|
||||
d2lprior = diag(d2lprior);
|
||||
end
|
Loading…
Reference in New Issue