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:
<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(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------