Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: re: generating determinant of Hessian matrix over observations


From   Kit Baum <baum@bc.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: re: generating determinant of Hessian matrix over observations
Date   Mon, 1 Oct 2007 09:49:32 -0400

The hard way:

modify Asgar's code presented to replace one observation at a time in det_H.

The easy way: the det of a 2x2 matrix does not require matrix calculations; just calculate the det as A*C - B*B.

* corrected code

gen det_H = .
qui forvalues i = 1/43 {
matrix H = (A[`i'], B[`i'] \ B[`i'], C[`i'])
replace det_H = det(H) in `i'
}

* a much simpler solution

gen easydetH = A*C - B^2

l det_H easydetH


Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index