After reading the answer of my last question, I change my code about fsolve, but there is still notification of: No solution found.
fsolve stopped because the problem appears to be locally singular.
<stopping criteria details>
Would anyone could check my code and give me some advises plz? Thanks a lot.:
%%function for omega of every time period for OI scheme
function f=function_1_5_3(x,Z)r0=.02;%interest rate
sigma=.15;%vatality rate of risky asset
mu0=.06;%drift rate of risky asset
gamma=5;%risk aversion rate
M=10000;%number of trajectories
N=55;%time period
T=55;%total time period
R=40;%time of retirement
dt=T/N;%each time period
t=1:dt:T;omega=x;Rf=exp(r0);%riskless reture
load OI_a_matrix;%set a grid of at
Rs=exp(mu0+sigma*Z);%risky market return
a=20*mat(:,N-2);a_1=20*mat(:,N-1);W=((a.*(Rf+omega*(Rs-Rf))-a_1).^(-gamma)).*(Rs-Rf)/M;f=W;
and
clearM=10000;x0=0.4;Z=randn(M,1);x=fsolve(@(x)function_1_5_3(x,Z),x0)
in which the loaded matrix is a random matrix which saved at first:
mat=rand(M,N)
Best Answer