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
Dynare
dynare
Commits
636cd1ba
Commit
636cd1ba
authored
13 years ago
by
MichelJuillard
Browse files
Options
Downloads
Patches
Plain Diff
calling always multivariate Kalman filter first, even if univariate
diffuse Kalman filter was used before
parent
cfb5114d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
matlab/dsge_likelihood.m
+7
-6
7 additions, 6 deletions
matlab/dsge_likelihood.m
matlab/dsge_likelihood_hh.m
+13
-11
13 additions, 11 deletions
matlab/dsge_likelihood_hh.m
with
20 additions
and
17 deletions
matlab/dsge_likelihood.m
+
7
−
6
View file @
636cd1ba
...
...
@@ -359,6 +359,7 @@ end
diffuse_periods
=
0
;
correlated_errors_have_been_checked
=
0
;
singular_diffuse_filter
=
0
;
switch
DynareOptions
.
lik_init
case
1
%
Standard
initialization
with
the
steady
state
of
the
state
equation
.
if
kalman_algo
~=
2
...
...
@@ -407,17 +408,17 @@ switch DynareOptions.lik_init
diffuse_periods
=
length
(
tmp
);
if
isinf
(
dLIK
)
%
Go
to
univariate
diffuse
filter
if
singularity
problem
.
kalman_algo
=
4
;
singular_diffuse_filter
=
1
;
end
end
if
(
kalman_algo
==
4
)
if
singular_diffuse_filter
||
(
kalman_algo
==
4
)
%
Univariate
Diffuse
Kalman
Filter
if
isequal
(
H
,
0
)
H
=
zeros
(
nobs
,
1
);
H
1
=
zeros
(
nobs
,
1
);
mmm
=
mm
;
else
if
all
(
all
(
abs
(
H
-
diag
(
diag
(
H
)))
<
1e-14
))
%
ie
,
the
covariance
matrix
is
diagonal
...
H
=
diag
(
H
);
H
1
=
diag
(
H
);
mmm
=
mm
;
else
Z
=
[
Z
,
eye
(
pp
)];
...
...
@@ -426,7 +427,7 @@ switch DynareOptions.lik_init
R
=
blkdiag
(
R
,
eye
(
pp
));
Pstar
=
blkdiag
(
Pstar
,
H
);
Pinf
=
blckdiag
(
Pinf
,
zeros
(
pp
));
H
=
zeros
(
nobs
,
1
);
H
1
=
zeros
(
nobs
,
1
);
mmm
=
mm
+
pp
;
end
end
...
...
@@ -439,7 +440,7 @@ switch DynareOptions.lik_init
Y
,
1
,
size
(
Y
,
2
),
...
zeros
(
mmm
,
1
),
Pinf
,
Pstar
,
...
kalman_tol
,
riccati_tol
,
DynareOptions
.
presample
,
...
T
,
R
,
Q
,
H
,
Z
,
mmm
,
pp
,
rr
);
T
,
R
,
Q
,
H
1
,
Z
,
mmm
,
pp
,
rr
);
diffuse_periods
=
length
(
tmp
);
end
case
4
%
Start
from
the
solution
of
the
Riccati
equation
.
...
...
This diff is collapsed.
Click to expand it.
matlab/dsge_likelihood_hh.m
+
13
−
11
View file @
636cd1ba
...
...
@@ -255,6 +255,7 @@ end
diffuse_periods
=
0
;
correlated_errors_have_been_checked
=
0
;
singular_diffuse_filter
=
0
;
switch
DynareOptions
.
lik_init
case
1
% Standard initialization with the steady state of the state equation.
if
kalman_algo
~=
2
...
...
@@ -303,18 +304,17 @@ switch DynareOptions.lik_init
diffuse_periods
=
length
(
dlik
);
if
isinf
(
dLIK
)
% Go to univariate diffuse filter if singularity problem.
kalman_algo
=
4
;
singularity_flag
=
1
;
singular_diffuse_filter
end
end
if
(
kalman_algo
==
4
)
if
singular_diffuse_filter
||
(
kalman_algo
==
4
)
% Univariate Diffuse Kalman Filter
if
isequal
(
H
,
0
)
H
=
zeros
(
nobs
,
1
);
H
1
=
zeros
(
nobs
,
1
);
mmm
=
mm
;
else
if
all
(
all
(
abs
(
H
-
diag
(
diag
(
H
)))
<
1e-14
))
% ie, the covariance matrix is diagonal...
H
=
diag
(
H
);
H
1
=
diag
(
H
);
mmm
=
mm
;
else
Z
=
[
Z
,
eye
(
pp
)];
...
...
@@ -323,18 +323,20 @@ switch DynareOptions.lik_init
R
=
blkdiag
(
R
,
eye
(
pp
));
Pstar
=
blkdiag
(
Pstar
,
H
);
Pinf
=
blckdiag
(
Pinf
,
zeros
(
pp
));
H
=
zeros
(
nobs
,
1
);
H
1
=
zeros
(
nobs
,
1
);
mmm
=
mm
+
pp
;
end
end
% no need to test again for correlation elements
correlated_errors_have_been_checked
=
1
;
[
dLIK
,
dlik
,
a
,
Pstar
]
=
univariate_kalman_filter_d
(
DynareDataset
.
missing
.
aindex
,
DynareDataset
.
missing
.
number_of_observations
,
DynareDataset
.
missing
.
no_more_missing_observations
,
...
Y
,
1
,
size
(
Y
,
2
),
...
zeros
(
mmm
,
1
),
Pinf
,
Pstar
,
...
kalman_tol
,
riccati_tol
,
DynareOptions
.
presample
,
...
T
,
R
,
Q
,
H
,
Z
,
mmm
,
pp
,
rr
);
[
dLIK
,
dlik
,
a
,
Pstar
]
=
univariate_kalman_filter_d
(
DynareDataset
.
missing
.
aindex
,
...
DynareDataset
.
missing
.
number_of_observations
,
...
DynareDataset
.
missing
.
no_more_missing_observations
,
...
Y
,
1
,
size
(
Y
,
2
),
...
zeros
(
mmm
,
1
),
Pinf
,
Pstar
,
...
kalman_tol
,
riccati_tol
,
DynareOptions
.
presample
,
...
T
,
R
,
Q
,
H1
,
Z
,
mmm
,
pp
,
rr
);
diffuse_periods
=
length
(
dlik
);
end
case
4
% Start from the solution of the Riccati equation.
...
...
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