# Could anyone give me ‍the function 'kf'

**URL:** <https://forum.dynare.org/t/could-anyone-give-me-the-function-kf/5468>\
**Category:** Dynare help (legacy posts)\
**Created:** [26 April 2016 09:36 UTC](https://forum.dynare.org/t/could-anyone-give-me-the-function-kf/5468 "2016-04-26T09:36:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![flye](https://forum.dynare.org/letter_avatar_proxy/v4/letter/f/a88e57/32.png) [@flye](https://forum.dynare.org/u/flye)\
**Post date:** [26 April 2016 09:36 UTC](https://forum.dynare.org/t/could-anyone-give-me-the-function-kf/5468/1 "2016-04-26T09:36:56Z")

</div>

Dear all,  
I am trying to run the codes of the paper " The effects of monetary policy news and surprises " by Milani and Treadwell (2012), but got the following error:

Undefined function ‘kf’ for input arguments of type ‘double’.

Error in likelihood\_RE\_ALL (line 887)  
[shatnew,signew,lh]=kf(data(it,:)’,H,S0,P0,F,G);

Error in MH\_RE\_ALL (line 78)  
[loglike,S]=likelihood\_RE\_ALL(data,theta);

Could anyone give me ‍the function ‘kf’ and some guidance?  
Thank you very much!

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [28 April 2016 07:59 UTC](https://forum.dynare.org/t/could-anyone-give-me-the-function-kf/5468/2 "2016-04-28T07:59:38Z")

</div>

That seems to be a Kalman Filter function. Hard to tell what the original function was. The closest to this seems to be the one in the replication file of Justiniano/Primiceri/Tambalotti (2013) in the AEJ Macro. It is attached.  
[kf.m](https://forum.dynare.org/uploads/default/original/2X/0/0909b210effeda4888f0692db0e59ef98cbc8232.m) (1.39 KB)

---

<div class="post-metadata">

**Author:** ![flye](https://forum.dynare.org/letter_avatar_proxy/v4/letter/f/a88e57/32.png) [@flye](https://forum.dynare.org/u/flye)\
**Post date:** [29 April 2016 04:56 UTC](https://forum.dynare.org/t/could-anyone-give-me-the-function-kf/5468/3 "2016-04-29T04:56:00Z")

</div>

Dear Pfeifer,

Thank you for the reply. The function ‘kf’ you gave me can work very well.

Once again, thank you very much for your help.
