Question: Is Excel better than Maple?!

This GARCH model in Maple is driving me crazy. I have successfully estimated the two parameters in excel

which was quite straight forward with the help with Hulls book page 380 (please see attached file for data)
 

Download 8342_GARCH Estimation (Hull).zip
View file details

 

In Maple everything is not so simple.  The first pain in Maple is keeping track of the end points for all loops (easy in excel)

The second pain is the Maximize command in Maple.  It does not seem to use the same algorithm as solver in excel

( ie "generalized reduced gradient " ). I can find the optimal parameters in Excel in under 3 seconds.

Maple gets unresponsive. Ok let start with an simulation of an GARCH model in Maple:

 


restart:
with(plots):
with(Statistics):
randomize():

n := 100:    alpha := .5:   beta := .3:    `ϖ` := 1-alpha-beta:

for i from 2 to n do

S[1] := 100:    var[1] := .2:     r[1] := 0:

var[i] := `ϖ`+alpha*r[i-1]^2+beta*var[i-1]:

r[i] := Sample(RandomVariable(Normal(0, sqrt(var[i]))), 1)[1]:

S[i] := S[i-1]+r[i]

end do:

SS := Array([seq(S[i], i = 1 .. n)]);

RR := Array([seq(r[i], i = 1 .. n)]);

 

The objective is finding alpha and beta. Note varphi is simply given by Variance(RR)*(1-alpha-beta) if we use

what hull calls variance targeting . This seems simple enough.  Maple should be able to find 2 parameters right ?!

All right lets take the example in Hull again (data is in the xls file that I attached above).

 



restart:
with(Statistics):
with(ArrayTools):
with(ExcelTools):
with(Optimization):

A := Import("C:\\Users\\Marcus\\Desktop\\GARCH Estimation (Hull).xls", "Variance Targeting", "B9:B2431"):
Nr, Nc := Size(A):

# % return
for i from 2 to Nr do

u[i] := (A[i, 1]-A[i-1, 1])/A[i-1, 1] :

end do:

RR := Vector([seq(u[i], i = 2 .. Nr)]):


 



X := proc (a, b) local w, i, V, VV, Nr, Nc, E, Max:

Nr, Nc := Size(RR):

w := Variance(RR)*(1-a-b):

# variance
for i from 2 to Nr-1 do

V[1] := RR[1]^2:

V[i] := w+a*RR[i]^2+b*V[i-1] :

end do:

VV := Vector([seq(V[i], i = 1 .. Nr-1)]):

Nr, Nc := Size(VV):

# maximum likelihood
for i to Nr do

E[i] := -ln(VV[i])-RR[i+1]^2/VV[i]

end do:

add(E[i], i = 1 .. Nr)


end proc:

 



X(0.0607, 0.8990);
 

                                                                  22063.52740

 

The maximum likelihood value given the optimal parameter values is the same as described in

Hulls book (page 380)  22063.52740  which to me indicate that everything is working correctly (even though

some of the loops look a bit strange decause the vector becomes shorter over time ie returns -1 etc ).

Now we should simply be able to optimize X(a,b) and find the optimal values of a and b.

 


con := [a <= 1, a >= 0, b <= 1, b >= 0];

Maximize( X(a,b), con, initialpoint = [a = .6, b = .2], assume = nonnegative);
 

 

However this is not working for some strange reason. As I said previously Excel finds the solution in 3 seconds

Maple does not find the solution at all (dont run the optimization because Maple will not respond)

I find this strange. I have also attached some pages from Hull's book

 

Download 8342_Hull - GARCH Pages.pdf
View file details

Please Wait...