reverse-shooting

Matlab scripts for reverse shooting
Log | Files | Refs | README

getells0.m (1219B)


      1 %%% Returns values of s_o and l_o such that d(l)_0 - g_s* and d(s)_0 - g_s* and d(sigma)_0 are minimized, given all other model parameters (note that you don't need a transition path for this).  
      2 %%% Gotcha: d(some variable) is that variable's derivative. In the paper, this is that variable with a hat ^.
      3 
      4 function xsoln=getells0(xguess,dlta0,Nend, alpha,epsilon,beta,lambda,phi,dltabar,ubar,gamma,rho,z,y,sigma,nbar,gs, T);
      5 
      6 %%%  Use minimization to ensure ellhat=gs, shat=gs, and sigmahat=0
      7 %%%  as closely as possible, by choosing x=[s0 ell0 N0].
      8   
      9 options=optimset('Display','on', 'MaxFunEvals', 100000, 'MaxIter', 1000);
     10 %%% options=optimset('Display','on');
     11 xsoln=fminsearch(@SSR,xguess,options);
     12 %%% xsoln=fminunc(@SSR,xguess,options);
     13 %%% fminsearch attempts to find the minimum of a function.
     14 
     15  function e=SSR(x0);
     16    s=x0(1);
     17    ell=x0(2);
     18 
     19    x=[s ell sigma dlta0 y z Nend];
     20    t=T;
     21 
     22    dx=transit1dx(t,x,alpha,epsilon,beta,lambda,phi,dltabar,ubar,gamma,rho,nbar, 0);
     23    dx=dx';   %%% [s ell sigma dlta y z]
     24    shat=dx(:,1)./s;
     25    ellhat=dx(:,2)./ell;
     26    sigmahat=dx(:,3)./sigma;
     27 
     28    
     29    m(1)=shat-gs;
     30    m(2)=ellhat-gs;
     31    m(3)=sigmahat;
     32 
     33    m=m';  
     34    e=100*m'*m;  %%% Sum of squared deviations
     35  end
     36 end