[Gretl-users] GMM giving strange error messages

Allin Cottrell cottrell at wfu.edu
Wed Nov 4 13:53:38 EST 2009


On Wed, 4 Nov 2009, Gal Wettstein wrote:

> I am having some problems with GMM. I try to run the following script:
> # initializations go here
> series e1 = 0
> series e2 = 0
> set bfgs_toler 1e-7
> set lbfgs 1
> matrix W = I(10)
> scalar beta = 0.95
> scalar lambda = 0.05
> scalar sigma = 1.05
> scalar gamma = 0.1
> scalar phi = 0.3
> scalar theta = 1
> list IVs = const R_DETREND(-1) CONSUMPTION_GRO(-1) GDP_GROWTH(-1)
> LN_RATIO_DETREN(-1)
> # list IVs = const R_DETREND(-1) R_DETREND(-2) R_DETREND(-3)
> CONSUMPTION_GRO(-1) CONSUMPTION_GRO(-2) CONSUMPTION_GRO(-3) GDP_GROWTH(-1)
> GDP_GROWTH(-2) GDP_GROWTH(-3) LN_RATIO_DETREN(-1) LN_RATIO_DETREN(-2)
> LN_RATIO_DETREN(-3)
> gmm
>  e1 = (R_DETREND * beta * (((CONS_DETREND(+1) - lambda * GDP_DETREND(+1)) ^
> ((-1) * (sigma))) * ((CONS_DETREND - lambda * GDP_DETREND) ^ (gamma)) *
> (LABOR_DETREND(+1) ^ phi) + (gamma * beta * ((CONS_DETREND(+2) - lambda *
> GDP_DETREND(+2)) ^ (1 - sigma)) * ((CONS_DETREND(+1) - lambda *
> GDP_DETREND(+1)) ^ (gamma - 1)) * (LABOR_DETREND(+2) ^ phi)) / (1-sigma)) -
> (((CONS_DETREND - lambda * GDP_DETREND) ^ ((-1) * (sigma))) *
> ((CONS_DETREND(-1) - lambda * GDP_DETREND(-1)) ^ (gamma)) * (LABOR_DETREND ^
> phi) + (gamma * beta * ((CONS_DETREND(+1) - lambda * GDP_DETREND(+1)) ^ (1 -
> sigma)) * ((CONS_DETREND - lambda * GDP_DETREND) ^ (gamma - 1)) *
> (LABOR_DETREND(+1) ^ phi)) / (1-sigma)))
>  e2 = (phi * ((CONS_DETREND - lambda * GDP_DETREND) ^ (1 - sigma)) *
> ((CONS_DETREND(-1) - lambda * GDP_DETREND(-1)) ^ gamma) * (LABOR_DETREND ^
> (phi-1))) / (1-sigma) + (((CONS_DETREND - lambda * GDP_DETREND) ^ ((-1) *
> sigma)) * ((CONS_DETREND(-1) - lambda * GDP_DETREND(-1)) ^ gamma) *
> (LABOR_DETREND ^ phi) + (beta * gamma * beta * ((CONS_DETREND(+1) - lambda *
> GDP_DETREND(+1)) ^ (1-sigma)) * ((CONS_DETREND - lambda * GDP_DETREND) ^
> (gamma - 1)) * (LABOR_DETREND(+1) ^ phi)) / (1 - sigma)) * (-theta) * ((1 -
> LABOR_DETREND) ^ (theta - 1)))

I'm sorry, but this is totally unreadable, and in fact has a
syntax error (unmatched trailing parenthesis in the definition of
e2).

If you'd like feedback on your model, please:

* break up these huge chunks: define some intermediate variables
  as components of e1 and e2 (e.g. e1 = e1a - e1b)

* lose all the confusing parentheses, for example

  x^((-1) * (sigma)) -> x^(-sigma)

  (and note that '^' has higher precedence than '*', which allows
  you to delete a few dozen parentheses).

* use terse variable names in this sort of expression so that the
  math is clear, e.g. R_DETREND -> r, CONSUMPTION_GRO -> dc and so
  on.

That said, one hint is to drop the "--iterate" flag to gmm and add
the "--verbose" flag.

Allin Cottrell


More information about the Gretl-users mailing list