why do I receive an error in my codes?

1 visualización (últimos 30 días)
parisa lotfi
parisa lotfi el 11 de Feb. de 2017
Comentada: parisa lotfi el 14 de Feb. de 2017
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 comentarios
Walter Roberson
Walter Roberson el 14 de Feb. de 2017
You do not appear to use function dp?
parisa lotfi
parisa lotfi el 14 de Feb. de 2017
yes, but I don't know what should I do

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Risk Management Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by