Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dynare
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Frédéric Karamé
dynare
Commits
a0e1d3b3
Commit
a0e1d3b3
authored
13 years ago
by
Stéphane Adjemian
Browse files
Options
Downloads
Patches
Plain Diff
Fixed bugs + cosmetic changes.
parent
16d2fd56
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
matlab/distributions/ig1fun.m
+1
-1
1 addition, 1 deletion
matlab/distributions/ig1fun.m
matlab/distributions/inverse_gamma_specification.m
+19
-7
19 additions, 7 deletions
matlab/distributions/inverse_gamma_specification.m
with
20 additions
and
8 deletions
matlab/distributions/ig1fun.m
+
1
−
1
View file @
a0e1d3b3
...
@@ -16,4 +16,4 @@ function err = ig1fun(nu,mu2,sigma2)
...
@@ -16,4 +16,4 @@ function err = ig1fun(nu,mu2,sigma2)
% You should have received a copy of the GNU General Public License
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
err
=
2
*
mu2
*
gamma
(
nu
/
2
)
.^
2
-
(
sigma2
+
mu2
)
*
(
nu
-
2
)
.*
gamma
((
nu
-
1
)/
2
)
.^
2
;
err
=
log
(
2
*
mu2
)
-
log
((
sigma2
+
mu2
)
*
(
nu
-
2
))
+
2
*
(
gammaln
(
nu
/
2
)
-
gammaln
((
nu
-
1
)/
2
)
);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
matlab/distributions/inverse_gamma_specification.m
+
19
−
7
View file @
a0e1d3b3
...
@@ -35,6 +35,11 @@ function [s,nu] = inverse_gamma_specification(mu,sigma,type,use_fzero_flag)
...
@@ -35,6 +35,11 @@ function [s,nu] = inverse_gamma_specification(mu,sigma,type,use_fzero_flag)
%!
@ref
{
set_prior
}
%!
@ref
{
set_prior
}
%!
@sp
2
%!
@sp
2
%!
@strong
{
This
function
calls
:
}
%!
@strong
{
This
function
calls
:
}
%!
@sp
2
%!
@strong
{
Remark
:
}
%!
The
call
to
the
matlab
'
s
implementation
of
the
secant
method
is
here
for
testing
purpose
and
should
not
be
used
.
This
routine
fails
%!
more
often
in
finding
an
interval
for
nu
containing
a
signe
change
because
it
expands
the
interval
on
both
sides
and
eventually
%!
violates
the
condition
nu
>
2
.
%!
%!
%!
@end
deftypefn
%!
@end
deftypefn
%
@eod
:
%
@eod
:
...
@@ -77,10 +82,9 @@ elseif type == 1; % Inverse Gamma 1
...
@@ -77,10 +82,9 @@ elseif type == 1; % Inverse Gamma 1
nu2
=
2
*
nu
;
nu2
=
2
*
nu
;
nu1
=
2
;
nu1
=
2
;
err
=
ig1fun
(
nu
,
mu2
,
sigma2
);
err
=
ig1fun
(
nu
,
mu2
,
sigma2
);
err1
=
ig1fun
(
nu1
,
mu2
,
sigma2
);
err2
=
ig1fun
(
nu2
,
mu2
,
sigma2
);
err2
=
ig1fun
(
nu2
,
mu2
,
sigma2
);
if
sign
(
err2
)
%
Too
short
interval
.
if
err2
>
0
%
Too
short
interval
.
while
nu2
/
nu
<
10
00
%
Shift
the
interval
contai
o
ning
the
root
.
while
nu2
<
5
00
%
Shift
the
interval
containing
the
root
.
nu1
=
nu2
;
nu1
=
nu2
;
nu2
=
nu2
*
1
.
01
;
nu2
=
nu2
*
1
.
01
;
err2
=
ig1fun
(
nu2
,
mu2
,
sigma2
);
err2
=
ig1fun
(
nu2
,
mu2
,
sigma2
);
...
@@ -88,6 +92,9 @@ elseif type == 1; % Inverse Gamma 1
...
@@ -88,6 +92,9 @@ elseif type == 1; % Inverse Gamma 1
break
break
end
end
end
end
if
err2
>
0
error
(
'
inverse_gamma_specification
::
Failed
in
finding
an
interval
containing
a
sign
change
!
You
should
check
that
the
prior
variance
is
not
too
small
compared
to
the
prior
mean
...
'
);
end
end
end
%
Sove
for
nu
using
the
secant
method
.
%
Sove
for
nu
using
the
secant
method
.
while
abs
(
nu2
-
nu1
)
>
1e-14
while
abs
(
nu2
-
nu1
)
>
1e-14
...
@@ -126,11 +133,16 @@ end
...
@@ -126,11 +133,16 @@ end
%
@test
:
1
%
@test
:
1
%
$
%
$
%
$
[
s0
,
nu0
]
=
inverse_gamma_specification
(.
75
,.
1
,
1
,
0
);
%
$
[
s0
,
nu0
]
=
inverse_gamma_specification
(.
75
,.
2
,
1
,
0
);
%
$
[
s1
,
nu1
]
=
inverse_gamma_specification
(.
75
,.
1
,
1
,
1
);
%
$
[
s1
,
nu1
]
=
inverse_gamma_specification
(.
75
,.
2
,
1
,
1
);
%
$
%
$
[
s3
,
nu3
]
=
inverse_gamma_specification
(.
75
,.
1
,
1
,
0
);
%
$
[
s4
,
nu4
]
=
inverse_gamma_specification
(.
75
,.
1
,
1
,
1
);
%
$
%
Check
the
results
.
%
$
%
Check
the
results
.
%
$
t
(
1
)
=
dyn_assert
(
s0
,
s1
,
1e-6
);
%
$
t
(
1
)
=
dyn_assert
(
s0
,
s1
,
1e-6
);
%
$
t
(
2
)
=
dyn_assert
(
nu0
,
nu1
,
1e-6
);
%
$
t
(
2
)
=
dyn_assert
(
nu0
,
nu1
,
1e-6
);
%
$
t
(
3
)
=
isnan
(
s4
);
%
$
t
(
4
)
=
isnan
(
nu4
);
%
$
t
(
5
)
=
dyn_assert
(
s3
,
16
.
240907971002265
,
1e-6
);;
%
$
t
(
6
)
=
dyn_assert
(
nu3
,
30
.
368398202624046
,
1e-6
);;
%
$
T
=
all
(
t
);
%
$
T
=
all
(
t
);
%
@eof
:
1
%
@eof
:
1
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment