Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
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
Marco Ratto
dynare
Commits
26809527
Commit
26809527
authored
11 years ago
by
Stéphane Adjemian
Browse files
Options
Downloads
Patches
Plain Diff
Factorized code using ispd routine.
parent
3701707e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
matlab/DsgeVarLikelihood.m
+3
-4
3 additions, 4 deletions
matlab/DsgeVarLikelihood.m
matlab/dsge_likelihood.m
+14
-26
14 additions, 26 deletions
matlab/dsge_likelihood.m
with
17 additions
and
30 deletions
matlab/DsgeVarLikelihood.m
+
3
−
4
View file @
26809527
...
...
@@ -224,10 +224,9 @@ if ~isinf(dsge_prior_weight)% Evaluation of the likelihood of the dsge-var model
tmp1
=
dsge_prior_weight
*
DynareDataset
.
info
.
ntobs
*
GYX
+
mYX
;
tmp2
=
inv
(
dsge_prior_weight
*
DynareDataset
.
info
.
ntobs
*
GXX
+
mXX
);
SIGMAu
=
tmp0
-
tmp1
*
tmp2
*
tmp1
'; clear('
tmp0
'
);
if
~
ispd
(
SIGMAu
)
v
=
diag
(
SIGMAu
);
k
=
find
(
v
<
0
);
fval
=
objective_function_penalty_base
+
sum
(
v
(
k
)
.^
2
);
[
SIGMAu_is_positive_definite
,
penalty
]
=
ispd
(
SIGMAu
)
if
~
SIGMAu_is_positive_definite
fval
=
objective_function_penalty_base
+
penalty
;
info
=
52
;
exit_flag
=
0
;
return
;
...
...
This diff is collapsed.
Click to expand it.
matlab/dsge_likelihood.m
+
14
−
26
View file @
26809527
...
...
@@ -206,36 +206,24 @@ Q = Model.Sigma_e;
H
=
Model
.
H
;
%
Test
if
Q
is
positive
definite
.
if
EstimatedParameters
.
ncx
%
Try
to
compute
the
cholesky
decomposition
of
Q
(
possible
iff
Q
is
positive
definite
)
[
CholQ
,
testQ
]
=
chol
(
Q
);
if
testQ
%
The
variance
-
covariance
matrix
of
the
structural
innovations
is
not
definite
positive
.
We
have
to
compute
the
eigenvalues
of
this
matrix
in
order
to
build
the
endogenous
penalty
.
a
=
diag
(
eig
(
Q
));
k
=
find
(
a
<
0
);
if
k
>
0
fval
=
objective_function_penalty_base
+
sum
(
-
a
(
k
));
exit_flag
=
0
;
info
=
43
;
return
end
if
~
issquare
(
Q
)
&&
EstimatedParameters
.
ncx
[
Q_is_positive_definite
,
penalty
]
=
ispd
(
Q
);
if
~
Q_is_positive_definite
fval
=
objective_function_penalty_base
+
penalty
;
exit_flag
=
0
;
info
=
43
;
return
end
end
%
Test
if
H
is
positive
definite
.
if
EstimatedParameters
.
ncn
%
Try
to
compute
the
cholesky
decomposition
of
H
(
possible
iff
H
is
positive
definite
)
[
CholH
,
testH
]
=
chol
(
H
);
if
testH
%
The
variance
-
covariance
matrix
of
the
measurement
errors
is
not
definite
positive
.
We
have
to
compute
the
eigenvalues
of
this
matrix
in
order
to
build
the
endogenous
penalty
.
a
=
diag
(
eig
(
H
));
k
=
find
(
a
<
0
);
if
k
>
0
fval
=
objective_function_penalty_base
+
sum
(
-
a
(
k
));
exit_flag
=
0
;
info
=
44
;
return
end
if
~
issquare
(
H
)
&&
EstimatedParameters
.
ncn
[
H_is_positive_definite
,
penalty
]
=
ispd
(
H
);
if
~
H_is_positive_definite
fval
=
objective_function_penalty_base
+
penalty
;
exit_flag
=
0
;
info
=
44
;
return
end
end
...
...
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