Thomas Jacobs <[email protected]>:
You may also want to reparametrize--I had trouble finding fake
starting values that would not crash your program. For example, if
Avol and AoX are always positive, try logs:
clear all
mata
void Merton(todo, A, c, lnf, g, H)
{
f1=A[1]*normal((A[1]+c[2]*0.5*exp(A[2])^2)/(exp(A[2])*c[1]))
f2=-normal((A[1]-c[2]*0.5*exp(A[2])^2)/(exp(A[2])*c[1]))- c[3]
f3=normal((A[1]+c[2]*0.5*exp(A[2])^2)/(exp(A[2])*c[1]))*exp(A[1]+A[2])
f4=c[3] * c[4]
lnf=(f1-f2)^2 + (f3-f4)^2
}
T = 5
sqrtT = sqrt(T)
X = 0.65
E = 0.25
Evol = 0.15
Avol = ln(Evol/2)
AoX = ln(E + X)-ln(X)
EoX = E/X
c = (sqrtT, T, EoX, Evol)
S = optimize_init()
optimize_init_evaluator(S, &Merton())
optimize_init_evaluatortype(S,"d0")
optimize_init_params(S,(AoX,Avol))
optimize_init_which(S, "min")
optimize_init_argument(S,1,c)
B=optimize(S)
exp(B[1]),exp(B[2])
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/