Am 24.11.2013 14:42, schrieb Riccardo (Jack) Lucchetti:
On Sat, 23 Nov 2013, Pindar wrote:

Hi,

for the standard Poisson model I'd like to explore different methods of covariance estimation.
Could  you please tell me how to replicate the --hessian flag with the 'Hess' function?
(it's not included in MLE-advanced.inp, I read in the manuel 'negative inverse of the hessian', but I make something wrong since invpd(h) does not do the job).

The problem is that your "Hess" function has a bug. Have a look here:


I'm still puzzled since my crude "Hess" function produced the same results without the --hessian flag as the right one. For didactic reasons I wanted to use qform in order to have the X'WX syntax and thought this is qual to "qform(mX', {m}*{m}')" ). However, now with the plain (correct) matrix  notation invpd() works and if one includes "eval diag(sqrt(invpd(mX'(mX .* {m}))))" in the "Hess" function the SE corresponding to the --hessian flag are printed. But I'm a right, that it is not possible to reproduce --hessian SE without giving this flag just by tweaking the "Hess" function since the  --hessian SE are somehow not passed when using "H = inv(mX'(mX .* {m}))" ?


<hansl>
open poisson.gdt

poisson y 0 x1 x2
series fake_y = ln(y+1)
ols fake_y 0 x1 x2 --quiet
list xList = $xlist
matrix b = $coeff
matrix mX = {xList}

function matrix score(series y, series m, matrix mX)
    return {y - m} .* mX
end function

function void Hess(matrix *H, series m, matrix mX)
    #computes the negative Hessian for Poisson model
    H = mX'(mX .* {m})
end function

matrix H = {}
mle loglik = y*xb - m - lngamma(y+1)
    series xb = mX*b
    series m = exp(xb)
    deriv b = score(y, m, mX)
    hessian Hess(&H, m, mX)
end mle --hessian
</hansl>



-------------------------------------------------------
  Riccardo (Jack) Lucchetti
  Dipartimento di Scienze Economiche e Sociali (DiSES)

  Università Politecnica delle Marche
  (formerly known as Università di Ancona)

  r.lucchetti@univpm.it
  http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------


_______________________________________________
Gretl-users mailing list
Gretl-users@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users