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

Re: st: Re: reg and matrix munipulation for OLS in Stata


From   Richard Williams <Richard.A.Williams.5@nd.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: reg and matrix munipulation for OLS in Stata
Date   Mon, 05 Apr 2004 22:08:03 -0500

At 07:41 PM 4/5/2004 -0500, Scott Merryman wrote:
Don't you need to add a column of 1s to the X matrix for the intercept?
Yet another way to do it (which might be handy if the data set is large):

. sysuse auto
(1978 Automobile Data)

. mat accum xprimex = mpg weight
(obs=74)

. mat vecaccum yprimex = price mpg weight

. mat xprimey = yprimex'

. mat b = inv(xprimex)*xprimey

. mat list b

b[3,1]
             price
   mpg  -49.512221
weight   1.7465592
 _cons   1946.0687


-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX:    (574)288-4373
HOME:   (574)289-5227
EMAIL:  Richard.A.Williams.5@ND.Edu
WWW (personal):    http://www.nd.edu/~rwilliam
WWW (department):    http://www.nd.edu/~soc

*
*   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