[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: re: generating determinant of Hessian matrix over observations
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/