LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2003, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 10 May 2003 21:20:26 +1000
Reply-To:     doug <queanbeyan@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         doug <queanbeyan@HOTMAIL.COM>
Organization: Global Crossing Internet
Subject:      Re: how to calculate linear regression by hand?

Michael,

You can use excel to do the transposes for matrices to get the (XtX)-1XtY vector outcome that will contain the beta values. Otherwise, if you data are not too numerous you could do the inverses, transposes and multiplications by hand.

The (xtx)-1Xty method works every time and I owe much of my understanding (or lack thereof) to my stats lecturer who insisted that I learn the manual method!!

Basically if you have your X values (for simple linear regression it is dead-set simple) and you are including an intercept, make a matrix of nx2 form where n= number of obs (lets say you have 2 values of x and y). Make the first column all equal to 1 and populate the second column with the x values. Then create a vector (nx1 matrix) with the y values.

First step is to transpose of the x matrix (2x2), second multiply this by the original x matrix. third take the inverse of this and multiply this by transposed x matrix from step 1 finally, multiply this by the y vector and hey presto you have your OLS beta values.

I can send you an excel spreadsheet that will do the matrix multiplications, transpositions and inverses if you wish.

Hope this helps.

Doug

"Yu, Michael" <michael.yu@SPCORP.COM> wrote in message news:51E9450E2DA1D4118DB400508BF9AC34092B6B85@kenmsg32.schp.com... > off topic: What's the formula to compute linear regression by hand? > > eg, 10 pairs of x and y > ( x1, y1 ) > ( x2, y2 ) > ... > ( x10, y10 ) > > there's a formula to get a least square fit > y= a x + b > > where can I find such a formula so I can compute it myself to check against > the output from SAS? > > Thanks, > > Hsiwei > > > > ********************************************************************* > This message and any attachments are solely for the intended recipient. If you are not the intended recipient, disclosure, copying, use or distribution of the information included in this message is prohibited -- Please immediately and permanently delete.


Back to: Top of message | Previous page | Main SAS-L page