MATH 376 -- Probability and Statistics 2

April 3, 2006

First Least Squares Regression Example

The housing price data:

>    read "/home/fac/little/public_html/ProbStat0506/MSP.map";

Warning, the name changecoords has been redefined

49399506

For computation of the estimators for the coefficients in the model

    Y = beta[0]+beta[1]*x+epsilon

We enter the lists of x   and   y   coordinates of the data points separately:

>    XList:=[0.,1,2,3,4,5,6,7];

XList := [0., 1, 2, 3, 4, 5, 6, 7]

>    YList:=[27.6,32.5,35.9,39.3,44.8,48.8,55.7,62.9];

YList := [27.6, 32.5, 35.9, 39.3, 44.8, 48.8, 55.7, 62.9]

Means:

>    Xbar:=Mean(XList);

Xbar := 3.500000000

>    Ybar:=Mean(YList);

Ybar := 43.43750000

Organizing the computation as we described in class:

>    SXY:=add((XList[i]-Xbar)*(YList[i]-Ybar),i=1..8);

SXY := 203.6500000

>    SXX:=add((XList[i]-Xbar)*(XList[i]-Xbar),i=1..8);

SXX := 42.00000000

>    hatbeta[1]:=SXY/SXX;

hatbeta[1] := 4.848809524

>    hatbeta[0]:=Ybar-hatbeta[1]*Xbar;

hatbeta[0] := 26.46666667

Plot the data points together with the line determined by the least-squares estimators

for beta[0]   and beta[1]

>    with(plots):

>    Pts:=[seq([XList[i],YList[i]],i=1..8)];

Pts := [[0., 27.6], [1, 32.5], [2, 35.9], [3, 39.3], [4, 44.8], [5, 48.8], [6, 55.7], [7, 62.9]]

>    PP:=plot(Pts,style=point,color=blue,symbol=circle):

>    LP:=plot(hatbeta[0]+hatbeta[1]*x,x=0..8):

>    display(PP,LP);

[Maple Plot]

>   

This indicates a pretty good "fit" with the linear model.  (Other functional forms could

also be considered, though, since it seems that the y 's are consistently low in the

middle of the range of  x's. )