File Exchange

image thumbnail

Kalman Filter Application CIR

version 1.0 (25.1 KB) by

Estimates the parameters of the CIR model on a generated term structure

12 Downloads

Updated

View License

3 .m files, 1) simulates a term structure using the CIR model, 2-3) take this simulation and estimates the parameters of the model.
also includes a set of results, take mean() and std() of this to see how good the filter is.

If the implementation is good, the inputs should equal the outputs, run this 200 times.

For details see;

http://www.bankofcanada.ca/en/res/wp/2001/wp01-15a.pdf
and/or
Ren-Raw Chen and Louis Scott, “Multi-Factor Cox-Ingersoll-Ross Models of the Term Structure: Estimates and Tests from a Kalman Filter Model,” The Journal of Real Estate Finance and Economics 27, no. 2 (2003): 143-172.
etc.

Please comment or leave suggestions.
thanks bill, submission #27493 is included in the BSD

Comments and Ratings (4)

Foroguh

 

I am trying to replicate your results but the code as it is produces errors in the optimization part and it stops around the 50th iteration. The final mean values are very far from the true one. Moreover the numbers that I am getting are very far from the ones in CIR200.mat. Can you please help?

Steve G

I believe there is another problem in the code, LLtwoCIR, in the calculation of the Q matrix, the (1,1) element of which is,

(theta1*sigma1*sigma1*(1-exp(-kappa1*dt))^2/(2*kappa1)+sigma1*sigma1/kappa1*(exp(-kappa1*dt)-exp(-2*kappa1*dt)))*AdjS(1)

I think the correct code is,
theta1*sigma1*sigma1*(1-exp(-kappa1*dt))^2/(2*kappa1)+sigma1*sigma1/kappa1*(exp(-kappa1*dt)-exp(-2*kappa1*dt))*AdjS(1)
The AdjS only multiplies the second term, not both the first and second, see Chen and Scott (2003), page 147, second formula.

Thanks

luisa cutillo

I am trying to replicate your results but the code as it is produces errors in the optimization part and it stops around the 50th iteration. The final mean values are very far from the true one. Moreover the numbers that I am getting are very far from the ones in CIR200.mat. Can you please help? I am just running your code as it is with matlab 2008. Thanks in advance. Luisa.

luisa cutillo

I am trying to replicate your results but the code as it is produces errors in the optimization part and it stops around the 50th iteration. The final mean values are very far from the true one. Moreover the numbers that I am getting are very far from the ones in CIR200.mat. Can you please help? I am just running your code as it is with matlab 2008. Thanks in advance. Luisa.

MATLAB Release
MATLAB 7.7 (R2008b)
Acknowledgements

Inspired by: Kalman Filter Application

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video