2 .m files, 3 xls files with data from German, US, UK zero coupon bonds.
Files estimate the parameters on these bonds, the optimizer doesn't really work that well for this problem, so if some-one has a solution, please let me know.
For details of methodology see;
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.
Please comment or leave suggestions.
thanks Bill, 27493
Nils Delava (2020). Kalman Filter Application two factor CIR (https://www.mathworks.com/matlabcentral/fileexchange/27705-kalman-filter-application-two-factor-cir), MATLAB Central File Exchange. Retrieved .
Hello Hils, could you tell me how did you decide the initial parameter value as input ? Thank you very much!
how can i run this code?
I believe there is another problem in the code, LLtwoCIR, in the calculation of the Q matrix, the (1,1) element of which is,
I think the correct code is,
The AdjS only multiplies the second term, not both the first and second, see Chen and Scott (2003), page 147, second formula.
I like the simple code, however I donot understand the following code segment:
Given the KalmanGain definition:
The above VarS is not symmetric, and (1-KalmanGain*H) is not correct either. I believe the corrrect calculation should be:
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.
Dear Nils, dear Yan,
How do these optimizer tricks look like? I currently work on a Kalman Filter Application for a (correlated) multifactor Vasicek Model, which has got even more parameters to optimize and I am afraid the optimizer will stuck.
Thanks in advance,
Hi Hils, thank you for your answer.
I have another question, what does the "sigmai" stand for? Is that represent to the variances of measurement errors? But why does it can be negative? could you tell me what is the definition of this paremeter? Thank you very much!
The location of this parameter as follows:
% Initialize the parameters for CIR model
the initial parameters are decided with a little trial and error and some common sense. In the files I've set them as the answer because then the optimizer works better, but you are right it does not run smoothly. There is some common sense aswell, if you "surf()" the historic term structure you can see that it is always upward sloping so the risk aversion coeff. will be negative, etc.
Also the papers I've cited in the description gives some indication.
I also played around a bit with the other optimizers such as patternsearch and fmin.
When I have some time i will re-do them, as I don't think that the measurement errors (the other sigma's) should be in the optimizer. I think they should be 0.005*randn() and then resample (run the optimiser) 100 times or so to get 100 answers (slightly different) and then take the mean of that.
Hi Nils, Yan,
I am working on the CIR calibration using a Kalman filter. How do you make the optimization work? Sometimes, the fmincon function generates a warning of the form: "Matrix is close to singular or badly scaled. Results may be inaccurate". Have you found a way around that? Yan, how have you solved the optimization problem in general?
Hi Hils, could you tell me how did you decide the initial parameter value as input ? Thank you very much!
sent you email
Hi Nils, i was able to make the optimizer work by using some tricks. However, I would like to know how would you decide the initial parameter value as input ?