why do I receive an error in my codes?

조회 수: 1 (최근 30일)
parisa lotfi
parisa lotfi 2017년 2월 11일
댓글: parisa lotfi 2017년 2월 14일
I am trying to find the maximum of the function.I want to find teta for each x which is maximize the my function. the function is
F(x)=(F(x-1)+cr*Y(x-1))*exp(r+teta(x-1)*((mu-1/2*sigma.^2)+sigma*Z(1,x)))
I write the codes but it has errors. could you possibly help me?
lambda=4.5; % loss aversion ratio
nu1=0.44; % curvature parameter for gains
nu2=0.88; % curvature parameter for loss
rl=0.02;
sigma1=0.05;
sigma2=0.02;
h1=-0.1865;
h2=0.7537;
r=0.02; % real risk-free return
mu=0.04; % equity risk premium
sigma=0.18; % volatility of equity return
beta=0.96; % discount factor
cr=0.15; % contribution rate
w=0.5; % weight of interim target
a=15.8382; % price of annuity on retirement
x=21:65;
Z(1,x)=randn(1,45);
Z(2,x)=randn(1,45);
hist(x,-1:.05:1) % Notice the symmetry around point Mu
Z(1,x) = Z(1,x) + abs(min(Z(1,x))); % Move everything to the right
Z(2,x) = Z(2,x) + abs(min(Z(2,x))); % Move everything to the right
%%Return on risky assets
R(x)=r+mu-1/2*sigma^2+sigma*Z(1,x);
S(x)=1+h1*(-1+(x-20)/45)+h2*(-1+4*(x-20)/45-((3^1/2)*(x-20)/45).^2);
I(x)=rl+(S(x)-S(x-1))/S(x-1)+sigma1*Z(1,x)+sigma2*Z(2,x);
Y(20)=1;
for x=21:65
Y(x)=Y(x-1)*exp(I(x));
end
function F = myfun(teta)
F(x)=(F(x-1)+cr*Y(x-1))*exp(r+teta(x-1)*((mu-1/2*sigma.^2)+sigma*Z(1,x)));
teta=fminbnd(@myfun,0,1);
end
  댓글 수: 10
Walter Roberson
Walter Roberson 2017년 2월 14일
You do not appear to use function dp?
parisa lotfi
parisa lotfi 2017년 2월 14일
yes, but I don't know what should I do

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Risk Management Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by