MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Findminimum computation time (ignore my previous posting)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24024] Findminimum computation time (ignore my previous posting)
  • From: Benoit_Carmichael <benoit at ecn.ulaval.ca>
  • Date: Tue, 20 Jun 2000 03:07:37 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

I would like to use FINDMINIMUM to estimate Ferson (Journal of finance 
1992) beta pricing model with Hansen (Econometrica 1982) generalized 
method of moments (GMM). I have already a FORTRAN program that does the 
estimation in matter of minutes (if not seconds!). So far, my 
implementation of GMM with MATHEMATICA 4.0 is too slow to make it useful 
in practice. Before giving it all up, I want to make sure that my 
programming style is not at fault.

The objective function to minimize as the form of a sum of squares (i.e. 
e.v.e). The main part of my code is listed below. Here are my questions:

1) From your experience, is FINDMINIMUM useful to minimize a function of 
a large number of variables (say 40 or 50 parameters) in a reasonable 
lapse of time?


My fobj[b] function takes about 0,2 second to compute on a PII 400 with 
128 mg of ram. FINDMINIMUM has yet to return something after hours of 
computations! Something must be wrong. The code works. I have estimated 
successfully a small model with 3 asset returns, 25 observations and 2 
parameters.

2) Would supplying the gradient myself speed things up? (Findminimum 
seems to build the function analytically before replacing the parameters 
with the starting values. This seems to be the part that takes too much 
time.)

3) My objective function is built in 4 steps (ortho, ez, m and fobj). 
Would there be efficiency gains to merge these steps?

I am more familiar with procedural style of programming (FORTRAN), my 
mathematica code could probably be improved. I tried, to the best of my 
knowledge, to program my objective function "functionaly".

4) Have I succeeded or could you see obvious improvement?

I would greatly appreciate any suggestions.

Many thanks in advance.



Benoit Carmichael
Professeur
Departement d'Economique
Pavillon J.-A. de S=E8ve
Cit=E9 Universitaire
Ste-Foy (Quebec)
Canada, G1K 7P4
Tel.: (418) 656-2131 #5442

Here is the main part of my code:

BUILDING THE OBJECTIVE FUNCTION:

ortho[{y_, r_, x_, z_}] := Module[{f, eR, eT}, (* nf is the number of 
factors, nr is the number of assets considered, x and z are data *)

f = y - \[Gamma].x;

eR = r[[Range[nf]]] - \[Delta].x - \[Beta]R.f;

eT = r[[Range[nf + 1, nr]]] - \[Beta]T.\[Beta]Ri.\[Delta].x - 
\[Beta]T.f;


Flatten[{Outer[Times, f, z],

Outer[Times, Flatten[{eR, eT}], Flatten[{f, z}]]}]

]

ez[b_] := ( (* nf, nxf, nxr and np are constant terms determining the 
number of factors, of explanatory variables and of parameter to estimate 
*)


\[Gamma] = Partition[b[[Range[nf nxf]]], nxf];

\[Delta] = Partition[b[[Range[nf nxf + 1, nf (nxf + nxr)]]], nxr];

\[Beta] = Partition[b[[Range[nf (nxf + nxr) + 1, np]]], nf];

\[Beta]R = \[Beta][[Range[nf]]];

\[Beta]Ri = Inverse[\[Beta]R];

\[Beta]T = \[Beta][[Range[nf + 1, nr]]];


Map[ortho, lst]

)

m[b_] := (Apply[Plus, Transpose[ez[b]], 1]);

fobj[b_] := Module[{mm}, mm = m[b]; f = mm.v.mm; Print[f]; f]

DATA:

lst = Transpose[{F, re, x, z}];

PARAMETER VECTOR:

bb = Table[ToExpression["b" <> ToString[i]], {i, np}] ;

b0 = STARTING VALUES

bb0 = Flatten[{Transpose[{Flatten[bb], Flatten[b0]}]}, 1]

ESTIMATION:

v=Identity matrix  (*for the time being *)

FindMinimum[fobj[bb], Evaluate[Sequence @@ bb0], MaxIterations -> 100]

In typical application, I have :

10 asset returns (nr=10),

2 factors (nf=2)

10 explanatory variables (nxf=nxr=10),

200+ observations for each variables

40 to 50 parameters to estimate


  • Prev by Date: Re: Newbie question: pairswise function application
  • Next by Date: Re: And, Or, Intersection, Union - no Orderless attribute
  • Previous by thread: Re: Gradient in FindMininum
  • Next by thread: Win 98 compatibility With Ver. 2.2.2