Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: reg and matrix munipulation for OLS in Stata


From   [email protected]
To   [email protected]
Subject   st: reg and matrix munipulation for OLS in Stata
Date   Mon, 05 Apr 2004 19:59:58 -0400

Hi all, 

I encountered a weird problem. As you know, the formal form of obtaining the coefficient estimates in OLS is: B = (X'X)^(-1)X'Y. In a dataset that contains X1, X2, X3, X4, X5 and Y, I did the following:

reg Y X1 X2 X3 X4 X5

mkmat X1 X2 X3 X4 X5, matrix(X_ALL)
matrix B = inv(X_ALL'*X_ALL)*X_ALL'Y

Theoretically, I am supposed to get the same results for the coefficient estimates contained in B matrix as well as in the results from reg command. However, my regression results are slightly different in these two approaches. Can anyone tell why I have different results? 

Thank you very much!





__________________________________________________________________
Introducing the New Netscape Internet Service. 
Only $9.95 a month -- Sign up today at http://isp.netscape.com/register

Netscape. Just the Net You Need. 

New! Netscape Toolbar for Internet Explorer
Search from anywhere on the Web and block those annoying pop-ups.
Download now at http://channels.netscape.com/ns/search/install.jsp
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index