Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Dynare
dynare
Commits
82aa669b
Verified
Commit
82aa669b
authored
Jan 22, 2021
by
Johannes Pfeifer
Committed by
Stéphane Adjemian
Jan 23, 2021
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prior densities: make sure derivative output has correct dimensions
parent
2b7dbff4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
13 deletions
+29
-13
matlab/lpdfgam.m
matlab/lpdfgam.m
+6
-3
matlab/lpdfgbeta.m
matlab/lpdfgbeta.m
+7
-3
matlab/lpdfig1.m
matlab/lpdfig1.m
+5
-1
matlab/lpdfig2.m
matlab/lpdfig2.m
+5
-1
matlab/lpdfnorm.m
matlab/lpdfnorm.m
+4
-3
matlab/priordens.m
matlab/priordens.m
+2
-2
No files found.
matlab/lpdfgam.m
View file @
82aa669b
...
...
@@ -7,13 +7,14 @@ function [ldens,Dldens,D2ldens] = lpdfgam(x,a,b)
% b [double] m*n matrix or scalar, Second GAMMA distribution parameters (scale),
%
% OUTPUTS
% ldens [double] m*n matrix of logged GAMMA densities evaluated at x.
%
% ldens [double] m*n matrix of logged GAMMA densities evaluated at x.
% Dldens [double] m*n matrix of first derivatives of logged GAMMA densities.
% D2ldens [double] m*n matrix of second derivatives of logged matrix of logged GAMMA densities.
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2003-201
7
Dynare Team
% Copyright (C) 2003-20
2
1 Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -42,6 +43,7 @@ end
if
nargout
>
1
Dldens
=
ldens
;
if
length
(
a
)
==
1
Dldens
(
idx
)
=
(
a
-
1
)
.
/(
x
(
idx
))
-
ones
(
length
(
idx
),
1
)/
b
;
else
...
...
@@ -50,6 +52,7 @@ if nargout >1
end
if
nargout
==
3
D2ldens
=
ldens
;
if
length
(
a
)
==
1
D2ldens
(
idx
)
=
-
(
a
-
1
)
.
/(
x
(
idx
))
.^
2
;
else
...
...
matlab/lpdfgbeta.m
View file @
82aa669b
...
...
@@ -2,19 +2,21 @@ function [ldens,Dldens,D2ldens] = lpdfgbeta(x,a,b,aa,bb)
% Evaluates the logged BETA PDF at x.
%
% INPUTS
% x [double] m*n matrix of lo
a
ctions,
% x [double] m*n matrix of loc
a
tions,
% a [double] m*n matrix of First BETA distribution parameters,
% b [double] m*n matrix of Second BETA distribution parameters,
% aa [double] m*n matrix of lower bounds for (generalized) distribution,
% bb [double] m*n matrix of upper bounds for (generalized) distribution
%
% OUTPUTS
% ldens [double] m*n matrix of logged (generalized) BETA densities.
% ldens [double] m*n matrix of logged (generalized) BETA densities.
% Dldens [double] m*n matrix of first derivatives of logged (generalized) BETA densities.
% D2ldens [double] m*n matrix of second derivatives of logged matrix of logged (generalized) BETA densities.
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2003-201
7
Dynare Team
% Copyright (C) 2003-20
2
1 Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -42,6 +44,7 @@ end
if
nargout
>
1
Dldens
=
ldens
;
if
length
(
a
)
==
1
Dldens
(
idx
)
=
(
a
-
1
)
.
/(
x
(
idx
)
-
aa
)
-
(
b
-
1
)
.
/(
bb
-
x
(
idx
))
;
else
...
...
@@ -51,6 +54,7 @@ end
if
nargout
==
3
D2ldens
=
ldens
;
if
length
(
a
)
==
1
D2ldens
(
idx
)
=
-
(
a
-
1
)
.
/(
x
(
idx
)
-
aa
)
.^
2
-
(
b
-
1
)
.
/(
bb
-
x
(
idx
))
.^
2
;
else
...
...
matlab/lpdfig1.m
View file @
82aa669b
...
...
@@ -13,11 +13,13 @@ function [ldens,Dldens,D2ldens] = lpdfig1(x,s,nu)
%
% OUTPUTS
% ldens [double] m*n matrix of logged INVERSE-GAMMA-1 densities evaluated at x.
% Dldens [double] m*n matrix of first derivatives of logged INVERSE-GAMMA-1 densities.
% D2ldens [double] m*n matrix of second derivatives of logged matrix of logged INVERSE-GAMMA-1 densities.
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2004-201
7
Dynare Team
% Copyright (C) 2004-20
2
1 Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -44,6 +46,7 @@ else
end
if
nargout
>
1
Dldens
=
ldens
;
if
length
(
s
)
==
1
Dldens
(
idx
)
=
-
(
nu
+
1
)
.
/(
x
(
idx
))
+
s
.
/(
x
(
idx
)
.^
3
)
;
else
...
...
@@ -52,6 +55,7 @@ if nargout >1
end
if
nargout
==
3
D2ldens
=
ldens
;
if
length
(
s
)
==
1
D2ldens
(
idx
)
=
(
nu
+
1
)
.
/(
x
(
idx
)
.^
2
)
-
3
*
s
(
idx
)
.
/(
x
(
idx
)
.^
4
)
;
else
...
...
matlab/lpdfig2.m
View file @
82aa669b
...
...
@@ -13,11 +13,13 @@ function [ldens,Dldens,D2ldens] = lpdfig2(x,s,nu)
%
% OUTPUTS
% ldens [double] m*n matrix of logged INVERSE-GAMMA-2 densities evaluated at x.
% Dldens [double] m*n matrix of first derivatives of logged INVERSE-GAMMA-2 densities.
% D2ldens [double] m*n matrix of second derivatives of logged matrix of logged INVERSE-GAMMA-2 densities.
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2004-201
7
Dynare Team
% Copyright (C) 2004-20
2
1 Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -44,6 +46,7 @@ else
end
if
nargout
>
1
Dldens
=
ldens
;
if
length
(
s
)
==
1
Dldens
(
idx
)
=
-
.
5
*
(
nu
+
2
)
.
/(
x
(
idx
))
+
.
5
*
s
.
/
x
(
idx
)
.^
2
;
else
...
...
@@ -52,6 +55,7 @@ if nargout >1
end
if
nargout
==
3
D2ldens
=
ldens
;
if
length
(
s
)
==
1
D2ldens
(
idx
)
=
.
5
*
(
nu
+
2
)
.
/(
x
(
idx
))
.^
2
-
s
.
/
x
(
idx
)
.^
3
;
else
...
...
matlab/lpdfnorm.m
View file @
82aa669b
...
...
@@ -7,13 +7,14 @@ function [ldens,Dldens,D2ldens] = lpdfnorm(x,a,b)
% b [double] m*n matrix or scalar, Second GAUSSIAN distribution parameters (standard deviation).
%
% OUTPUTS
% ldens [double] m*n matrix of logged GAUSSIAN densities evaluated at x.
%
% ldens [double] m*n matrix of logged GAUSSIAN densities evaluated at x.
% Dldens [double] m*n matrix of first derivatives of logged GAUSSIAN densities.
% D2ldens [double] m*n matrix of second derivatives of logged matrix of GAUSSIAN densities.
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2003-201
7
Dynare Team
% Copyright (C) 2003-20
2
1 Dynare Team
%
% This file is part of Dynare.
%
...
...
matlab/priordens.m
View file @
82aa669b
...
...
@@ -83,8 +83,8 @@ if nargin > 6 && initialization
end
logged_prior_density
=
0.0
;
dlprior
=
0.0
;
d2lprior
=
0.0
;
dlprior
=
zeros
(
1
,
length
(
x
))
;
d2lprior
=
dlprior
;
if
tt1
logged_prior_density
=
logged_prior_density
+
sum
(
lpdfgbeta
(
x
(
id1
),
p6
(
id1
),
p7
(
id1
),
p3
(
id1
),
p4
(
id1
)))
;
...
...
Johannes Pfeifer
@JohannesPfeifer
mentioned in commit
e23793a4
·
Jan 23, 2021
mentioned in commit
e23793a4
mentioned in commit e23793a4b8d20b6e0aee7e0d1f4992a32ca3bf96
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment