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

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

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
*   For searches and help try:

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