From: Alberto Frigerio on
Good evening everyone, I got a question about maxi/minimization in Octave.

First off all ... is there an Octave function which makes the calibration of the CIR process? Since I didn't find anything I decided to implement it on my own, but obviuosly if a function is yet available I will use it!!

I'm trying to implement a calibration for a particular stochastic process (the CIR one) , but I cannot manage a function maximizaton.

Here it is the function I want to minimize :

function out= MaxLikehood( data, dt, params )

N=length(data);
alpha = params (1); theta = params (2); sigma = params (3);
c = (2* alpha )/(( sigma ^2)*(1 - exp(- alpha *dt )));
q = ((2* alpha * theta )/( sigma ^2)) -1;
u = c* exp(- alpha *dt )* data (1:N -1);
v = c* data (2:N);
out = -(N -1)* log(c)+ sum(u+v- log(v./u)*q /2 -...
log( besseli (q ,2* sqrt (u.*v) ,1)) - abs( real (2* sqrt(u.*v ))));

endfunction

I wanna find the params which minimize this function, hence I type

params=[0.1 0.2 0.3];
fminsearch (@(params) MaxLikehood, params) or
fminsearch(@(params) MaxLikehood(data,dt,params) and other probably silly combinations.

Apart from my particular purpose, could you tell me how to minimize a function like the one I'm looking at?

Thank you so much, have a nice evening,
Alberto