[SciPy-user] Using fmin

josef.pktd at gmail.com josef.pktd at gmail.com
Wed Mar 25 18:42:00 EDT 2009


On Wed, Mar 25, 2009 at 5:48 PM, Moofle <mustafarahman23 at gmail.com> wrote:
> Dear All,
>
> I am a beginner to python and scipy for that matter. I am trying to program
> GARCH(1,1) and I am attempting to use fmin or fmin_powell to optimize the
> equation : =
>
> SUM(from i to N) [-ln(vi)-((ui**2)/(vi))]  (where i is the index)
>
> I am trying to get some hints as to how to answer this question:
>
> 1. vi is dependent on ui and the v before it (vi-1). It is defined by this
> equation: vi = omega + alpha*ui-1 + beta*vi-1 (where omega, alpha, beta are the
> parameters I need to optimize, i is the index)
>
> I am not sure how to pass alpha, omega, beta into the fmin method. To be honest,
> I am not even completely sure about how that method even works even though I
> have looked at the documentation for hours. In particular, I dont know what the
> args=() is used for!! I can solve this in excel using solver and AMPL, but I
> sure would appreciate a few hints!!
>
> Many Thanks.
>

A good place to start is looking at the different versions of curve fitting in
http://www.scipy.org/Cookbook/FittingData

the basic idea is similar for all numerical optimization routines
fmin(func, x0, args=(), ...)

where you need to provide func as the objective function, that takes
an array as optimization parameters, and additional arguments for
example the time series of your observations.
x0 are the starting values
args is a list/tuple of additional arguments

example :
--------------
mlogitloglike is the negative loglikelihood of the multivariate logit
model, the objective function
param are the parameters I want to estimate
y is independent variable
x,z, are explanatory variables

def mlogitloglike(param, y, x, z):
    '''wrapper to get negative loglikelihood to feed to optimization procedure
      param are parameters of the logit model'''
      unpack parameters and calculate likelihood function
      ...

define starting parameters param0

then:
result = optimize.fmin(mlogitloglike, param0, args=(y,x,z))


Josef



More information about the SciPy-User mailing list