Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
eb9bc512
Commit
eb9bc512
authored
Nov 16, 2012
by
Frédéric Karamé
Browse files
fixed bug in calculation of observed mean and variance + add the possibility for smooth resampling
parent
3a9eed00
Changes
1
Hide whitespace changes
Inline
Side-by-side
matlab/particle/sequential_importance_particle_filter.m
View file @
eb9bc512
...
...
@@ -38,7 +38,7 @@ function [LIK,lik] = sequential_importance_particle_filter(ReducedForm,Y,start,D
%!
@end
deftypefn
%
@eod
:
%
Copyright
(
C
)
2011
-
2012
Dynare
Team
%
Copyright
(
C
)
2011
,
2012
Dynare
Team
%
%
This
file
is
part
of
Dynare
.
%
...
...
@@ -55,7 +55,7 @@ function [LIK,lik] = sequential_importance_particle_filter(ReducedForm,Y,start,D
%
You
should
have
received
a
copy
of
the
GNU
General
Public
License
%
along
with
Dynare
.
If
not
,
see
<
http
:
//www.gnu.org/licenses/>.
%
AUTHOR
(
S
)
frederic
DOT
karame
AT
univ
DASH
evry
DOT
fr
%
AUTHOR
(
S
)
frederic
DOT
karame
AT
univ
DASH
lemans
DOT
fr
%
stephane
DOT
adjemian
AT
univ
DASH
lemans
DOT
fr
persistent
init_flag
...
...
@@ -72,7 +72,7 @@ end
pruning
=
DynareOptions
.
particle
.
pruning
;
%
Get
steady
state
and
mean
.
steadystate
=
ReducedForm
.
steadystate
;
%
steadystate
=
ReducedForm
.
steadystate
;
constant
=
ReducedForm
.
constant
;
state_variables_steady_state
=
ReducedForm
.
state_variables_steady_state
;
...
...
@@ -103,6 +103,10 @@ if isempty(H)
H
=
0
;
end
%
Initialization
of
the
likelihood
.
const_lik
=
log
(
2
*
pi
)
*
number_of_observed_variables
;
lik
=
NaN
(
sample_size
,
1
);
%
Get
initial
condition
for
the
state
vector
.
StateVectorMean
=
ReducedForm
.
StateVectorMean
;
StateVectorVarianceSquareRoot
=
reduced_rank_cholesky
(
ReducedForm
.
StateVectorVariance
)
'
;
...
...
@@ -116,14 +120,13 @@ state_variance_rank = size(StateVectorVarianceSquareRoot,2);
%
Factorize
the
covariance
matrix
of
the
structural
innovations
Q_lower_triangular_cholesky
=
chol
(
Q
)
'
;
[
PredictedStateMean
,
PredictedStateVarianceSquareRoot
,
StateVectorMean
,
StateVectorVarianceSquareRoot
]
=
...
gaussian_filter_bank
(
ReducedForm
,
Y
(
:
,
1
),
StateVectorMean
,
StateVectorVarianceSquareRoot
,
Q_lower_triangular_cholesky
,
Q_lower_triangular_cholesky
,
H
,
DynareOptions
)
;
StateVectors
=
bsxfun
(
@plus
,
StateVectorVarianceSquareRoot
*
randn
(
state_variance_rank
,
number_of_particles
),
StateVectorMean
)
;
%
Set
seed
for
randn
().
set_dynare_seed
(
'
default
'
);
%
Initialization
of
the
likelihood
.
const_lik
=
log
(
2
*
pi
)
*
number_of_observed_variables
;
lik
=
NaN
(
sample_size
,
1
);
%
Initialization
of
the
weights
across
particles
.
weights
=
ones
(
1
,
number_of_particles
)
/
number_of_particles
;
StateVectors
=
bsxfun
(
@plus
,
StateVectorVarianceSquareRoot
*
randn
(
state_variance_rank
,
number_of_particles
),
StateVectorMean
);
...
...
Write
Preview
Supports
Markdown
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