SlideShare una empresa de Scribd logo
1 de 79
Descargar para leer sin conexión
Filtering and Likelihood Inference

                                    Jesús Fernández-Villaverde

                                       University of Pennsylvania


                                           July 10, 2011




Jesús Fernández-Villaverde (PENN)          Filtering and Likelihood   July 10, 2011   1 / 79
Introduction


Motivation

       Filtering, smoothing, and forecasting problems are pervasive in
       economics.

       Examples:

          1   Macroeconomics: evaluating likelihood of DSGE models.

          2   Microeconomics: structural models of individual choice with
              unobserved heterogeneity.

          3   Finance: time-varying variance of asset returns.


       However, …ltering is a complicated endeavor with no simple and exact
       algorithm.
Jesús Fernández-Villaverde (PENN)     Filtering and Likelihood       July 10, 2011   2 / 79
Introduction


Environment I

       Discrete time t 2 f1, 2, ...g .

       Why discrete time?

          1   Economic data is discrete.

          2   Easier math.


       Comparison with continuous time:

          1   Discretize observables.

          2   More involved math (stochastic calculus) but often we have extremely
              powerful results.
Jesús Fernández-Villaverde (PENN)       Filtering and Likelihood    July 10, 2011   3 / 79
Introduction


Environment II

       States St .

       We will focus on continuous state spaces.

       Comparison with discrete states:

          1   Markov-Switching models.

          2   Jumps and continuous changes.


       Initial state S0 is either known or it comes from p (S0 ; γ) .

       Properties of p (S0 ; γ)? Stationarity?

Jesús Fernández-Villaverde (PENN)     Filtering and Likelihood     July 10, 2011   4 / 79
State Space Representations


State Space Representations

       Transition equation:

                                             St = f ( St         1 , Wt ; γ )



       Measurement equation:

                                                Yt = g (St , Vt ; γ)


       f and g are measurable functions.

       Interpretation. Modelling origin.

       Note Markov structure.
Jesús Fernández-Villaverde (PENN)              Filtering and Likelihood         July 10, 2011   5 / 79
State Space Representations


Shocks

       fWt g and fVt g are independent of each other.


       fWt g is known as process noise and fVt g as measurement noise.


       Wt and Vt have zero mean.


       No assumptions on the distribution beyond that.


       Often, we assume that the variance of Wt is given by Rt and the
       variance of Vt by Qt .


Jesús Fernández-Villaverde (PENN)              Filtering and Likelihood   July 10, 2011   6 / 79
State Space Representations


DSGE Models and State Space Representations

       We have the solution of a DSGE model:

                                           St      = P1 St           1 + P2 Zt
                                           Yt      = R1 St           1 + R2 Zt

       This has nearly the same form that

                                           St      = f ( S t 1 , Wt ; γ )
                                          Yt       = g (St , Vt ; γ)

       We only need to be careful with:

          1   To rewrite the measurement equation in terms of St instead of St                   1.

          2   How we partition Zt into Wt and Vt .

       Later, we will present an example.
Jesús Fernández-Villaverde (PENN)               Filtering and Likelihood         July 10, 2011    7 / 79
State Space Representations


Generalizations I

We can accommodate many generalizations by playing with the state
de…nition:

   1   Serial correlation of shocks.

   2   Contemporaneous correlation of shocks.

   3   Time changing state space equations.


Often, even in…nite histories (for example in a dynamic game) can be
tracked by a Lagrangian multiplier.


Jesús Fernández-Villaverde (PENN)              Filtering and Likelihood   July 10, 2011   8 / 79
State Space Representations


Generalizations II


       However, some generalizations can be tricky to accommodate.


       Take the model:
                                             St = f ( St         1 , Wt ; γ )

                                           Yt = g (St , Vt , Yt           1 ; γ)




       Yt will be an in…nite-memory process.




Jesús Fernández-Villaverde (PENN)              Filtering and Likelihood            July 10, 2011   9 / 79
State Space Representations


Conditional Densities


       From St = f (St              1 , Wt ; γ ) ,   we can compute p (St jSt          1 ; γ ).


       From Yt = g (St , Vt ; γ), we can compute p (Yt jSt ; γ) .

       From St = f (St              1 , Wt ; γ )   and Yt = g (St , Vt ; γ), we have:

                                      Yt = g (f (St          1 , Wt ; γ ) , Vt ; γ )



       and hence we can compute p (Yt jSt                          1 ; γ ).




Jesús Fernández-Villaverde (PENN)              Filtering and Likelihood                 July 10, 2011   10 / 79
Filtering


Filtering, Smoothing, and Forecasting



       Filtering: we are concerned with what we have learned up to current
       observation.


       Smoothing: we are concerned with what we learn with the full sample.


       Forecasting: we are concerned with future realizations.




Jesús Fernández-Villaverde (PENN)   Filtering and Likelihood     July 10, 2011   11 / 79
Filtering


Goal of Filtering I

       Compute conditional densities: p St jy t                 1; γ   and p (St jy t ; γ) .


       Why?


          1   It allows probability statements regarding the situation of the system.

          2   Compute conditional moments: mean, st jt and st jt              1,   and variances
              Pt jt and Pt jt 1 .

          3   Other functions of the states. Examples of interest.


       Theoretical point: do the conditional densities exist?

Jesús Fernández-Villaverde (PENN)    Filtering and Likelihood                      July 10, 2011   12 / 79
Filtering


Goals of Filtering II
       Evaluate the likelihood function of the observables y T at parameter
       values γ:
                                      p yT ; γ
       Given the Markov structure of our state space representation:
                                                        T
                                    p yT ; γ =         ∏p            yt jy t   1
                                                                                   ;γ
                                                       t =1
       Then:
                                           T
       p yT ; γ           = p (y1 jγ) ∏ p yt jy t               1
                                                                    ;γ
                                          t =2
                                Z                           T   Z
                          =         p (y1 js1 ; γ) dS1 ∏               p (yt jSt ; γ) p St jy t   1
                                                                                                      ; γ dSt
                                                         t =2
                                                                T
       Hence, knowledge of p St jy t 1 ; γ t =1 and p (S1 ; γ) allow the
       evaluation of the likelihood of the model.
Jesús Fernández-Villaverde (PENN)         Filtering and Likelihood                      July 10, 2011    13 / 79
Filtering


Two Fundamental Tools

   1   Chapman-Kolmogorov equation:
                                           Z
                p St j y t     1
                                    ;γ =        p ( St j St     1 ; γ) p   St   1 jy
                                                                                       t 1
                                                                                             ; γ dSt     1



   2   Bayes’theorem:

                                                      p (yt jSt ; γ) p St jy t         1; γ
                             p St j y t ; γ =
                                                             p (yt jy t 1 ; γ)


       where:
                                                  Z
                      p yt jy t      1
                                         ;γ =         p (yt jSt ; γ) p St jy t         1
                                                                                           ; γ dSt


Jesús Fernández-Villaverde (PENN)              Filtering and Likelihood                       July 10, 2011   14 / 79
Filtering


Interpretation


       All …ltering problems have two steps: prediction and update.


          1   Chapman-Kolmogorov equation is one-step ahead predictor.


          2   Bayes’theorem updates the conditional density of states given the new
              observation.



       We can think of those two equations as operators that map measures
       into measures.



Jesús Fernández-Villaverde (PENN)   Filtering and Likelihood        July 10, 2011   15 / 79
Filtering


Recursion for Conditional Distribution

       Combining the Chapman-Kolmogorov and the Bayes’theorem:



                                         p St j y t ; γ =
                       R
                        p (St jSt 1 ; γ) p St 1 jy t 1 ; γ dSt 1
       R R                                                                    p (yt jSt ; γ)
                p (St jSt 1 ; γ) p (St 1 jy t 1 ; γ) dSt 1 p (yt jSt ; γ) dSt




       To initiate that recursion, we only need a value for s0 or p (S0 ; γ).


       Applying the Chapman-Kolmogorov equation once more, we get
                        T
        p St jy t 1 ; γ t =1 to evaluate the likelihood function.

Jesús Fernández-Villaverde (PENN)     Filtering and Likelihood           July 10, 2011   16 / 79
Filtering


Initial Conditions I

       From previous discussion, we know that we need a value for s1 or
       p ( S1 ; γ ) .

       Stationary models: ergodic distribution.

       Non-stationary models: more complicated. Importance of
       transformations.

       Initialization in the case of Kalman …lter.

       Forgetting conditions.

       Non-contraction properties of the Bayes operator.

Jesús Fernández-Villaverde (PENN)   Filtering and Likelihood   July 10, 2011   17 / 79
Filtering


Smoothing


       We are interested on the distribution of the state conditional on all
       the observations, on p St jy T ; γ and p yt jy T ; γ .

       We compute:
                                           Z
                                                 p St + 1 j y T ; γ p ( St + 1 j St ; γ )
         p St j y T ; γ = p St j y t ; γ                                                  dSt +1
                                                          p ( St + 1 j y t ; γ )


       a backward recursion that we initialize with p ST jy T ; γ ,
                                                               T
       fp (St jy t ; γ)gT=1 and p St jy t
                        t
                                                 1; γ
                                                               t =1
                                                                      we obtained from …ltering.



Jesús Fernández-Villaverde (PENN)   Filtering and Likelihood                     July 10, 2011   18 / 79
Filtering


Forecasting


       We apply the Chapman-Kolmogorov equation recursively, we can get
       p (St +j jy t ; γ) , j 1.


       Integrating recursively:
                                      Z
                 p yl +1 jy l ; γ =        p (yl +1 jSl +1 ; γ) p Sl +1 jy l ; γ dSl +1

       from t + 1 to t + j, we get p yt +j jy T ; γ .


       Clearly smoothing and forecasting require to solve the …ltering
       problem …rst!


Jesús Fernández-Villaverde (PENN)         Filtering and Likelihood           July 10, 2011   19 / 79
Filtering


Problem of Filtering
       We have the recursion

                                         p St j y t ; γ =
                       R
                        p (St jSt 1 ; γ) p St 1 jy t 1 ; γ dSt 1
       R R                                                                    p (yt jSt ; γ)
                p (St jSt 1 ; γ) p (St 1 jy t 1 ; γ) dSt 1 p (yt jSt ; γ) dSt



       A lot of complicated and high dimensional integrals (plus the one
       involved in the likelihood).


       In general, we do not have closed form solution for them.


       Translate, spread, and deform (TSD) the conditional densities in ways
       that impossibilities to …t them within any known parametric family.
Jesús Fernández-Villaverde (PENN)     Filtering and Likelihood           July 10, 2011   20 / 79
Filtering


Exception

       There is one exception: linear and Gaussian case.


       Why? Because if the system is linear and Gaussian, all the conditional
       probabilities are also Gaussian.


       Linear and Gaussian state spaces models translate and spread the
       conditional distributions, but they do not deform them.


       For Gaussian distributions, we only need to track mean and variance
       (su¢ cient statistics).


       Kalman …lter accomplishes this goal e¢ ciently.

Jesús Fernández-Villaverde (PENN)   Filtering and Likelihood   July 10, 2011   21 / 79
Kalman Filtering


Linear Gaussian Case

       Let the following system:


              Transition equation

                                    st = Fst     1     + G ωt , ωt     N (0, Q )


              Measurement equation

                                      yt = Hst + υt , υt             N (0, R )


       Assume we want to write the likelihood function of y T = fyt gT=1 .
                                                                     t



Jesús Fernández-Villaverde (PENN)         Filtering and Likelihood                 July 10, 2011   22 / 79
Kalman Filtering


The State Space Representation is Not Unique

       Take the previous state space representation.


       Let B be a non-singular squared matrix conforming with F .


       Then, if st = Bst , F = BFB 1 , G = BG , and H = HB                                    1,   we can
       write a new, equivalent, representation:


              Transition equation

                                    st + 1 = F st + G ω t , ω t           N (0, Q )

              Measurement equation

                                       yt = H s t + υ t , υ t          N (0, R )

Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood                  July 10, 2011   23 / 79
Kalman Filtering


Example I


       AR(2) process:

                          yt = ρ1 yt   1   + ρ2 zt     2   + σ υ υt , υt   N (0, 1)

       Model is not apparently not Markovian.


       However, it is trivial to write it in a state space form.


       In fact, we have many di¤erent state space forms.



Jesús Fernández-Villaverde (PENN)          Filtering and Likelihood              July 10, 2011   24 / 79
Kalman Filtering


Example I

       State Space Representation I:

                        yt                         ρ1 1                    yt 1          συ
                                         =                                          +             υt
                     ρ2 yt    1                    ρ2 0                   ρ2 yt 2        0
                                                                      yt
                                    yt   =        1 0
                                                                   ρ2 yt       1

       State Space Representation II:

                         yt                       ρ1 ρ2                   yt   1        συ
                                         =                                          +          υt
                        yt 1                      1 0                     yt   2        0
                                                                      yt
                                  yt     =       1 ρ2
                                                                    yt     1

                                    1 0
       Rotation B =                              on the second system to get the …rst one.
                                    0 ρ2
Jesús Fernández-Villaverde (PENN)              Filtering and Likelihood                  July 10, 2011   25 / 79
Kalman Filtering


Example II
       MA(1) process:

             yt = υt + θυt               1,    υt       N 0, σ2 , and Eυt υs = 0 for s 6= t.
                                                              υ

       State Space Representation I:
                           yt                           0 1                 yt   1       1
                                          =                                          +          υt
                          θυt                           0 0                θυt   1       θ
                                                                         yt
                                    yt    =            1 0
                                                                        θυt
       State Space Representation II:

                                                      st     = υt 1
                                                      yt     = sxt + υt
       Again both representations are equivalent!
Jesús Fernández-Villaverde (PENN)                   Filtering and Likelihood                 July 10, 2011   26 / 79
Kalman Filtering


Example III
       Now we explore a di¤erent issue.

       Random walk plus drift process:
                                 yt = yt      1   + β + σ υ υt , υt         N (0, 1)

       This is even more interesting: we have a unit root and a constant
       parameter (the drift).

       State Space Representation:
                            yt                      1 1               yt1        συ
                                         =                                  +           υt
                            β                       0 1                β         0
                                                                    yt
                                    yt   =         1 0
                                                                    β


Jesús Fernández-Villaverde (PENN)              Filtering and Likelihood                July 10, 2011   27 / 79
Kalman Filtering


Some Conditions on the State Space Representation


       We only consider stable systems.


       A system is stable if for any initial state s0 , the vector of states, st ,
       converges to some unique s .


       A necessary and su¢ cient condition for the system to be stable is
       that:
                                   jλi (F )j < 1
       for all i, where λi (F ) stands for eigenvalue of F .




Jesús Fernández-Villaverde (PENN)         Filtering and Likelihood   July 10, 2011   28 / 79
Kalman Filtering


Introducing the Kalman Filter


       Developed by Kalman and Bucy.


       Wide application in science.


       Basic idea.


       Prediction, smoothing, and control.


       Di¤erent derivations.



Jesús Fernández-Villaverde (PENN)         Filtering and Likelihood   July 10, 2011   29 / 79
Kalman Filtering


Some De…nitions


De…nition
Let st jt 1 = E st jy t             1    be the best linear predictor of st given the history
of observables until t                  1, i.e., y t 1 .

De…nition
Let yt jt 1 = E yt jy t 1 = Hst jt                     1    be the best linear predictor of yt given
the history of observables until t                         1, i.e., y t 1 .

De…nition
Let st jt = E (st jy t ) be the best linear predictor of st given the history of
observables until t, i.e., s t .



Jesús Fernández-Villaverde (PENN)               Filtering and Likelihood             July 10, 2011   30 / 79
Kalman Filtering


What is the Kalman Filter Trying to Do?

       Let assume we have st jt          1   and yt jt      1.



       We observe a new yt .


       We need to obtain st jt .


       Note that st +1 jt = Fst jt and yt +1 jt = Hst +1 jt , so we can go back to
       the …rst step and wait for yt +1 .


       Therefore, the key question is how to obtain st jt from st jt      1   and yt .

Jesús Fernández-Villaverde (PENN)         Filtering and Likelihood   July 10, 2011   31 / 79
Kalman Filtering


A Minimization Approach to the Kalman Filter
       Assume we use the following equation to get st jt from yt and st jt                              1:

              st j t = st j t   1   + Kt yt       yt jt   1    = st j t   1   + Kt yt    Hst jt    1



       This formula will have some probabilistic justi…cation (to follow).

       Kt is called the Kalman …lter gain and it measures how much we
       update st jt 1 as a function in our error in predicting yt .

       The question is how to …nd the optimal Kt .

       The Kalman …lter is about how to build Kt such that optimally
       update st jt from st jt 1 and yt .

       How do we …nd the optimal Kt ?
Jesús Fernández-Villaverde (PENN)            Filtering and Likelihood                   July 10, 2011   32 / 79
Kalman Filtering


Some Additional De…nitions
De…nition
                                                                    0
Let Σt jt 1 E st st jt 1 st st jt 1 jy t 1 be the predicting error
variance covariance matrix of st given the history of observables until
t 1, i.e. y t 1 .

De…nition
                                                                        0
Let Ωt jt 1 E yt yt jt 1 yt yt jt 1 jy t 1 be the predicting
error variance covariance matrix of yt given the history of observables until
t 1, i.e. y t 1 .

De…nition
                                                          0
Let Σt jt        E      st      st j tjy t be the predicting error variance
                                         st      st j t
covariance matrix of st given the history of observables until t, i.e. y t .
Jesús Fernández-Villaverde (PENN)              Filtering and Likelihood     July 10, 2011   33 / 79
Kalman Filtering


The Kalman Filter Algorithm I


       Given Σt jt        1,   yt , and st jt    1,   we can now set the Kalman …lter
       algorithm.

       Let Σt jt     1,   then we compute:

                                                                                        0
                   Ω t jt      1       E        yt      yt jt   1      yt   yt jt   1       jy t   1

                                           0                            0
                                                                             1
                                                s t j t 1 st s t j t 1 H 0
                                                 H st
                                       B                        0            C
                                    = E@     + υ t st st j t 1 H 0           A
                                         + H st st j t 1 υ t0 + υ υ 0 jy t 1
                                                                  t t
                                                          0
                                    = HΣt jt         1H       +R



Jesús Fernández-Villaverde (PENN)               Filtering and Likelihood                           July 10, 2011   34 / 79
Kalman Filtering


The Kalman Filter Algorithm II

       Let Σt jt     1,   then we compute:

                                                                          0
                    E       yt        yt jt   1     st       st j t   1       jy t       1
                                                                                                 =
                                                                                     0
                                                                                             !
                              H s t s t j t 1 st                    st j t     1
                      E                                           0 t         1
                                                                                                 = HΣt jt        1
                               + υ t st st j t 1                   jy

       Let Σt jt     1,   then we compute:
                                                                                                      1
                                    Kt = Σ t j t        1H
                                                             0
                                                                 HΣt jt        1H
                                                                                         0
                                                                                             +R


       Let Σt jt     1 , st j t 1 ,   Kt , and yt , then we compute:

                                      st j t = st j t    1   + Kt yt                 Hst jt       1

Jesús Fernández-Villaverde (PENN)                 Filtering and Likelihood                                July 10, 2011   35 / 79
Kalman Filtering


Finding the Optimal Gain
       We want Kt such that min Σt jt .
       Thus:
                                                                                                1
                                    Kt = Σ t j t       1H
                                                            0
                                                                HΣt jt      1H
                                                                                   0
                                                                                       +R

       with the optimal update of st jt given yt and st jt                                  1   being:
                                     st j t = st j t   1    + Kt yt            Hst jt       1


       Intuition: note that we can rewrite Kt in the following way:
                                             Kt = Σ t j t        1H
                                                                      0
                                                                          Ω t jt
                                                                               1
                                                                                       1


          1   If we did a big mistake forecasting st jt 1 using past information (Σt jt                                1
              large), we give a lot of weight to the new information (Kt large).
          2   If the new information is noise (R large), we give a lot of weight to the
              old prediction (Kt small).
Jesús Fernández-Villaverde (PENN)               Filtering and Likelihood                            July 10, 2011   36 / 79
Kalman Filtering


Example
       Assume the following model in state space form:
              Transition equation:
                                      st = µ + ω t , ω t             N 0, σ2
                                                                           ω

              Measurement equation:
                                       yt = s t + υ t , υ t          N 0, σ2
                                                                           υ



       Let σ2 = qσ2 .
            υ        ω
       Then, if Σ1 j0 = σ2 , (s1 is drawn from the ergodic distribution of st ):
                         ω
                                                        1     1
                                     K1 = σ 2
                                            ω              ∝     .
                                                       1+q   1+q

       Therefore, the bigger σ2 relative to σ2 (the bigger q), the lower K1
                               υ             ω
       and the less we trust y1 .
Jesús Fernández-Villaverde (PENN)         Filtering and Likelihood             July 10, 2011   37 / 79
Kalman Filtering


The Kalman Filter Algorithm III


       Let Σt jt     1 , st j t 1 ,     Kt , and yt .
       Then, we compute:
                                                                                              0
                               Σ t jt           E        st       st j t       st   st j t        jy t =
          0                                                                0                 1
                         st        st j t
                                  st j t 1  1       st
        B                                  0
                  st st jt 1 yt Hst jt 1 Kt0                                                 C
        B                                                                                    C
       EB                                     0                                              C = Σ t jt    1      Kt HΣt jt     1
        @        Kt yt Hst jt 1 st st jt 1 +                                                 A
                                             0 0 t
               Kt yt Hst jt 1 yt Hst jt 1 Kt jy

       where
                              st      st j t = s t            st j t   1       Kt yt          Hst jt   1   .



Jesús Fernández-Villaverde (PENN)                    Filtering and Likelihood                              July 10, 2011   38 / 79
Kalman Filtering


The Kalman Filter Algorithm IV

       Let Σt jt     1 , st j t 1 ,   Kt , and yt , then we compute:

                                         Σt +1 jt = F Σt jt F 0 + GQG 0


       Let st jt , then we compute:

          1   st +1 jt = Fst jt

          2   yt +1 jt = Hst +1 jt

       Therefore, from st jt            1,   Σ t jt   1,   and yt we compute st jt and Σt jt .

       We also compute yt jt 1 and Ωt jt 1 to help (later) to calculate the
       likelihood function of y T = fyt gT=1 .
                                         t

Jesús Fernández-Villaverde (PENN)               Filtering and Likelihood             July 10, 2011   39 / 79
Kalman Filtering


The Kalman Filter Algorithm: A Review
We start with st jt                1   and Σt jt          1.   Then, we observe yt and:

       Ω t jt       1   = HΣt jt           1H
                                                0   +R

       yt jt    1   = Hst jt           1

                                                                        1
       Kt = Σ t j t        1H
                                   0       HΣt jt     1H
                                                           0   +R

       Σ t jt = Σ t jt         1           Kt HΣt jt       1

       st j t = st j t     1   + K t yt                Hst jt     1

       Σt +1 jt = F Σt jt F 0 + GQG 0

       st +1 jt = Fst jt

We …nish with st +1 jt and Σt +1 jt .
Jesús Fernández-Villaverde (PENN)                         Filtering and Likelihood        July 10, 2011   40 / 79
Kalman Filtering


Writing the Likelihood Function

Likelihood function of y T = fyt gT=1 :
                                  t


                                     log p y T jF , G , H, Q, R =
                                T
                               ∑ log p         yt jy t      1
                                                                F , G , H, Q, R =
                              t =1
                       T
                              N         1                                   1 0
                       ∑      2
                                log 2π + log Ωt jt
                                        2                              1   + ς t Ω t jt 1 ς t
                                                                            2
                                                                                      1
                      t =1

where:
                                    ςt = yt        yt jt    1   = yt       Hst jt   1

is white noise and:
                                      Ω t jt   1   = Ht Σ t j t        0
                                                                    1 Ht   +R


Jesús Fernández-Villaverde (PENN)              Filtering and Likelihood                     July 10, 2011   41 / 79
Kalman Filtering


Initial conditions for the Kalman Filter
       An important step in the Kalman Filter is to set the initial conditions.
       Initial conditions s1 j0 and Σ1 j0 .
       Where do they come from?

Since we only consider stable system, the standard approach is to set:
     s1 j 0 = s
       Σ 1 j0 = Σ

where s solves:
                                     s     = Fs
                                     Σ     = F Σ F 0 + GQG 0
       How do we …nd Σ ?
                                                                 1
                                    Σ = [I         F       F]          vec (GQG 0 )
Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood                  July 10, 2011   42 / 79
Kalman Filtering


Initial conditions for the Kalman Filter II


Under the following conditions:

   1   The system is stable, i.e. all eigenvalues of F are strictly less than one
       in absolute value.

   2   GQG 0 and R are p.s.d. symmetric.

   3   Σ1 j0 is p.s.d. symmetric.


Then Σt +1 jt ! Σ .



Jesús Fernández-Villaverde (PENN)         Filtering and Likelihood   July 10, 2011   43 / 79
Kalman Filtering


Remarks


   1   There are more general theorems than the one just described.


   2   Those theorems are based on non-stable systems.


   3   Since we are going to work with stable system the former theorem is
       enough.


   4   Last theorem gives us a way to …nd Σ as Σt +1 jt ! Σ for any Σ1 j0 we
       start with.



Jesús Fernández-Villaverde (PENN)         Filtering and Likelihood   July 10, 2011   44 / 79
The Kalman Filter and DSGE models


The Kalman Filter and DSGE models
       Basic real business cycle model:
                                            ∞
                               max E0      ∑ βt flog ct + ψ log (1                   lt )g
                                           t =0
                               ct + kt +1 = ktα (e zt lt )1               α
                                                                              + (1 δ) kt
                                    zt = ρzt        1   + σεt , εt             N (0, 1)
       Equilibrium conditions:
                      1                    1
                         = βEt                αktα+1 (e zt +1 lt +1 )1 α + 1 δ
                                                   1
                      ct             ct + 1
                                     lt
                                  ψ        ct = (1 α) ktα (e zt lt )1 α
                                    1 lt
                               ct + kt +1 = ktα (e zt lt )1 α + (1 δ) kt
                                                zt = ρzt         1   + σεt
Jesús Fernández-Villaverde (PENN)              Filtering and Likelihood                      July 10, 2011   45 / 79
The Kalman Filter and DSGE models


The Kalman Filter and Linearized DSGE Models
       We loglinearize (or linearize) the equilibrium conditions around the
       steady state.

       Alternatives: particle …lter.

       We assume that we have data on:

          1   log outputt
          2   log lt
          3   log ct
                                                                                                 0
       s.t. a linearly additive measurement error Vt =                    v1,t   v2,t     v3,t       .

       Why measurement error? Stochastic singularity.

       Degrees of freedom in the measurement equation.
Jesús Fernández-Villaverde (PENN)              Filtering and Likelihood          July 10, 2011   46 / 79
The Kalman Filter and DSGE models


Policy Functions

       We need to write the model in state space form.

       Remember that a loglinear solution has the form:


                                             b          b
                                             kt +1 = p1 kt + p2 zt


       and

                                         
                                         output t              b
                                                          = q1 kt + q2 zt
                                              blt              b
                                                          = r1 kt + r2 zt
                                                 bt
                                                 c             b
                                                          = u1 kt + u2 zt


Jesús Fernández-Villaverde (PENN)             Filtering and Likelihood      July 10, 2011   47 / 79
The Kalman Filter and DSGE models


Writing the Likelihood Function

       Transition equation:
               0     1 0          10      1 0                                            1
                  1         1 0 0      1                                               0
               @ kt A = @ 0 p1 p2 A@ kt 1 A + @
                  b                  b                                                 0 A t .
                                                                                           |{z}
                  zt        0 0 ρ    zt 1                                              σ    ω
               | {z } |       {z  }| {z } |                                            {z } t
                       st                       F                        st   1        G

       Measurement equation:
          0              1 0               10                                        1 0              1
             log outputt       log y q1 q2                                        1              v1,t
          @     log lt   A = @ log l r1 r2 A@                                     kt A + @
                                                                                  b              v2,t A
                log ct         log c u1 u2                                        zt             v3,t
          |       {z     } |         {z    }|                                     {z } |          {z }
                         yt                                 H                     st               υ



Jesús Fernández-Villaverde (PENN)             Filtering and Likelihood                     July 10, 2011   48 / 79
The Kalman Filter and DSGE models


The Solution to the Model in State Space Form

       Now, with y T , F , G , H, Q, and R as de…ned before...


       ...we can use the Ricatti equations to evaluate the likelihood function:

                            log p y T jγ = log p y T jF , G , H, Q, R



       where γ = fα, β, ρ, ψ, δ, σg .


       Cross-equations restrictions implied by equilibrium solution.


       With the likelihood, we can do inference!

Jesús Fernández-Villaverde (PENN)             Filtering and Likelihood   July 10, 2011   49 / 79
Nonlinear Filtering


Nonlinear Filtering

       Di¤erent approaches.

       Deterministic …ltering:

          1   Kalman family.

          2   Grid-based …ltering.


       Simulation …ltering:

          1   McMc.

          2   Sequential Monte Carlo.

Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood   July 10, 2011   50 / 79
Nonlinear Filtering


Kalman Family of Filters

       Use ideas of Kalman …ltering to NLGF problems.


       Non-optimal …lters.


       Di¤erent implementations:


          1   Extended Kalman …lter.

          2   Iterated Extended Kalman …lter.

          3   Second-order Extended Kalman …lter.

          4   Unscented Kalman …lter.
Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood   July 10, 2011   51 / 79
Nonlinear Filtering


The Extended Kalman Filter




       EKF is historically the …rst descendant of the Kalman …lter.


       EKF deals with nonlinearities with a …rst order approximation to the
       system and applying the Kalman …lter to this approximation.


       Non-Gaussianities are ignored.




Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood   July 10, 2011   52 / 79
Nonlinear Filtering


Algorithm
       Given st      1 j t 1 , st j t 1     = f st          1 jt 1 , 0; γ           .
       Then:
                                                                                                   0
                                        Pt jt   1    = Qt        1   + Ft Pt             1 j t 1 Ft
       where
                                         df (St 1 , Wt ; γ)
                              Ft =
                                              dSt 1                       St        1 =s t 1 jt 1 ,W t =0

       Kalman gain, Kt , is:
                                                          0                        0                     1
                                     Kt = Pt jt        1 Gt     Gt Pt jt        1 Gt        + Rt
       where
                                             dg (St 1 , vt ; γ)
                                     Gt =
                                                  dSt 1                        St       1 =s t jt 1 ,v t =0

       Then
                            st j t     = st j t        1  + Kt yt g st jt                         1 , 0; γ
                           Pt jt       = Pt jt          1   Kt Gt Pt jt 1
Jesús Fernández-Villaverde (PENN)                   Filtering and Likelihood                                  July 10, 2011   53 / 79
Nonlinear Filtering


Problems of EKF

   1   It ignores the non-Gaussianities of Wt and Vt .


   2   It ignores the non-Gaussianities of states distribution.


   3   Approximation error incurred by the linearization.


   4   Biased estimate of the mean and variance.


   5   We need to compute Jacobian and Hessians.


As the sample size grows, those errors accumulate and the …lter diverges.
Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood   July 10, 2011   54 / 79
Nonlinear Filtering


Iterated Extended Kalman Filter I
       Compute st jt 1 and Pt jt                  1   as in EKF.
       Iterate N times on:
                                                         i0                      i0                 1
                                    Kti = Pt jt       1 Gt      Gti Pt jt     1 Gt      + Rt
       where
                                             dg (St 1 , vt ; γ)
                                    Gti =
                                                  dSt 1                      St        i
                                                                                  1 =s t jt 1 ,v t =0

       and
                               sti jt = st jt     1   + Kti yt              g st j t     1 , 0; γ
       Why are we iterating? How many times?
       Then:
                           st j t     = st j t        1   + Kt yt             g stNt
                                                                                   j        1 , 0; γ

                          Pt jt       = Pt jt         1        KtN GtN Pt jt        1

Jesús Fernández-Villaverde (PENN)                 Filtering and Likelihood                              July 10, 2011   55 / 79
Nonlinear Filtering


Second-order Extended Kalman Filter


       We keep second-order terms of the Taylor expansion of transition and
       measurement.


       Theoretically, less biased than EKF.


       Messy algebra.


       In practice, not much improvement.




Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood   July 10, 2011   56 / 79
Nonlinear Filtering


Unscented Kalman Filter I
       Recent proposal by Julier and Uhlmann (1996).
       Based around the unscented transform.
       A set of sigma points is selected to preserve some properties of the
       conditional distribution (for example, the …rst two moments).
       Then, those points are transformed and the properties of the new
       conditional distribution are computed.
       The UKF computes the conditional mean and variance accurately up
       to a third order approximation if the shocks Wt and Vt are Gaussian
       and up to a second order if they are not.
       The sigma points are chosen deterministically and not by simulation
       as in a Monte Carlo method.
       The UKF has the advantage with respect to the EKF that no Jacobian
       or Hessians is required, objects that may be di¢ cult to compute.
Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood   July 10, 2011   57 / 79
Nonlinear Filtering


New State Variable
       We modify the state space by creating a new augmented state
       variable:

                                              St = [St , Wt , Vt ]
       that includes the pure state space and the two random variables Wt
       and Vt .

       We initialize the …lter with


                                    s0 j0 = E (St ) = E (S0 , 0, 0)
                                            2                     3
                                               P0 j0 0      0
                                    P0 j0 = 4 0       R0 0 5
                                               0      0     Q0
Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood   July 10, 2011   58 / 79
Nonlinear Filtering


Sigma Points



       Let L be the dimension of the state variable St .

       For t = 1, we calculate the 2L + 1 sigma points:


       S0,t    1 jt 1     = st      1 jt 1
                                                                                 0.5
       Si ,t   1 jt 1     = st      1 jt 1        (L + λ) Pt            1 jt 1         for i = 1, ..., L
                                                                                 0.5
       Si ,t   1 jt 1     = st      1 jt 1   + (L + λ) Pt               1 jt 1         for i = L + 1, ..., 2L




Jesús Fernández-Villaverde (PENN)            Filtering and Likelihood                        July 10, 2011   59 / 79
Nonlinear Filtering


Parameters


       λ = α2 (L + κ )              L is a scaling parameter.

       α determines the spread of the sigma point and it must belong to the
       unit interval.

       κ is a secondary parameter usually set equal to zero.

       Notation for each of the elements of S :


                                    Si = [Sis , Siw , Siv ] for i = 0, ..., 2L



Jesús Fernández-Villaverde (PENN)              Filtering and Likelihood          July 10, 2011   60 / 79
Nonlinear Filtering


Weights

       Weights for each point:


                            m           λ
                           W0 =
                                      L+λ
                             c          λ
                            W0      =      + 1 α2 + β
                                      L+λ
                            m          c       1
                           W0       = X0 =            for i = 1, ..., 2L
                                           2 (L + λ )

       β incorporates knowledge regarding the conditional distributions.

       For Gaussian distributions, β = 2 is optimal.


Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood   July 10, 2011   61 / 79
Nonlinear Filtering


Algorithm I: Prediction of States

       We compute the transition of the pure states:

                                    Sis,t jt   1   = f Sis,t jt               w
                                                                         1 , Si ,t 1 jt 1 ; γ



       Weighted state
                                                                2L
                                               st j t   1   =   ∑ Wim Sis,t jt       1
                                                                i =0


       Weighted variance:
                                    2L                                                                          0
                  Pt jt   1   =     ∑ Wic           Sis,t jt    1      st j t   1   Sis,t jt   1   st j t   1
                                  i =0


Jesús Fernández-Villaverde (PENN)                   Filtering and Likelihood                        July 10, 2011   62 / 79
Nonlinear Filtering


Algorithm II: Prediction of Observables



       Predicted sigma observables:

                                    Yi ,t jt     1     = g Sis,t jt             v
                                                                           1 , Si ,t jt 1 ; γ

       Predicted observable:
                                                                2L
                                               yt jt    1   =   ∑ Wim Yi ,t jt        1
                                                                i =0




Jesús Fernández-Villaverde (PENN)                    Filtering and Likelihood                   July 10, 2011   63 / 79
Nonlinear Filtering


Algorithm III: Update


       Variance-covariance matrices:


                                    2L
                                    ∑ Wic
                                                                                                              0
                 Pyy ,t    =                         Yi ,t jt    1    yt jt    1   Yi ,t jt   1   yt jt   1
                                    i =0
                                      2L
                                    ∑ Wic
                                                                                                              0
                 Pxy ,t    =                         Sis,t jt    1    st j t   1   Yi ,t jt   1   yt jt   1
                                    i =0

       Kalman gain:

                                                      Kt = Pxy ,t Pyy1
                                                                     ,t




Jesús Fernández-Villaverde (PENN)                  Filtering and Likelihood                       July 10, 2011   64 / 79
Nonlinear Filtering


Algorithm IV: Update

       Update of the state:


                                    s t j t = s t j t + K t yt          yt jt   1



       the update of the variance:


                                      Pt jt = Pt jt        1   + Kt Pyy ,t Kt0

       Finally:
                                                  2                         3
                                                Pt jt             0      0
                                     Pt jt   =4 0                 Rt     0 5
                                                0                 0      Qt
Jesús Fernández-Villaverde (PENN)            Filtering and Likelihood               July 10, 2011   65 / 79
Nonlinear Filtering


Grid-Based Filtering

       Remember that we have the recursion


                                     p st j y t ; γ =
                       R
                         p (st jst 1 ; γ) p st 1 jy t 1 ; γ dst 1
        R R                                                                    p (yt jst ; γ)
                 p (st jst 1 ; γ) p (st 1 jy t 1 ; γ) dst 1 p (yt jst ; γ) dst

       This recursion requires the evaluation of three integrals.

       This suggests the possibility of addressing the problem by computing
       those integrals by a deterministic procedure as a grid method.

       Kitagawa (1987)and Kramer and Sorenson (1988).


Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood        July 10, 2011   66 / 79
Nonlinear Filtering


Grid-Based Filtering I



       We divide the state space into N cells, with center point sti ,
        sti : i = 1, ..., N .


       We substitute the exact conditional densities by discrete densities that
                                          N
       put all the mass at the points sti i =1 .


       We denote δ (x ) is a Dirac function with mass at 0.




Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood   July 10, 2011   67 / 79
Nonlinear Filtering


Grid-Based Filtering II

       Then, approximated distributions and weights:
                                                               N
                        p st j y t     1
                                           ;γ          '      ∑ ωit jt             1δ       st    sti
                                                              i =1
                                                                N
                            p st j y t ; γ             '      ∑ ωit jt             1δ       st    sti
                                                              i =1
                                                                N
                                    ω it jt     1      =      ∑ ωjt            1 jt 1
                                                                                            p sti jstj   1; γ
                                                              j =1

                                                                     ω it jt       1
                                                                                       p yt jsti ; γ
                                        ω it jt        =
                                                                               j
                                                              ∑ N 1 ω t jt
                                                                j=                      1
                                                                                            p yt jstj ; γ



Jesús Fernández-Villaverde (PENN)                   Filtering and Likelihood                                July 10, 2011   68 / 79
Nonlinear Filtering


Approximated Recursion


                                       p st j y t ; γ =
                   h                                  i
          N
                     N
                   ∑ j =1 ω jt 1 jt 1 p sti jstj 1 ; γ p yt jsti ; γ
         ∑          h
                               j                 j
                                                        i
                                                                    j
                                                                      δ st                       sti
        i =1   ∑N 1 ∑N 1 ω t 1 jt 1 p sti jst 1 ; γ p yt jst ; γ
                j=      j=

Compare with

                                        p st j y t ; γ =
                   R
                       p (st jst 1 ; γ) p st 1 jy t 1 ; γ dst 1
    R R                                                                      p (yt jst ; γ)
               p (st jst 1 ; γ) p (st 1 jy t 1 ; γ) dst 1 p (yt jst ; γ) dst
given that
                                                            N
                            p st    1 jy
                                           t 1
                                                 ;γ '      ∑ ωit        1 jt 1 δ   sti
                                                           i =1

Jesús Fernández-Villaverde (PENN)            Filtering and Likelihood                    July 10, 2011   69 / 79
Nonlinear Filtering


Problems

       Grid …lters require a constant readjustment to small changes in the
       model or its parameter values.


       Too computationally expensive to be of any practical bene…t beyond
       very low dimensions.


       Grid points are …xed ex ante and the results are very dependent on
       that choice.


Can we overcome those di¢ culties and preserve the idea of integration?
Yes, through Monte Carlo Integration.

Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood   July 10, 2011   70 / 79
Nonlinear Filtering


Particle Filtering

       Remember,
          1   Transition equation:
                                                St = f ( St       1 , Wt ; γ )
          2   Measurement equation:

                                                  Yt = g (St , Vt ; γ)

       Some Assumptions:
          1   We can partition fWt g into two independent sequences fW1,t g and
              fW2,t g, s.t. Wt = (W1,t , W2,t ) and
              dim (W2,t ) + dim (Vt ) dim (Yt ).
          2   We can always evaluate the conditional densities
              p yt j W 1 , y t 1 , S 0 ; γ .
                       t

          3   The model assigns positive probability to the data.
Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood             July 10, 2011   71 / 79
Nonlinear Filtering


Rewriting the Likelihood Function

       Evaluate the likelihood function of the a sequence of realizations of
       the observable y T at a particular parameter value γ:


                                                    p yT ; γ


       We factorize it as:


                                                           T
                                    p yT ; γ =            ∏p           yt jy t   1
                                                                                     ;γ
                                                          t =1
                  T     Z Z
             =   ∏             p yt jW1 , y t
                                      t            1
                                                       , S 0 ; γ p W1 , S 0 j y t
                                                                    t                     1         t
                                                                                              ; γ dW1 dS0
                 t =1

Jesús Fernández-Villaverde (PENN)           Filtering and Likelihood                            July 10, 2011   72 / 79
Nonlinear Filtering


A Law of Large Numbers

        n                             oN         T
             t jt 1,i      t jt 1,i
If          s0          , w1                            N i.i.d. draws from
                                        i =1     t =1
                                      T
     p W1 , S 0 j y t
        t                  1; γ
                                      t =1
                                           ,   then:


                                           T          N
                                             1
                                        ∏N           ∑p
                                                                        t jt 1,i                 t jt 1,i
                 p yT ; γ '                                      yt j w 1          , yt   1
                                                                                              , s0          ;γ
                                        t =1         i =1



The problem of evaluating the likelihood is equivalent to the problem of
drawing from

                                                                                T
                                               p W1 , S 0 j y t
                                                  t                   1
                                                                          ;γ    t =1



Jesús Fernández-Villaverde (PENN)                    Filtering and Likelihood                               July 10, 2011   73 / 79
Nonlinear Filtering


Introducing Particles
       n                           oN
            t   1,i      t   1,i                                  t                        1
           s0         , w1                 N i.i.d. draws from p W1                            , S0 j y t    1; γ    .
                                    i =1
                                               n              oN
       Each s0 1,i , w1 1,i is a particle and s0 1,i , w1 1,i
               t          t                       t     t
                                                                    a swarm of
                                                               i =1
       particles.
       n                      o
          t jt 1,i    t jt 1,i N
         s0        , w1          N i.i.d. draws from p W1 , S0 jy t 1 ; γ .
                                                          t
                                        i =1

                  t jt 1,i         t jt 1,i
       Each s0          , w1     is a proposed particle and
       n                      o
          t jt 1,i    t jt 1,i N
         s0        , w1           a swarm of proposed particles.
                                        i =1

       Weights:
                                                            t jt 1,i           1 , s t jt 1,i ; γ
                                               p yt jw1                , yt         0
                               i
                              qt    =                             t jt 1,i          1 , s t jt 1,i ; γ
                                           ∑N 1 p yt jw1
                                            i=                               , yt        0

Jesús Fernández-Villaverde (PENN)                   Filtering and Likelihood                                July 10, 2011   74 / 79
Nonlinear Filtering


A Proposition
                                                                               n                          oN
                   N
    si e i
Let e0 , w1        i =1
                          be a draw with replacement from s0 jt
                                                           t                          1,i      t jt 1,i
                                                                                            , w1
                                                                                                           i =1
                   i                                        N
                            si e i
and probabilities qt . Then e0 , w1                         i =1
                                                                   is a draw from p (W1t , S0 jy t ; γ).

Importance of the Proposition:

                                       n                       o
                                          t jt 1,i     t jt 1,i N
   1   It shows how a draw              s0         , w1               from p W1 , S0 jy t 1 ; γ
                                                                                  t
                                      n              oN          i =1
                                          t,i    t,i
       can be used to draw              s 0 , w1            from p (W1 , S0 jy t ; γ).
                                                                         t
                                                      i =1

                           n                oN
                                 t,i  t,i
   2   With a draw                  from p (W1 , S0 jy t ; γ) we can use
                               s 0 , w1             t
                                    n        i =1             o
                                       t +1 jt,i     t +1 jt,i N
       p (W1,t +1 ; γ) to get a draw s0          , w1                and iterate the
                                                                i =1
       procedure.
Jesús Fernández-Villaverde (PENN)             Filtering and Likelihood                  July 10, 2011      75 / 79
Nonlinear Filtering


Sequential Monte Carlo
Step 0, Initialization: Set t            1 and set
p W1 1 , S 0 j y t 1 ; γ = p ( S 0 ; γ ) .
     t
                                                n                                                     oN
                                                   t jt                         1,i        t jt 1,i
Step 1, Prediction: Sample N values s0                                                , w1                      from
                                                                                      i =1
the density p W1 , S0 jy t
               t                               1; γ   = p (W1,t ; γ) p W1t 1 , S0 jy t 1 ; γ                            .
                                                                    t jt 1,i    t jt 1,i
Step 2, Weighting: Assign to                          each draw s0           , w1        the
weight qt .   i
                                  n               oN
                                     t,i      t,i
Step 3, Sampling: Draw s0 , w1                             with rep. from
n                        oN                         i =1
   t jt 1,i
  s0        , w1
                t jt 1,i                                          i N
                               with probabilities qt i =1 . If t < T set
                          i =1
t      t + 1 and go to step 1. Otherwise go to step 4.
                                    n                          o    T
                                         t jt 1,i      t jt 1,i N
Step 4, Likelihood: Use               s0          , w1                to compute:
                                                                              i =1     t =1
                                     T          N
                                           1
                                    ∏N ∑p
                                                                   t jt 1,i                  t jt 1,i
               p yT ; γ '                                   yt j w 1          , yt    1
                                                                                          , s0          ;γ
                                    t =1       i =1
Jesús Fernández-Villaverde (PENN)               Filtering and Likelihood                                July 10, 2011       76 / 79
Nonlinear Filtering


A “Trivial” Application



How do we evaluate the likelihood function p y T jα, β, σ of the nonlinear,
non-Gaussian process:


                                                                 st 1
                                    st      = α+β                               + wt
                                                               1 + st       1
                                    yt      = st + vt

where wt      N (0, σ) and vt                      t (2) given some observables
  T = y T
y     f t gt =1 and s0 .




Jesús Fernández-Villaverde (PENN)                Filtering and Likelihood              July 10, 2011   77 / 79
Nonlinear Filtering




            0,i
   1   Let s0 = s0 for all i.
                                                   n                          oN
                                                        1 j0,i
   2   Generate N i.i.d. draws                         s0        , w 1 j0,i             from N (0, σ).
                                                                                i =1
   3   Evaluate
                                                                                                  1 j0,i
                   1 j0,i           1 j0,i                                                       s0
       p y1 jw1             , y 0 , s0           = pt (2 ) y1                    α+β                  1 j0,i   + w 1 j0,i          .
                                                                                             1 +s 0
                                                                                                                              !!
                                                                                                           1 j0,i
                                                                                                          s0
                                                                              p t (2 ) y 1       α+ β        1 j0,i
                                                                                                                    +w 1 j0,i
                                      i                                                                 1 +s 0
   4   Evaluate the relative weights q1 =                                                                       1 j0,i
                                                                                                                              !!       .
                                                                                                              s
                                                                        ∑ N 1 p t (2 ) y 1
                                                                          i=                          α+ β 0 1 j0,i +w 1 j0,i
                                                                                                            1 +s 0
                                                                 oN                n
                                                                                        1 j0,i
   5   Resample with replacement N values of          , w 1 j0,i       with            s0
                                                      n           i =1
                                                                     oN
                                                         1,i
                         i
       relative weights q1 . Call those sampled values s0 , w 1,i        .
                                                                                                                       i =1
   6   Go to step 1, and iterate 1-4 until the end of the sample.


Jesús Fernández-Villaverde (PENN)                    Filtering and Likelihood                                      July 10, 2011       78 / 79
Nonlinear Filtering


A Law of Large Numbers

A law of the large numbers delivers:


                                                           N
                                                   1
                                                          ∑p
                                                                           1 j0,i             1 j0,i
                   p y1 j y 0 , α, β, σ '                          y1 jw1           , y 0 , s0
                                                   N      i =1



and consequently:


                                         T          N
                                               1
                                       ∏N ∑p
                                                                        t jt 1,i                 t jt 1,i
             p y T α, β, σ '                                     yt jw1            , yt   1
                                                                                              , s0
                                       t =1        i =1




Jesús Fernández-Villaverde (PENN)            Filtering and Likelihood                                  July 10, 2011   79 / 79

Más contenido relacionado

La actualidad más candente

Parameter Uncertainty and Learning in Dynamic Financial Decisions
Parameter Uncertainty and Learning in Dynamic Financial DecisionsParameter Uncertainty and Learning in Dynamic Financial Decisions
Parameter Uncertainty and Learning in Dynamic Financial DecisionsDaniel Bruggisser
 
Lesson 13: Related Rates Problems
Lesson 13: Related Rates ProblemsLesson 13: Related Rates Problems
Lesson 13: Related Rates ProblemsMatthew Leingang
 
The Black-Litterman model in the light of Bayesian portfolio analysis
The Black-Litterman model in the light of Bayesian portfolio analysisThe Black-Litterman model in the light of Bayesian portfolio analysis
The Black-Litterman model in the light of Bayesian portfolio analysisDaniel Bruggisser
 
Lesson 14: Derivatives of Logarithmic and Exponential Functions
Lesson 14: Derivatives of Logarithmic and Exponential FunctionsLesson 14: Derivatives of Logarithmic and Exponential Functions
Lesson 14: Derivatives of Logarithmic and Exponential FunctionsMatthew Leingang
 
04 structured prediction and energy minimization part 1
04 structured prediction and energy minimization part 104 structured prediction and energy minimization part 1
04 structured prediction and energy minimization part 1zukun
 
Lesson 23: The Definite Integral (handout)
Lesson 23: The Definite Integral (handout)Lesson 23: The Definite Integral (handout)
Lesson 23: The Definite Integral (handout)Matthew Leingang
 
Saddlepoint approximations, likelihood asymptotics, and approximate condition...
Saddlepoint approximations, likelihood asymptotics, and approximate condition...Saddlepoint approximations, likelihood asymptotics, and approximate condition...
Saddlepoint approximations, likelihood asymptotics, and approximate condition...jaredtobin
 
Stochastic Calculus Main Results
Stochastic Calculus Main ResultsStochastic Calculus Main Results
Stochastic Calculus Main ResultsSSA KPI
 
Pr 2-bayesian decision
Pr 2-bayesian decisionPr 2-bayesian decision
Pr 2-bayesian decisionshivamsoni123
 
Paris2012 session2
Paris2012 session2Paris2012 session2
Paris2012 session2Cdiscount
 
Tro07 sparse-solutions-talk
Tro07 sparse-solutions-talkTro07 sparse-solutions-talk
Tro07 sparse-solutions-talkmpbchina
 
Lesson 15: Exponential Growth and Decay (handout)
Lesson 15: Exponential Growth and Decay (handout)Lesson 15: Exponential Growth and Decay (handout)
Lesson 15: Exponential Growth and Decay (handout)Matthew Leingang
 
State Space Model
State Space ModelState Space Model
State Space ModelCdiscount
 
CMA-ES with local meta-models
CMA-ES with local meta-modelsCMA-ES with local meta-models
CMA-ES with local meta-modelszyedb
 
UT Austin - Portugal Lectures on Portfolio Choice
UT Austin - Portugal Lectures on Portfolio ChoiceUT Austin - Portugal Lectures on Portfolio Choice
UT Austin - Portugal Lectures on Portfolio Choiceguasoni
 
ABC and empirical likelihood
ABC and empirical likelihoodABC and empirical likelihood
ABC and empirical likelihoodChristian Robert
 
Label propagation - Semisupervised Learning with Applications to NLP
Label propagation - Semisupervised Learning with Applications to NLPLabel propagation - Semisupervised Learning with Applications to NLP
Label propagation - Semisupervised Learning with Applications to NLPDavid Przybilla
 
Measuring Downside Risk — Realised Semivariance
Measuring Downside Risk — Realised SemivarianceMeasuring Downside Risk — Realised Semivariance
Measuring Downside Risk — Realised Semivariancemerzak emerzak
 

La actualidad más candente (19)

Parameter Uncertainty and Learning in Dynamic Financial Decisions
Parameter Uncertainty and Learning in Dynamic Financial DecisionsParameter Uncertainty and Learning in Dynamic Financial Decisions
Parameter Uncertainty and Learning in Dynamic Financial Decisions
 
Lesson 13: Related Rates Problems
Lesson 13: Related Rates ProblemsLesson 13: Related Rates Problems
Lesson 13: Related Rates Problems
 
The Black-Litterman model in the light of Bayesian portfolio analysis
The Black-Litterman model in the light of Bayesian portfolio analysisThe Black-Litterman model in the light of Bayesian portfolio analysis
The Black-Litterman model in the light of Bayesian portfolio analysis
 
Lesson 14: Derivatives of Logarithmic and Exponential Functions
Lesson 14: Derivatives of Logarithmic and Exponential FunctionsLesson 14: Derivatives of Logarithmic and Exponential Functions
Lesson 14: Derivatives of Logarithmic and Exponential Functions
 
04 structured prediction and energy minimization part 1
04 structured prediction and energy minimization part 104 structured prediction and energy minimization part 1
04 structured prediction and energy minimization part 1
 
Lesson 23: The Definite Integral (handout)
Lesson 23: The Definite Integral (handout)Lesson 23: The Definite Integral (handout)
Lesson 23: The Definite Integral (handout)
 
Saddlepoint approximations, likelihood asymptotics, and approximate condition...
Saddlepoint approximations, likelihood asymptotics, and approximate condition...Saddlepoint approximations, likelihood asymptotics, and approximate condition...
Saddlepoint approximations, likelihood asymptotics, and approximate condition...
 
Rouviere
RouviereRouviere
Rouviere
 
Stochastic Calculus Main Results
Stochastic Calculus Main ResultsStochastic Calculus Main Results
Stochastic Calculus Main Results
 
Pr 2-bayesian decision
Pr 2-bayesian decisionPr 2-bayesian decision
Pr 2-bayesian decision
 
Paris2012 session2
Paris2012 session2Paris2012 session2
Paris2012 session2
 
Tro07 sparse-solutions-talk
Tro07 sparse-solutions-talkTro07 sparse-solutions-talk
Tro07 sparse-solutions-talk
 
Lesson 15: Exponential Growth and Decay (handout)
Lesson 15: Exponential Growth and Decay (handout)Lesson 15: Exponential Growth and Decay (handout)
Lesson 15: Exponential Growth and Decay (handout)
 
State Space Model
State Space ModelState Space Model
State Space Model
 
CMA-ES with local meta-models
CMA-ES with local meta-modelsCMA-ES with local meta-models
CMA-ES with local meta-models
 
UT Austin - Portugal Lectures on Portfolio Choice
UT Austin - Portugal Lectures on Portfolio ChoiceUT Austin - Portugal Lectures on Portfolio Choice
UT Austin - Portugal Lectures on Portfolio Choice
 
ABC and empirical likelihood
ABC and empirical likelihoodABC and empirical likelihood
ABC and empirical likelihood
 
Label propagation - Semisupervised Learning with Applications to NLP
Label propagation - Semisupervised Learning with Applications to NLPLabel propagation - Semisupervised Learning with Applications to NLP
Label propagation - Semisupervised Learning with Applications to NLP
 
Measuring Downside Risk — Realised Semivariance
Measuring Downside Risk — Realised SemivarianceMeasuring Downside Risk — Realised Semivariance
Measuring Downside Risk — Realised Semivariance
 

Destacado

Dynare exercise
Dynare exerciseDynare exercise
Dynare exerciseNBER
 
Csvfrictions
CsvfrictionsCsvfrictions
CsvfrictionsNBER
 
Lecture on nk [compatibility mode]
Lecture on nk [compatibility mode]Lecture on nk [compatibility mode]
Lecture on nk [compatibility mode]NBER
 
Econometrics of High-Dimensional Sparse Models
Econometrics of High-Dimensional Sparse ModelsEconometrics of High-Dimensional Sparse Models
Econometrics of High-Dimensional Sparse ModelsNBER
 
Applications: Prediction
Applications: PredictionApplications: Prediction
Applications: PredictionNBER
 
Nuts and bolts
Nuts and boltsNuts and bolts
Nuts and boltsNBER
 
Big Data Analysis
Big Data AnalysisBig Data Analysis
Big Data AnalysisNBER
 
High-Dimensional Methods: Examples for Inference on Structural Effects
High-Dimensional Methods: Examples for Inference on Structural EffectsHigh-Dimensional Methods: Examples for Inference on Structural Effects
High-Dimensional Methods: Examples for Inference on Structural EffectsNBER
 

Destacado (8)

Dynare exercise
Dynare exerciseDynare exercise
Dynare exercise
 
Csvfrictions
CsvfrictionsCsvfrictions
Csvfrictions
 
Lecture on nk [compatibility mode]
Lecture on nk [compatibility mode]Lecture on nk [compatibility mode]
Lecture on nk [compatibility mode]
 
Econometrics of High-Dimensional Sparse Models
Econometrics of High-Dimensional Sparse ModelsEconometrics of High-Dimensional Sparse Models
Econometrics of High-Dimensional Sparse Models
 
Applications: Prediction
Applications: PredictionApplications: Prediction
Applications: Prediction
 
Nuts and bolts
Nuts and boltsNuts and bolts
Nuts and bolts
 
Big Data Analysis
Big Data AnalysisBig Data Analysis
Big Data Analysis
 
High-Dimensional Methods: Examples for Inference on Structural Effects
High-Dimensional Methods: Examples for Inference on Structural EffectsHigh-Dimensional Methods: Examples for Inference on Structural Effects
High-Dimensional Methods: Examples for Inference on Structural Effects
 

Similar a Chapter 4 likelihood

Portfolios and Risk Premia for the Long Run
Portfolios and Risk Premia for the Long RunPortfolios and Risk Premia for the Long Run
Portfolios and Risk Premia for the Long Runguasoni
 
Paris2012 session4
Paris2012 session4Paris2012 session4
Paris2012 session4Cdiscount
 
5. cem granger causality ecm
5. cem granger causality  ecm 5. cem granger causality  ecm
5. cem granger causality ecm Quang Hoang
 
Particle filtering
Particle filteringParticle filtering
Particle filteringWei Wang
 
Conditional probabilities for euro area sovereign default risk - Andre Lucas,...
Conditional probabilities for euro area sovereign default risk - Andre Lucas,...Conditional probabilities for euro area sovereign default risk - Andre Lucas,...
Conditional probabilities for euro area sovereign default risk - Andre Lucas,...SYRTO Project
 
Adiabatic Theorem for Discrete Time Evolution
Adiabatic Theorem for Discrete Time EvolutionAdiabatic Theorem for Discrete Time Evolution
Adiabatic Theorem for Discrete Time Evolutiontanaka-atushi
 
Sequential experimentation in clinical trials
Sequential experimentation in clinical trialsSequential experimentation in clinical trials
Sequential experimentation in clinical trialsSpringer
 
MCQMC 2020 talk: Importance Sampling for a Robust and Efficient Multilevel Mo...
MCQMC 2020 talk: Importance Sampling for a Robust and Efficient Multilevel Mo...MCQMC 2020 talk: Importance Sampling for a Robust and Efficient Multilevel Mo...
MCQMC 2020 talk: Importance Sampling for a Robust and Efficient Multilevel Mo...Chiheb Ben Hammouda
 
Computation of the marginal likelihood
Computation of the marginal likelihoodComputation of the marginal likelihood
Computation of the marginal likelihoodBigMC
 
6. bounds test for cointegration within ardl or vecm
6. bounds test for cointegration within ardl or vecm 6. bounds test for cointegration within ardl or vecm
6. bounds test for cointegration within ardl or vecm Quang Hoang
 
Estimation of the score vector and observed information matrix in intractable...
Estimation of the score vector and observed information matrix in intractable...Estimation of the score vector and observed information matrix in intractable...
Estimation of the score vector and observed information matrix in intractable...Pierre Jacob
 
On the Convergence of Single-Call Stochastic Extra-Gradient Methods
On the Convergence of Single-Call Stochastic Extra-Gradient MethodsOn the Convergence of Single-Call Stochastic Extra-Gradient Methods
On the Convergence of Single-Call Stochastic Extra-Gradient MethodsYu-Guan Hsieh
 
Ch 12 Slides.doc. Introduction of science of business
Ch 12 Slides.doc. Introduction of science of businessCh 12 Slides.doc. Introduction of science of business
Ch 12 Slides.doc. Introduction of science of businessohenebabismark508
 
SPM 12 practical course by Volodymyr B. Bogdanov (Kyiv 2015, Day 2)
SPM 12 practical course by Volodymyr B. Bogdanov (Kyiv 2015, Day 2) SPM 12 practical course by Volodymyr B. Bogdanov (Kyiv 2015, Day 2)
SPM 12 practical course by Volodymyr B. Bogdanov (Kyiv 2015, Day 2) Volodymyr Bogdanov
 
An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...
An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...
An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...Volatility
 

Similar a Chapter 4 likelihood (20)

Portfolios and Risk Premia for the Long Run
Portfolios and Risk Premia for the Long RunPortfolios and Risk Premia for the Long Run
Portfolios and Risk Premia for the Long Run
 
Paris2012 session4
Paris2012 session4Paris2012 session4
Paris2012 session4
 
Basic concepts and how to measure price volatility
Basic concepts and how to measure price volatility Basic concepts and how to measure price volatility
Basic concepts and how to measure price volatility
 
5. cem granger causality ecm
5. cem granger causality  ecm 5. cem granger causality  ecm
5. cem granger causality ecm
 
Particle filtering
Particle filteringParticle filtering
Particle filtering
 
Conditional probabilities for euro area sovereign default risk - Andre Lucas,...
Conditional probabilities for euro area sovereign default risk - Andre Lucas,...Conditional probabilities for euro area sovereign default risk - Andre Lucas,...
Conditional probabilities for euro area sovereign default risk - Andre Lucas,...
 
Adiabatic Theorem for Discrete Time Evolution
Adiabatic Theorem for Discrete Time EvolutionAdiabatic Theorem for Discrete Time Evolution
Adiabatic Theorem for Discrete Time Evolution
 
Sequential experimentation in clinical trials
Sequential experimentation in clinical trialsSequential experimentation in clinical trials
Sequential experimentation in clinical trials
 
MCQMC 2020 talk: Importance Sampling for a Robust and Efficient Multilevel Mo...
MCQMC 2020 talk: Importance Sampling for a Robust and Efficient Multilevel Mo...MCQMC 2020 talk: Importance Sampling for a Robust and Efficient Multilevel Mo...
MCQMC 2020 talk: Importance Sampling for a Robust and Efficient Multilevel Mo...
 
Computation of the marginal likelihood
Computation of the marginal likelihoodComputation of the marginal likelihood
Computation of the marginal likelihood
 
6. bounds test for cointegration within ardl or vecm
6. bounds test for cointegration within ardl or vecm 6. bounds test for cointegration within ardl or vecm
6. bounds test for cointegration within ardl or vecm
 
Estimation of the score vector and observed information matrix in intractable...
Estimation of the score vector and observed information matrix in intractable...Estimation of the score vector and observed information matrix in intractable...
Estimation of the score vector and observed information matrix in intractable...
 
On the Convergence of Single-Call Stochastic Extra-Gradient Methods
On the Convergence of Single-Call Stochastic Extra-Gradient MethodsOn the Convergence of Single-Call Stochastic Extra-Gradient Methods
On the Convergence of Single-Call Stochastic Extra-Gradient Methods
 
Ch 12 Slides.doc. Introduction of science of business
Ch 12 Slides.doc. Introduction of science of businessCh 12 Slides.doc. Introduction of science of business
Ch 12 Slides.doc. Introduction of science of business
 
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
 
SPM 12 practical course by Volodymyr B. Bogdanov (Kyiv 2015, Day 2)
SPM 12 practical course by Volodymyr B. Bogdanov (Kyiv 2015, Day 2) SPM 12 practical course by Volodymyr B. Bogdanov (Kyiv 2015, Day 2)
SPM 12 practical course by Volodymyr B. Bogdanov (Kyiv 2015, Day 2)
 
Deep Learning Opening Workshop - Statistical and Computational Guarantees of ...
Deep Learning Opening Workshop - Statistical and Computational Guarantees of ...Deep Learning Opening Workshop - Statistical and Computational Guarantees of ...
Deep Learning Opening Workshop - Statistical and Computational Guarantees of ...
 
An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...
An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...
An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...
 
Cash Settled Interest Rate Swap Futures
Cash Settled Interest Rate Swap FuturesCash Settled Interest Rate Swap Futures
Cash Settled Interest Rate Swap Futures
 
Ch14_slides.pdf
Ch14_slides.pdfCh14_slides.pdf
Ch14_slides.pdf
 

Más de NBER

FISCAL STIMULUS IN ECONOMIC UNIONS: WHAT ROLE FOR STATES
FISCAL STIMULUS IN ECONOMIC UNIONS: WHAT ROLE FOR STATESFISCAL STIMULUS IN ECONOMIC UNIONS: WHAT ROLE FOR STATES
FISCAL STIMULUS IN ECONOMIC UNIONS: WHAT ROLE FOR STATESNBER
 
Business in the United States Who Owns it and How Much Tax They Pay
Business in the United States Who Owns it and How Much Tax They PayBusiness in the United States Who Owns it and How Much Tax They Pay
Business in the United States Who Owns it and How Much Tax They PayNBER
 
Redistribution through Minimum Wage Regulation: An Analysis of Program Linkag...
Redistribution through Minimum Wage Regulation: An Analysis of Program Linkag...Redistribution through Minimum Wage Regulation: An Analysis of Program Linkag...
Redistribution through Minimum Wage Regulation: An Analysis of Program Linkag...NBER
 
The Distributional E ffects of U.S. Clean Energy Tax Credits
The Distributional Effects of U.S. Clean Energy Tax CreditsThe Distributional Effects of U.S. Clean Energy Tax Credits
The Distributional E ffects of U.S. Clean Energy Tax CreditsNBER
 
An Experimental Evaluation of Strategies to Increase Property Tax Compliance:...
An Experimental Evaluation of Strategies to Increase Property Tax Compliance:...An Experimental Evaluation of Strategies to Increase Property Tax Compliance:...
An Experimental Evaluation of Strategies to Increase Property Tax Compliance:...NBER
 
Nbe rtopicsandrecomvlecture1
Nbe rtopicsandrecomvlecture1Nbe rtopicsandrecomvlecture1
Nbe rtopicsandrecomvlecture1NBER
 
Nbe rcausalpredictionv111 lecture2
Nbe rcausalpredictionv111 lecture2Nbe rcausalpredictionv111 lecture2
Nbe rcausalpredictionv111 lecture2NBER
 
Nber slides11 lecture2
Nber slides11 lecture2Nber slides11 lecture2
Nber slides11 lecture2NBER
 
Recommenders, Topics, and Text
Recommenders, Topics, and TextRecommenders, Topics, and Text
Recommenders, Topics, and TextNBER
 
Machine Learning and Causal Inference
Machine Learning and Causal InferenceMachine Learning and Causal Inference
Machine Learning and Causal InferenceNBER
 
Introduction to Supervised ML Concepts and Algorithms
Introduction to Supervised ML Concepts and AlgorithmsIntroduction to Supervised ML Concepts and Algorithms
Introduction to Supervised ML Concepts and AlgorithmsNBER
 
Jackson nber-slides2014 lecture3
Jackson nber-slides2014 lecture3Jackson nber-slides2014 lecture3
Jackson nber-slides2014 lecture3NBER
 
Jackson nber-slides2014 lecture1
Jackson nber-slides2014 lecture1Jackson nber-slides2014 lecture1
Jackson nber-slides2014 lecture1NBER
 
Acemoglu lecture2
Acemoglu lecture2Acemoglu lecture2
Acemoglu lecture2NBER
 
Acemoglu lecture4
Acemoglu lecture4Acemoglu lecture4
Acemoglu lecture4NBER
 
The NBER Working Paper Series at 20,000 - Joshua Gans
The NBER Working Paper Series at 20,000 - Joshua GansThe NBER Working Paper Series at 20,000 - Joshua Gans
The NBER Working Paper Series at 20,000 - Joshua GansNBER
 
The NBER Working Paper Series at 20,000 - Claudia Goldin
The NBER Working Paper Series at 20,000 - Claudia GoldinThe NBER Working Paper Series at 20,000 - Claudia Goldin
The NBER Working Paper Series at 20,000 - Claudia GoldinNBER
 
The NBER Working Paper Series at 20,000 - James Poterba
The NBER Working Paper Series at 20,000 - James PoterbaThe NBER Working Paper Series at 20,000 - James Poterba
The NBER Working Paper Series at 20,000 - James PoterbaNBER
 
The NBER Working Paper Series at 20,000 - Scott Stern
The NBER Working Paper Series at 20,000 - Scott SternThe NBER Working Paper Series at 20,000 - Scott Stern
The NBER Working Paper Series at 20,000 - Scott SternNBER
 
The NBER Working Paper Series at 20,000 - Glenn Ellison
The NBER Working Paper Series at 20,000 - Glenn EllisonThe NBER Working Paper Series at 20,000 - Glenn Ellison
The NBER Working Paper Series at 20,000 - Glenn EllisonNBER
 

Más de NBER (20)

FISCAL STIMULUS IN ECONOMIC UNIONS: WHAT ROLE FOR STATES
FISCAL STIMULUS IN ECONOMIC UNIONS: WHAT ROLE FOR STATESFISCAL STIMULUS IN ECONOMIC UNIONS: WHAT ROLE FOR STATES
FISCAL STIMULUS IN ECONOMIC UNIONS: WHAT ROLE FOR STATES
 
Business in the United States Who Owns it and How Much Tax They Pay
Business in the United States Who Owns it and How Much Tax They PayBusiness in the United States Who Owns it and How Much Tax They Pay
Business in the United States Who Owns it and How Much Tax They Pay
 
Redistribution through Minimum Wage Regulation: An Analysis of Program Linkag...
Redistribution through Minimum Wage Regulation: An Analysis of Program Linkag...Redistribution through Minimum Wage Regulation: An Analysis of Program Linkag...
Redistribution through Minimum Wage Regulation: An Analysis of Program Linkag...
 
The Distributional E ffects of U.S. Clean Energy Tax Credits
The Distributional Effects of U.S. Clean Energy Tax CreditsThe Distributional Effects of U.S. Clean Energy Tax Credits
The Distributional E ffects of U.S. Clean Energy Tax Credits
 
An Experimental Evaluation of Strategies to Increase Property Tax Compliance:...
An Experimental Evaluation of Strategies to Increase Property Tax Compliance:...An Experimental Evaluation of Strategies to Increase Property Tax Compliance:...
An Experimental Evaluation of Strategies to Increase Property Tax Compliance:...
 
Nbe rtopicsandrecomvlecture1
Nbe rtopicsandrecomvlecture1Nbe rtopicsandrecomvlecture1
Nbe rtopicsandrecomvlecture1
 
Nbe rcausalpredictionv111 lecture2
Nbe rcausalpredictionv111 lecture2Nbe rcausalpredictionv111 lecture2
Nbe rcausalpredictionv111 lecture2
 
Nber slides11 lecture2
Nber slides11 lecture2Nber slides11 lecture2
Nber slides11 lecture2
 
Recommenders, Topics, and Text
Recommenders, Topics, and TextRecommenders, Topics, and Text
Recommenders, Topics, and Text
 
Machine Learning and Causal Inference
Machine Learning and Causal InferenceMachine Learning and Causal Inference
Machine Learning and Causal Inference
 
Introduction to Supervised ML Concepts and Algorithms
Introduction to Supervised ML Concepts and AlgorithmsIntroduction to Supervised ML Concepts and Algorithms
Introduction to Supervised ML Concepts and Algorithms
 
Jackson nber-slides2014 lecture3
Jackson nber-slides2014 lecture3Jackson nber-slides2014 lecture3
Jackson nber-slides2014 lecture3
 
Jackson nber-slides2014 lecture1
Jackson nber-slides2014 lecture1Jackson nber-slides2014 lecture1
Jackson nber-slides2014 lecture1
 
Acemoglu lecture2
Acemoglu lecture2Acemoglu lecture2
Acemoglu lecture2
 
Acemoglu lecture4
Acemoglu lecture4Acemoglu lecture4
Acemoglu lecture4
 
The NBER Working Paper Series at 20,000 - Joshua Gans
The NBER Working Paper Series at 20,000 - Joshua GansThe NBER Working Paper Series at 20,000 - Joshua Gans
The NBER Working Paper Series at 20,000 - Joshua Gans
 
The NBER Working Paper Series at 20,000 - Claudia Goldin
The NBER Working Paper Series at 20,000 - Claudia GoldinThe NBER Working Paper Series at 20,000 - Claudia Goldin
The NBER Working Paper Series at 20,000 - Claudia Goldin
 
The NBER Working Paper Series at 20,000 - James Poterba
The NBER Working Paper Series at 20,000 - James PoterbaThe NBER Working Paper Series at 20,000 - James Poterba
The NBER Working Paper Series at 20,000 - James Poterba
 
The NBER Working Paper Series at 20,000 - Scott Stern
The NBER Working Paper Series at 20,000 - Scott SternThe NBER Working Paper Series at 20,000 - Scott Stern
The NBER Working Paper Series at 20,000 - Scott Stern
 
The NBER Working Paper Series at 20,000 - Glenn Ellison
The NBER Working Paper Series at 20,000 - Glenn EllisonThe NBER Working Paper Series at 20,000 - Glenn Ellison
The NBER Working Paper Series at 20,000 - Glenn Ellison
 

Último

5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...CaraSkikne1
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and stepobaje godwin sunday
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptxmary850239
 
M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxDr. Santhosh Kumar. N
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17Celine George
 
Philosophy of Education and Educational Philosophy
Philosophy of Education  and Educational PhilosophyPhilosophy of Education  and Educational Philosophy
Philosophy of Education and Educational PhilosophyShuvankar Madhu
 
Presentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphPresentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphNetziValdelomar1
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxraviapr7
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfMohonDas
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 
Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationMJDuyan
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfYu Kanazawa / Osaka University
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxEduSkills OECD
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxraviapr7
 
How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17Celine George
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.raviapr7
 

Último (20)

5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...5 charts on South Africa as a source country for international student recrui...
5 charts on South Africa as a source country for international student recrui...
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and step
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptx
 
M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptx
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17
 
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdfPersonal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
 
Philosophy of Education and Educational Philosophy
Philosophy of Education  and Educational PhilosophyPhilosophy of Education  and Educational Philosophy
Philosophy of Education and Educational Philosophy
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 
Presentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphPresentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a Paragraph
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptx
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdf
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 
Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive Education
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptx
 
How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.
 

Chapter 4 likelihood

  • 1. Filtering and Likelihood Inference Jesús Fernández-Villaverde University of Pennsylvania July 10, 2011 Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 1 / 79
  • 2. Introduction Motivation Filtering, smoothing, and forecasting problems are pervasive in economics. Examples: 1 Macroeconomics: evaluating likelihood of DSGE models. 2 Microeconomics: structural models of individual choice with unobserved heterogeneity. 3 Finance: time-varying variance of asset returns. However, …ltering is a complicated endeavor with no simple and exact algorithm. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 2 / 79
  • 3. Introduction Environment I Discrete time t 2 f1, 2, ...g . Why discrete time? 1 Economic data is discrete. 2 Easier math. Comparison with continuous time: 1 Discretize observables. 2 More involved math (stochastic calculus) but often we have extremely powerful results. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 3 / 79
  • 4. Introduction Environment II States St . We will focus on continuous state spaces. Comparison with discrete states: 1 Markov-Switching models. 2 Jumps and continuous changes. Initial state S0 is either known or it comes from p (S0 ; γ) . Properties of p (S0 ; γ)? Stationarity? Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 4 / 79
  • 5. State Space Representations State Space Representations Transition equation: St = f ( St 1 , Wt ; γ ) Measurement equation: Yt = g (St , Vt ; γ) f and g are measurable functions. Interpretation. Modelling origin. Note Markov structure. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 5 / 79
  • 6. State Space Representations Shocks fWt g and fVt g are independent of each other. fWt g is known as process noise and fVt g as measurement noise. Wt and Vt have zero mean. No assumptions on the distribution beyond that. Often, we assume that the variance of Wt is given by Rt and the variance of Vt by Qt . Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 6 / 79
  • 7. State Space Representations DSGE Models and State Space Representations We have the solution of a DSGE model: St = P1 St 1 + P2 Zt Yt = R1 St 1 + R2 Zt This has nearly the same form that St = f ( S t 1 , Wt ; γ ) Yt = g (St , Vt ; γ) We only need to be careful with: 1 To rewrite the measurement equation in terms of St instead of St 1. 2 How we partition Zt into Wt and Vt . Later, we will present an example. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 7 / 79
  • 8. State Space Representations Generalizations I We can accommodate many generalizations by playing with the state de…nition: 1 Serial correlation of shocks. 2 Contemporaneous correlation of shocks. 3 Time changing state space equations. Often, even in…nite histories (for example in a dynamic game) can be tracked by a Lagrangian multiplier. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 8 / 79
  • 9. State Space Representations Generalizations II However, some generalizations can be tricky to accommodate. Take the model: St = f ( St 1 , Wt ; γ ) Yt = g (St , Vt , Yt 1 ; γ) Yt will be an in…nite-memory process. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 9 / 79
  • 10. State Space Representations Conditional Densities From St = f (St 1 , Wt ; γ ) , we can compute p (St jSt 1 ; γ ). From Yt = g (St , Vt ; γ), we can compute p (Yt jSt ; γ) . From St = f (St 1 , Wt ; γ ) and Yt = g (St , Vt ; γ), we have: Yt = g (f (St 1 , Wt ; γ ) , Vt ; γ ) and hence we can compute p (Yt jSt 1 ; γ ). Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 10 / 79
  • 11. Filtering Filtering, Smoothing, and Forecasting Filtering: we are concerned with what we have learned up to current observation. Smoothing: we are concerned with what we learn with the full sample. Forecasting: we are concerned with future realizations. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 11 / 79
  • 12. Filtering Goal of Filtering I Compute conditional densities: p St jy t 1; γ and p (St jy t ; γ) . Why? 1 It allows probability statements regarding the situation of the system. 2 Compute conditional moments: mean, st jt and st jt 1, and variances Pt jt and Pt jt 1 . 3 Other functions of the states. Examples of interest. Theoretical point: do the conditional densities exist? Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 12 / 79
  • 13. Filtering Goals of Filtering II Evaluate the likelihood function of the observables y T at parameter values γ: p yT ; γ Given the Markov structure of our state space representation: T p yT ; γ = ∏p yt jy t 1 ;γ t =1 Then: T p yT ; γ = p (y1 jγ) ∏ p yt jy t 1 ;γ t =2 Z T Z = p (y1 js1 ; γ) dS1 ∏ p (yt jSt ; γ) p St jy t 1 ; γ dSt t =2 T Hence, knowledge of p St jy t 1 ; γ t =1 and p (S1 ; γ) allow the evaluation of the likelihood of the model. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 13 / 79
  • 14. Filtering Two Fundamental Tools 1 Chapman-Kolmogorov equation: Z p St j y t 1 ;γ = p ( St j St 1 ; γ) p St 1 jy t 1 ; γ dSt 1 2 Bayes’theorem: p (yt jSt ; γ) p St jy t 1; γ p St j y t ; γ = p (yt jy t 1 ; γ) where: Z p yt jy t 1 ;γ = p (yt jSt ; γ) p St jy t 1 ; γ dSt Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 14 / 79
  • 15. Filtering Interpretation All …ltering problems have two steps: prediction and update. 1 Chapman-Kolmogorov equation is one-step ahead predictor. 2 Bayes’theorem updates the conditional density of states given the new observation. We can think of those two equations as operators that map measures into measures. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 15 / 79
  • 16. Filtering Recursion for Conditional Distribution Combining the Chapman-Kolmogorov and the Bayes’theorem: p St j y t ; γ = R p (St jSt 1 ; γ) p St 1 jy t 1 ; γ dSt 1 R R p (yt jSt ; γ) p (St jSt 1 ; γ) p (St 1 jy t 1 ; γ) dSt 1 p (yt jSt ; γ) dSt To initiate that recursion, we only need a value for s0 or p (S0 ; γ). Applying the Chapman-Kolmogorov equation once more, we get T p St jy t 1 ; γ t =1 to evaluate the likelihood function. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 16 / 79
  • 17. Filtering Initial Conditions I From previous discussion, we know that we need a value for s1 or p ( S1 ; γ ) . Stationary models: ergodic distribution. Non-stationary models: more complicated. Importance of transformations. Initialization in the case of Kalman …lter. Forgetting conditions. Non-contraction properties of the Bayes operator. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 17 / 79
  • 18. Filtering Smoothing We are interested on the distribution of the state conditional on all the observations, on p St jy T ; γ and p yt jy T ; γ . We compute: Z p St + 1 j y T ; γ p ( St + 1 j St ; γ ) p St j y T ; γ = p St j y t ; γ dSt +1 p ( St + 1 j y t ; γ ) a backward recursion that we initialize with p ST jy T ; γ , T fp (St jy t ; γ)gT=1 and p St jy t t 1; γ t =1 we obtained from …ltering. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 18 / 79
  • 19. Filtering Forecasting We apply the Chapman-Kolmogorov equation recursively, we can get p (St +j jy t ; γ) , j 1. Integrating recursively: Z p yl +1 jy l ; γ = p (yl +1 jSl +1 ; γ) p Sl +1 jy l ; γ dSl +1 from t + 1 to t + j, we get p yt +j jy T ; γ . Clearly smoothing and forecasting require to solve the …ltering problem …rst! Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 19 / 79
  • 20. Filtering Problem of Filtering We have the recursion p St j y t ; γ = R p (St jSt 1 ; γ) p St 1 jy t 1 ; γ dSt 1 R R p (yt jSt ; γ) p (St jSt 1 ; γ) p (St 1 jy t 1 ; γ) dSt 1 p (yt jSt ; γ) dSt A lot of complicated and high dimensional integrals (plus the one involved in the likelihood). In general, we do not have closed form solution for them. Translate, spread, and deform (TSD) the conditional densities in ways that impossibilities to …t them within any known parametric family. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 20 / 79
  • 21. Filtering Exception There is one exception: linear and Gaussian case. Why? Because if the system is linear and Gaussian, all the conditional probabilities are also Gaussian. Linear and Gaussian state spaces models translate and spread the conditional distributions, but they do not deform them. For Gaussian distributions, we only need to track mean and variance (su¢ cient statistics). Kalman …lter accomplishes this goal e¢ ciently. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 21 / 79
  • 22. Kalman Filtering Linear Gaussian Case Let the following system: Transition equation st = Fst 1 + G ωt , ωt N (0, Q ) Measurement equation yt = Hst + υt , υt N (0, R ) Assume we want to write the likelihood function of y T = fyt gT=1 . t Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 22 / 79
  • 23. Kalman Filtering The State Space Representation is Not Unique Take the previous state space representation. Let B be a non-singular squared matrix conforming with F . Then, if st = Bst , F = BFB 1 , G = BG , and H = HB 1, we can write a new, equivalent, representation: Transition equation st + 1 = F st + G ω t , ω t N (0, Q ) Measurement equation yt = H s t + υ t , υ t N (0, R ) Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 23 / 79
  • 24. Kalman Filtering Example I AR(2) process: yt = ρ1 yt 1 + ρ2 zt 2 + σ υ υt , υt N (0, 1) Model is not apparently not Markovian. However, it is trivial to write it in a state space form. In fact, we have many di¤erent state space forms. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 24 / 79
  • 25. Kalman Filtering Example I State Space Representation I: yt ρ1 1 yt 1 συ = + υt ρ2 yt 1 ρ2 0 ρ2 yt 2 0 yt yt = 1 0 ρ2 yt 1 State Space Representation II: yt ρ1 ρ2 yt 1 συ = + υt yt 1 1 0 yt 2 0 yt yt = 1 ρ2 yt 1 1 0 Rotation B = on the second system to get the …rst one. 0 ρ2 Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 25 / 79
  • 26. Kalman Filtering Example II MA(1) process: yt = υt + θυt 1, υt N 0, σ2 , and Eυt υs = 0 for s 6= t. υ State Space Representation I: yt 0 1 yt 1 1 = + υt θυt 0 0 θυt 1 θ yt yt = 1 0 θυt State Space Representation II: st = υt 1 yt = sxt + υt Again both representations are equivalent! Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 26 / 79
  • 27. Kalman Filtering Example III Now we explore a di¤erent issue. Random walk plus drift process: yt = yt 1 + β + σ υ υt , υt N (0, 1) This is even more interesting: we have a unit root and a constant parameter (the drift). State Space Representation: yt 1 1 yt1 συ = + υt β 0 1 β 0 yt yt = 1 0 β Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 27 / 79
  • 28. Kalman Filtering Some Conditions on the State Space Representation We only consider stable systems. A system is stable if for any initial state s0 , the vector of states, st , converges to some unique s . A necessary and su¢ cient condition for the system to be stable is that: jλi (F )j < 1 for all i, where λi (F ) stands for eigenvalue of F . Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 28 / 79
  • 29. Kalman Filtering Introducing the Kalman Filter Developed by Kalman and Bucy. Wide application in science. Basic idea. Prediction, smoothing, and control. Di¤erent derivations. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 29 / 79
  • 30. Kalman Filtering Some De…nitions De…nition Let st jt 1 = E st jy t 1 be the best linear predictor of st given the history of observables until t 1, i.e., y t 1 . De…nition Let yt jt 1 = E yt jy t 1 = Hst jt 1 be the best linear predictor of yt given the history of observables until t 1, i.e., y t 1 . De…nition Let st jt = E (st jy t ) be the best linear predictor of st given the history of observables until t, i.e., s t . Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 30 / 79
  • 31. Kalman Filtering What is the Kalman Filter Trying to Do? Let assume we have st jt 1 and yt jt 1. We observe a new yt . We need to obtain st jt . Note that st +1 jt = Fst jt and yt +1 jt = Hst +1 jt , so we can go back to the …rst step and wait for yt +1 . Therefore, the key question is how to obtain st jt from st jt 1 and yt . Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 31 / 79
  • 32. Kalman Filtering A Minimization Approach to the Kalman Filter Assume we use the following equation to get st jt from yt and st jt 1: st j t = st j t 1 + Kt yt yt jt 1 = st j t 1 + Kt yt Hst jt 1 This formula will have some probabilistic justi…cation (to follow). Kt is called the Kalman …lter gain and it measures how much we update st jt 1 as a function in our error in predicting yt . The question is how to …nd the optimal Kt . The Kalman …lter is about how to build Kt such that optimally update st jt from st jt 1 and yt . How do we …nd the optimal Kt ? Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 32 / 79
  • 33. Kalman Filtering Some Additional De…nitions De…nition 0 Let Σt jt 1 E st st jt 1 st st jt 1 jy t 1 be the predicting error variance covariance matrix of st given the history of observables until t 1, i.e. y t 1 . De…nition 0 Let Ωt jt 1 E yt yt jt 1 yt yt jt 1 jy t 1 be the predicting error variance covariance matrix of yt given the history of observables until t 1, i.e. y t 1 . De…nition 0 Let Σt jt E st st j tjy t be the predicting error variance st st j t covariance matrix of st given the history of observables until t, i.e. y t . Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 33 / 79
  • 34. Kalman Filtering The Kalman Filter Algorithm I Given Σt jt 1, yt , and st jt 1, we can now set the Kalman …lter algorithm. Let Σt jt 1, then we compute: 0 Ω t jt 1 E yt yt jt 1 yt yt jt 1 jy t 1 0 0 1 s t j t 1 st s t j t 1 H 0 H st B 0 C = E@ + υ t st st j t 1 H 0 A + H st st j t 1 υ t0 + υ υ 0 jy t 1 t t 0 = HΣt jt 1H +R Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 34 / 79
  • 35. Kalman Filtering The Kalman Filter Algorithm II Let Σt jt 1, then we compute: 0 E yt yt jt 1 st st j t 1 jy t 1 = 0 ! H s t s t j t 1 st st j t 1 E 0 t 1 = HΣt jt 1 + υ t st st j t 1 jy Let Σt jt 1, then we compute: 1 Kt = Σ t j t 1H 0 HΣt jt 1H 0 +R Let Σt jt 1 , st j t 1 , Kt , and yt , then we compute: st j t = st j t 1 + Kt yt Hst jt 1 Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 35 / 79
  • 36. Kalman Filtering Finding the Optimal Gain We want Kt such that min Σt jt . Thus: 1 Kt = Σ t j t 1H 0 HΣt jt 1H 0 +R with the optimal update of st jt given yt and st jt 1 being: st j t = st j t 1 + Kt yt Hst jt 1 Intuition: note that we can rewrite Kt in the following way: Kt = Σ t j t 1H 0 Ω t jt 1 1 1 If we did a big mistake forecasting st jt 1 using past information (Σt jt 1 large), we give a lot of weight to the new information (Kt large). 2 If the new information is noise (R large), we give a lot of weight to the old prediction (Kt small). Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 36 / 79
  • 37. Kalman Filtering Example Assume the following model in state space form: Transition equation: st = µ + ω t , ω t N 0, σ2 ω Measurement equation: yt = s t + υ t , υ t N 0, σ2 υ Let σ2 = qσ2 . υ ω Then, if Σ1 j0 = σ2 , (s1 is drawn from the ergodic distribution of st ): ω 1 1 K1 = σ 2 ω ∝ . 1+q 1+q Therefore, the bigger σ2 relative to σ2 (the bigger q), the lower K1 υ ω and the less we trust y1 . Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 37 / 79
  • 38. Kalman Filtering The Kalman Filter Algorithm III Let Σt jt 1 , st j t 1 , Kt , and yt . Then, we compute: 0 Σ t jt E st st j t st st j t jy t = 0 0 1 st st j t st j t 1 1 st B 0 st st jt 1 yt Hst jt 1 Kt0 C B C EB 0 C = Σ t jt 1 Kt HΣt jt 1 @ Kt yt Hst jt 1 st st jt 1 + A 0 0 t Kt yt Hst jt 1 yt Hst jt 1 Kt jy where st st j t = s t st j t 1 Kt yt Hst jt 1 . Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 38 / 79
  • 39. Kalman Filtering The Kalman Filter Algorithm IV Let Σt jt 1 , st j t 1 , Kt , and yt , then we compute: Σt +1 jt = F Σt jt F 0 + GQG 0 Let st jt , then we compute: 1 st +1 jt = Fst jt 2 yt +1 jt = Hst +1 jt Therefore, from st jt 1, Σ t jt 1, and yt we compute st jt and Σt jt . We also compute yt jt 1 and Ωt jt 1 to help (later) to calculate the likelihood function of y T = fyt gT=1 . t Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 39 / 79
  • 40. Kalman Filtering The Kalman Filter Algorithm: A Review We start with st jt 1 and Σt jt 1. Then, we observe yt and: Ω t jt 1 = HΣt jt 1H 0 +R yt jt 1 = Hst jt 1 1 Kt = Σ t j t 1H 0 HΣt jt 1H 0 +R Σ t jt = Σ t jt 1 Kt HΣt jt 1 st j t = st j t 1 + K t yt Hst jt 1 Σt +1 jt = F Σt jt F 0 + GQG 0 st +1 jt = Fst jt We …nish with st +1 jt and Σt +1 jt . Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 40 / 79
  • 41. Kalman Filtering Writing the Likelihood Function Likelihood function of y T = fyt gT=1 : t log p y T jF , G , H, Q, R = T ∑ log p yt jy t 1 F , G , H, Q, R = t =1 T N 1 1 0 ∑ 2 log 2π + log Ωt jt 2 1 + ς t Ω t jt 1 ς t 2 1 t =1 where: ςt = yt yt jt 1 = yt Hst jt 1 is white noise and: Ω t jt 1 = Ht Σ t j t 0 1 Ht +R Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 41 / 79
  • 42. Kalman Filtering Initial conditions for the Kalman Filter An important step in the Kalman Filter is to set the initial conditions. Initial conditions s1 j0 and Σ1 j0 . Where do they come from? Since we only consider stable system, the standard approach is to set: s1 j 0 = s Σ 1 j0 = Σ where s solves: s = Fs Σ = F Σ F 0 + GQG 0 How do we …nd Σ ? 1 Σ = [I F F] vec (GQG 0 ) Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 42 / 79
  • 43. Kalman Filtering Initial conditions for the Kalman Filter II Under the following conditions: 1 The system is stable, i.e. all eigenvalues of F are strictly less than one in absolute value. 2 GQG 0 and R are p.s.d. symmetric. 3 Σ1 j0 is p.s.d. symmetric. Then Σt +1 jt ! Σ . Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 43 / 79
  • 44. Kalman Filtering Remarks 1 There are more general theorems than the one just described. 2 Those theorems are based on non-stable systems. 3 Since we are going to work with stable system the former theorem is enough. 4 Last theorem gives us a way to …nd Σ as Σt +1 jt ! Σ for any Σ1 j0 we start with. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 44 / 79
  • 45. The Kalman Filter and DSGE models The Kalman Filter and DSGE models Basic real business cycle model: ∞ max E0 ∑ βt flog ct + ψ log (1 lt )g t =0 ct + kt +1 = ktα (e zt lt )1 α + (1 δ) kt zt = ρzt 1 + σεt , εt N (0, 1) Equilibrium conditions: 1 1 = βEt αktα+1 (e zt +1 lt +1 )1 α + 1 δ 1 ct ct + 1 lt ψ ct = (1 α) ktα (e zt lt )1 α 1 lt ct + kt +1 = ktα (e zt lt )1 α + (1 δ) kt zt = ρzt 1 + σεt Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 45 / 79
  • 46. The Kalman Filter and DSGE models The Kalman Filter and Linearized DSGE Models We loglinearize (or linearize) the equilibrium conditions around the steady state. Alternatives: particle …lter. We assume that we have data on: 1 log outputt 2 log lt 3 log ct 0 s.t. a linearly additive measurement error Vt = v1,t v2,t v3,t . Why measurement error? Stochastic singularity. Degrees of freedom in the measurement equation. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 46 / 79
  • 47. The Kalman Filter and DSGE models Policy Functions We need to write the model in state space form. Remember that a loglinear solution has the form: b b kt +1 = p1 kt + p2 zt and output t b = q1 kt + q2 zt blt b = r1 kt + r2 zt bt c b = u1 kt + u2 zt Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 47 / 79
  • 48. The Kalman Filter and DSGE models Writing the Likelihood Function Transition equation: 0 1 0 10 1 0 1 1 1 0 0 1 0 @ kt A = @ 0 p1 p2 A@ kt 1 A + @ b b 0 A t . |{z} zt 0 0 ρ zt 1 σ ω | {z } | {z }| {z } | {z } t st F st 1 G Measurement equation: 0 1 0 10 1 0 1 log outputt log y q1 q2 1 v1,t @ log lt A = @ log l r1 r2 A@ kt A + @ b v2,t A log ct log c u1 u2 zt v3,t | {z } | {z }| {z } | {z } yt H st υ Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 48 / 79
  • 49. The Kalman Filter and DSGE models The Solution to the Model in State Space Form Now, with y T , F , G , H, Q, and R as de…ned before... ...we can use the Ricatti equations to evaluate the likelihood function: log p y T jγ = log p y T jF , G , H, Q, R where γ = fα, β, ρ, ψ, δ, σg . Cross-equations restrictions implied by equilibrium solution. With the likelihood, we can do inference! Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 49 / 79
  • 50. Nonlinear Filtering Nonlinear Filtering Di¤erent approaches. Deterministic …ltering: 1 Kalman family. 2 Grid-based …ltering. Simulation …ltering: 1 McMc. 2 Sequential Monte Carlo. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 50 / 79
  • 51. Nonlinear Filtering Kalman Family of Filters Use ideas of Kalman …ltering to NLGF problems. Non-optimal …lters. Di¤erent implementations: 1 Extended Kalman …lter. 2 Iterated Extended Kalman …lter. 3 Second-order Extended Kalman …lter. 4 Unscented Kalman …lter. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 51 / 79
  • 52. Nonlinear Filtering The Extended Kalman Filter EKF is historically the …rst descendant of the Kalman …lter. EKF deals with nonlinearities with a …rst order approximation to the system and applying the Kalman …lter to this approximation. Non-Gaussianities are ignored. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 52 / 79
  • 53. Nonlinear Filtering Algorithm Given st 1 j t 1 , st j t 1 = f st 1 jt 1 , 0; γ . Then: 0 Pt jt 1 = Qt 1 + Ft Pt 1 j t 1 Ft where df (St 1 , Wt ; γ) Ft = dSt 1 St 1 =s t 1 jt 1 ,W t =0 Kalman gain, Kt , is: 0 0 1 Kt = Pt jt 1 Gt Gt Pt jt 1 Gt + Rt where dg (St 1 , vt ; γ) Gt = dSt 1 St 1 =s t jt 1 ,v t =0 Then st j t = st j t 1 + Kt yt g st jt 1 , 0; γ Pt jt = Pt jt 1 Kt Gt Pt jt 1 Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 53 / 79
  • 54. Nonlinear Filtering Problems of EKF 1 It ignores the non-Gaussianities of Wt and Vt . 2 It ignores the non-Gaussianities of states distribution. 3 Approximation error incurred by the linearization. 4 Biased estimate of the mean and variance. 5 We need to compute Jacobian and Hessians. As the sample size grows, those errors accumulate and the …lter diverges. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 54 / 79
  • 55. Nonlinear Filtering Iterated Extended Kalman Filter I Compute st jt 1 and Pt jt 1 as in EKF. Iterate N times on: i0 i0 1 Kti = Pt jt 1 Gt Gti Pt jt 1 Gt + Rt where dg (St 1 , vt ; γ) Gti = dSt 1 St i 1 =s t jt 1 ,v t =0 and sti jt = st jt 1 + Kti yt g st j t 1 , 0; γ Why are we iterating? How many times? Then: st j t = st j t 1 + Kt yt g stNt j 1 , 0; γ Pt jt = Pt jt 1 KtN GtN Pt jt 1 Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 55 / 79
  • 56. Nonlinear Filtering Second-order Extended Kalman Filter We keep second-order terms of the Taylor expansion of transition and measurement. Theoretically, less biased than EKF. Messy algebra. In practice, not much improvement. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 56 / 79
  • 57. Nonlinear Filtering Unscented Kalman Filter I Recent proposal by Julier and Uhlmann (1996). Based around the unscented transform. A set of sigma points is selected to preserve some properties of the conditional distribution (for example, the …rst two moments). Then, those points are transformed and the properties of the new conditional distribution are computed. The UKF computes the conditional mean and variance accurately up to a third order approximation if the shocks Wt and Vt are Gaussian and up to a second order if they are not. The sigma points are chosen deterministically and not by simulation as in a Monte Carlo method. The UKF has the advantage with respect to the EKF that no Jacobian or Hessians is required, objects that may be di¢ cult to compute. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 57 / 79
  • 58. Nonlinear Filtering New State Variable We modify the state space by creating a new augmented state variable: St = [St , Wt , Vt ] that includes the pure state space and the two random variables Wt and Vt . We initialize the …lter with s0 j0 = E (St ) = E (S0 , 0, 0) 2 3 P0 j0 0 0 P0 j0 = 4 0 R0 0 5 0 0 Q0 Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 58 / 79
  • 59. Nonlinear Filtering Sigma Points Let L be the dimension of the state variable St . For t = 1, we calculate the 2L + 1 sigma points: S0,t 1 jt 1 = st 1 jt 1 0.5 Si ,t 1 jt 1 = st 1 jt 1 (L + λ) Pt 1 jt 1 for i = 1, ..., L 0.5 Si ,t 1 jt 1 = st 1 jt 1 + (L + λ) Pt 1 jt 1 for i = L + 1, ..., 2L Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 59 / 79
  • 60. Nonlinear Filtering Parameters λ = α2 (L + κ ) L is a scaling parameter. α determines the spread of the sigma point and it must belong to the unit interval. κ is a secondary parameter usually set equal to zero. Notation for each of the elements of S : Si = [Sis , Siw , Siv ] for i = 0, ..., 2L Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 60 / 79
  • 61. Nonlinear Filtering Weights Weights for each point: m λ W0 = L+λ c λ W0 = + 1 α2 + β L+λ m c 1 W0 = X0 = for i = 1, ..., 2L 2 (L + λ ) β incorporates knowledge regarding the conditional distributions. For Gaussian distributions, β = 2 is optimal. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 61 / 79
  • 62. Nonlinear Filtering Algorithm I: Prediction of States We compute the transition of the pure states: Sis,t jt 1 = f Sis,t jt w 1 , Si ,t 1 jt 1 ; γ Weighted state 2L st j t 1 = ∑ Wim Sis,t jt 1 i =0 Weighted variance: 2L 0 Pt jt 1 = ∑ Wic Sis,t jt 1 st j t 1 Sis,t jt 1 st j t 1 i =0 Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 62 / 79
  • 63. Nonlinear Filtering Algorithm II: Prediction of Observables Predicted sigma observables: Yi ,t jt 1 = g Sis,t jt v 1 , Si ,t jt 1 ; γ Predicted observable: 2L yt jt 1 = ∑ Wim Yi ,t jt 1 i =0 Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 63 / 79
  • 64. Nonlinear Filtering Algorithm III: Update Variance-covariance matrices: 2L ∑ Wic 0 Pyy ,t = Yi ,t jt 1 yt jt 1 Yi ,t jt 1 yt jt 1 i =0 2L ∑ Wic 0 Pxy ,t = Sis,t jt 1 st j t 1 Yi ,t jt 1 yt jt 1 i =0 Kalman gain: Kt = Pxy ,t Pyy1 ,t Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 64 / 79
  • 65. Nonlinear Filtering Algorithm IV: Update Update of the state: s t j t = s t j t + K t yt yt jt 1 the update of the variance: Pt jt = Pt jt 1 + Kt Pyy ,t Kt0 Finally: 2 3 Pt jt 0 0 Pt jt =4 0 Rt 0 5 0 0 Qt Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 65 / 79
  • 66. Nonlinear Filtering Grid-Based Filtering Remember that we have the recursion p st j y t ; γ = R p (st jst 1 ; γ) p st 1 jy t 1 ; γ dst 1 R R p (yt jst ; γ) p (st jst 1 ; γ) p (st 1 jy t 1 ; γ) dst 1 p (yt jst ; γ) dst This recursion requires the evaluation of three integrals. This suggests the possibility of addressing the problem by computing those integrals by a deterministic procedure as a grid method. Kitagawa (1987)and Kramer and Sorenson (1988). Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 66 / 79
  • 67. Nonlinear Filtering Grid-Based Filtering I We divide the state space into N cells, with center point sti , sti : i = 1, ..., N . We substitute the exact conditional densities by discrete densities that N put all the mass at the points sti i =1 . We denote δ (x ) is a Dirac function with mass at 0. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 67 / 79
  • 68. Nonlinear Filtering Grid-Based Filtering II Then, approximated distributions and weights: N p st j y t 1 ;γ ' ∑ ωit jt 1δ st sti i =1 N p st j y t ; γ ' ∑ ωit jt 1δ st sti i =1 N ω it jt 1 = ∑ ωjt 1 jt 1 p sti jstj 1; γ j =1 ω it jt 1 p yt jsti ; γ ω it jt = j ∑ N 1 ω t jt j= 1 p yt jstj ; γ Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 68 / 79
  • 69. Nonlinear Filtering Approximated Recursion p st j y t ; γ = h i N N ∑ j =1 ω jt 1 jt 1 p sti jstj 1 ; γ p yt jsti ; γ ∑ h j j i j δ st sti i =1 ∑N 1 ∑N 1 ω t 1 jt 1 p sti jst 1 ; γ p yt jst ; γ j= j= Compare with p st j y t ; γ = R p (st jst 1 ; γ) p st 1 jy t 1 ; γ dst 1 R R p (yt jst ; γ) p (st jst 1 ; γ) p (st 1 jy t 1 ; γ) dst 1 p (yt jst ; γ) dst given that N p st 1 jy t 1 ;γ ' ∑ ωit 1 jt 1 δ sti i =1 Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 69 / 79
  • 70. Nonlinear Filtering Problems Grid …lters require a constant readjustment to small changes in the model or its parameter values. Too computationally expensive to be of any practical bene…t beyond very low dimensions. Grid points are …xed ex ante and the results are very dependent on that choice. Can we overcome those di¢ culties and preserve the idea of integration? Yes, through Monte Carlo Integration. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 70 / 79
  • 71. Nonlinear Filtering Particle Filtering Remember, 1 Transition equation: St = f ( St 1 , Wt ; γ ) 2 Measurement equation: Yt = g (St , Vt ; γ) Some Assumptions: 1 We can partition fWt g into two independent sequences fW1,t g and fW2,t g, s.t. Wt = (W1,t , W2,t ) and dim (W2,t ) + dim (Vt ) dim (Yt ). 2 We can always evaluate the conditional densities p yt j W 1 , y t 1 , S 0 ; γ . t 3 The model assigns positive probability to the data. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 71 / 79
  • 72. Nonlinear Filtering Rewriting the Likelihood Function Evaluate the likelihood function of the a sequence of realizations of the observable y T at a particular parameter value γ: p yT ; γ We factorize it as: T p yT ; γ = ∏p yt jy t 1 ;γ t =1 T Z Z = ∏ p yt jW1 , y t t 1 , S 0 ; γ p W1 , S 0 j y t t 1 t ; γ dW1 dS0 t =1 Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 72 / 79
  • 73. Nonlinear Filtering A Law of Large Numbers n oN T t jt 1,i t jt 1,i If s0 , w1 N i.i.d. draws from i =1 t =1 T p W1 , S 0 j y t t 1; γ t =1 , then: T N 1 ∏N ∑p t jt 1,i t jt 1,i p yT ; γ ' yt j w 1 , yt 1 , s0 ;γ t =1 i =1 The problem of evaluating the likelihood is equivalent to the problem of drawing from T p W1 , S 0 j y t t 1 ;γ t =1 Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 73 / 79
  • 74. Nonlinear Filtering Introducing Particles n oN t 1,i t 1,i t 1 s0 , w1 N i.i.d. draws from p W1 , S0 j y t 1; γ . i =1 n oN Each s0 1,i , w1 1,i is a particle and s0 1,i , w1 1,i t t t t a swarm of i =1 particles. n o t jt 1,i t jt 1,i N s0 , w1 N i.i.d. draws from p W1 , S0 jy t 1 ; γ . t i =1 t jt 1,i t jt 1,i Each s0 , w1 is a proposed particle and n o t jt 1,i t jt 1,i N s0 , w1 a swarm of proposed particles. i =1 Weights: t jt 1,i 1 , s t jt 1,i ; γ p yt jw1 , yt 0 i qt = t jt 1,i 1 , s t jt 1,i ; γ ∑N 1 p yt jw1 i= , yt 0 Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 74 / 79
  • 75. Nonlinear Filtering A Proposition n oN N si e i Let e0 , w1 i =1 be a draw with replacement from s0 jt t 1,i t jt 1,i , w1 i =1 i N si e i and probabilities qt . Then e0 , w1 i =1 is a draw from p (W1t , S0 jy t ; γ). Importance of the Proposition: n o t jt 1,i t jt 1,i N 1 It shows how a draw s0 , w1 from p W1 , S0 jy t 1 ; γ t n oN i =1 t,i t,i can be used to draw s 0 , w1 from p (W1 , S0 jy t ; γ). t i =1 n oN t,i t,i 2 With a draw from p (W1 , S0 jy t ; γ) we can use s 0 , w1 t n i =1 o t +1 jt,i t +1 jt,i N p (W1,t +1 ; γ) to get a draw s0 , w1 and iterate the i =1 procedure. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 75 / 79
  • 76. Nonlinear Filtering Sequential Monte Carlo Step 0, Initialization: Set t 1 and set p W1 1 , S 0 j y t 1 ; γ = p ( S 0 ; γ ) . t n oN t jt 1,i t jt 1,i Step 1, Prediction: Sample N values s0 , w1 from i =1 the density p W1 , S0 jy t t 1; γ = p (W1,t ; γ) p W1t 1 , S0 jy t 1 ; γ . t jt 1,i t jt 1,i Step 2, Weighting: Assign to each draw s0 , w1 the weight qt . i n oN t,i t,i Step 3, Sampling: Draw s0 , w1 with rep. from n oN i =1 t jt 1,i s0 , w1 t jt 1,i i N with probabilities qt i =1 . If t < T set i =1 t t + 1 and go to step 1. Otherwise go to step 4. n o T t jt 1,i t jt 1,i N Step 4, Likelihood: Use s0 , w1 to compute: i =1 t =1 T N 1 ∏N ∑p t jt 1,i t jt 1,i p yT ; γ ' yt j w 1 , yt 1 , s0 ;γ t =1 i =1 Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 76 / 79
  • 77. Nonlinear Filtering A “Trivial” Application How do we evaluate the likelihood function p y T jα, β, σ of the nonlinear, non-Gaussian process: st 1 st = α+β + wt 1 + st 1 yt = st + vt where wt N (0, σ) and vt t (2) given some observables T = y T y f t gt =1 and s0 . Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 77 / 79
  • 78. Nonlinear Filtering 0,i 1 Let s0 = s0 for all i. n oN 1 j0,i 2 Generate N i.i.d. draws s0 , w 1 j0,i from N (0, σ). i =1 3 Evaluate 1 j0,i 1 j0,i 1 j0,i s0 p y1 jw1 , y 0 , s0 = pt (2 ) y1 α+β 1 j0,i + w 1 j0,i . 1 +s 0 !! 1 j0,i s0 p t (2 ) y 1 α+ β 1 j0,i +w 1 j0,i i 1 +s 0 4 Evaluate the relative weights q1 = 1 j0,i !! . s ∑ N 1 p t (2 ) y 1 i= α+ β 0 1 j0,i +w 1 j0,i 1 +s 0 oN n 1 j0,i 5 Resample with replacement N values of , w 1 j0,i with s0 n i =1 oN 1,i i relative weights q1 . Call those sampled values s0 , w 1,i . i =1 6 Go to step 1, and iterate 1-4 until the end of the sample. Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 78 / 79
  • 79. Nonlinear Filtering A Law of Large Numbers A law of the large numbers delivers: N 1 ∑p 1 j0,i 1 j0,i p y1 j y 0 , α, β, σ ' y1 jw1 , y 0 , s0 N i =1 and consequently: T N 1 ∏N ∑p t jt 1,i t jt 1,i p y T α, β, σ ' yt jw1 , yt 1 , s0 t =1 i =1 Jesús Fernández-Villaverde (PENN) Filtering and Likelihood July 10, 2011 79 / 79