MathGroup Archive 2005

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

Search the Archive

NMinimize hanging after many iterations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62248] NMinimize hanging after many iterations
  • From: Ming Hsu <hsu at charter.net>
  • Date: Thu, 17 Nov 2005 04:15:46 -0500 (EST)
  • Organization: California Institute of Technology, Pasadena
  • Sender: owner-wri-mathgroup at wolfram.com

Hi, I am running Mathematica 5.1 on a G4 Powerbook running OS X Tiger.  I am
getting a very strange problem with mathematica hanging running a
constrained nonlinear optimization simulation with 3 unknown parameters.

Strangely, I have NEVER actually experienced hanging when I am not looping.
The error typically happens around iteration 10-30, so I should've
encountered one by chance by now.

Also, the hanging does not seem to occur when I am estimating only 1 or 2 of
the parameters.

Here is a snippet of the self-containing code.  Sorry for the length.

U[x_, $B&Q(B_] := (x + 1.*^-8)^$B&Q(B

Logit[p_, x1_, x2_, c1_, $B&Q(B_, $B&K(B_] := (
    u1 = U[x1, $B&Q(B]; 
    u2 = U[x2, $B&Q(B]; 
    u3 = U[c1, $B&Q(B]; 

    u0 = p*u1 + (1 - p)*u2; 1/(1 + Exp[(-$B&K(B)*(u0 - u3)])
)

LogLik[choice__, pList__, xList__, $B&Q(B_, $B&K(B_] :=
 
  (choiceP = Table[Logit[pList[[i]], xList[[i,1]], xList[[i,2]],
    xList[[i,3]], $B&Q(B, $B&K(B], 

    {i, 1, Length[pList]}];
    likList = Table[choice[[i]]*Log[choiceP[[i]] + 1.*^-6] +
 
      (1 - choice[[i]])*Log[1.000001 - choiceP[[i]]],
    {i, 1, Length[pList]}]; Plus @@ likList)

Generate[pList__, xList__, $B&Q(B_, $B&K(B_] := 
  (choiceP = Table[Logit[pList[[i]],
    xList[[i,1]], xList[[i,2]], xList[[i,3]], $B&Q(B, $B&K(B],
 
  {i, 1, Length[pList]}]; rand = Table[Random[], {Length[pList]}]; 

    Table[choiceP[[i]] > rand[[i]], {i, 1, Length[pList]}] /. True :> 1 /.
    False :> 0)

Table[
choices = Generate[G[[All,1]], G[[All, {2, 3, 4}]], $B&Q(B1True, $B&Q(B2True, 

$B&L(BTrue, $B&K(BTrue]; 

est = NMaximize[{LogLik[choices, G[[All, 1]], G[[All, {2, 3,
4}]], $B&Q(B1True,
$B&Q(B2, $B&L(B, $B&K(B], 0 < $B&Q(B2 < 2, 0 < $B&L(B < 2, $B&K(B > 0}, {$B&Q(B2, $B&L(B, $B&K(B},
Method -> {"NelderMead", "RandomSeed" -> Random[Integer, {0, 100}]}], {iter,
100}
] 

---------------------------------

Thank you,
Ming Hsu


  • Prev by Date: Re: Re: Magnetic Pendulum
  • Next by Date: Re: GUI-Kit Xserver Problem
  • Previous by thread: Autosave package problem - Mathematic 5.1 on OS X
  • Next by thread: General--Interpolation and NonlinearFit