Go Back   The Finance Forums > Finance forums > General Finance




General Finance Discuss general personal finance issues and home accounting not covered on the other finance boards.

Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old 07-27-2009, 10:18 PM
Junior Member
 
Join Date: Jul 2009
Location: sweden
Posts: 1
Default Help!!!Cox, IngersoU. and Ross model

I want to solve the bond pricing equation of Cox, IngersoU. and Ross model.I wrote some code in matlab,but result look strange.It is very small.I want some one can help me to check the code or give me some information.thanks a million!!!
Code:
dr = 0.005;
Nr = 8;
dt = 0.1;
Nt = 100;
a=0.2339*0.0189;
b=0.2339;
delta=sqrt(0.0073);
u(:,1) = ones(Nr+1,1); % Initial condition
for j=1:Nr+1
alpha=(1/2)*delta^2*dr*(j-1);
mu=(a-b*dr*(j-1));
rho=dt/(dr)^2;
x(j)=1+2*rho*alpha+dr*mu*rho+dt*dr*(j-1);
end
for p=1:Nr
alpha=(1/2)*delta^2*dr*(p-1);
mu=(a-b*dr*(p-1));
rho=dt/(dr)^2;
y(p)=-rho*alpha-dr*mu*rho;
end
for q=1:Nr
alpha=(1/2)*delta^2*dr*(q);
mu=(a-b*dr*(q));
rho=dt/(dr)^2;
z(q)=-rho*alpha;
end
A=diag(x)+diag(y,1)+diag(z,-1);

for i=1:Nt
u(:,i+1)=inv(A)*u(:,i);
end
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



» Boards




All times are GMT +1. The time now is 12:41 AM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.5.1 ©2010, Crawlability, Inc.