[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Maxi/minimization stupid question - CIR stochastic process
From: |
Michael Creel |
Subject: |
Re: Maxi/minimization stupid question - CIR stochastic process |
Date: |
Fri, 9 Jul 2010 04:08:12 -0700 (PDT) |
I don't know anything about this model, but here's some code to minimize the
function. I just made up some data.
#--------------------------------------------------------
1;
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
data = rand(100,1);
dt = 0.01;
params = [1;1;1];
MaxLikehood(data, dt,params)
control = {-1;1;1;3}; # maxiters, verbosity, conv. reg., arg_to_min
[theta, obj_value, convergence] = bfgsmin("MaxLikehood", {data, dt, params},
control);
#--------------------------------------------------------
If I run this, I get
octave:1> junk
ans = 1569.7
bfgsmin: Hessian reset
bfgsmin final results: 88 iterations
function value: 22.22
STRONG CONVERGENCE
Function conv 1 Param conv 1 Gradient conv 1
used numeric gradient
param gradient (n) change
1463.33090 -0.00000 0.00000
0.55726 0.00000 -0.00000
25.37338 -0.00000 0.00000
octave:2>
So, the final function value is less than the starting value, which is a
good sign. bfgsmin is in the optim package at Octave Forge. Hope this helps.
Cheers, Michael
--
View this message in context:
http://octave.1599824.n4.nabble.com/Maxi-minimization-stupid-question-CIR-stochastic-process-tp2282588p2283197.html
Sent from the Octave - General mailing list archive at Nabble.com.