Regression Analysis

MME 523

October 21, 2003

 

The goal this week and next is to explore the numerical considerations behind regression analysis, linear and other.

 

 

Assignment 1:

 

1) please review the derivations from lecture as you will need them to extend this work.

 

2) we will use Maple for computational and graphical purposes for learning about Regression Analysis. We note that this is different from performing Regression Analysis where something like Excel or Minitab or SPSS would be more appropriate.

 

3) generate some somewhat linear data of your choice – say at least 6 data points 

 

            using Part One of the Maple code here as a model, plot your data

 

            now have another student make a guess as to a straight line that fits it and use maple to

            plot both your data and their straight line on the same plot (see Maple notes for help)

 

4)  next set up a 2x3 augmented matrix with the system of equations in it that yields the best fit straight line (see lecture notes for details).  We want Maple to solve the system with linear algebra techniques.  Code which is helpful might be modifications of:

 

                                    >with(linalg);                           to open the library

 

                                    >A:=matrix(2,3,[    ]);                create blank 2x3 matrix A

 

                                    >A[1,2]:= 728;                          store 728 in the row 1, column 2 entry

 

and also code for summing data values (here we use Maple to sum the squares of all the x values in a sample

array):

 

                                    > x_val:=[0 , 1, 2, 3, 5 ];               

                                    > tot:=0;

                                    > for i from 1 to 5 do tot:=tot + x_val[i]^2 od;

 

Now, putting together lecture notes and the code above, you should be able to fill up all 6 entries of the array with what amount to the coefficients of the two equations and two unknowns for the unknowns m and b needed for a linear fit.

 

5. Next we want to get Maple to solve the system. This is easy!! Just issue

 

                                   >gaussjord(A);

 

and you invoke the Gauss-Jordan algorithm for solving a system of equations.

 

6.  Next plot

·        your data

·        your guesstimate fit

·        the optimal fit

 

            on the same plot.

 

Assignment 2:

 

OK – you understand the concept and the linear derivations, right??  So prove it by doing the same sort of analysis with quadratic fit!

 

Steps:

            1.  seek a best fit of the form   y = ax2 + bx + c

 

            2.  pick some parabolic looking data – maybe 5-6 points

 

            3.  set up the error expression  (see lecture notes)

 

            4.  take 3 derivatives, set all to 0 for optimality

 

            5.  do some algebra and get 3 linear equations, 3 unknowns

 

            6.  set up a 3x4 matrix in Maple and have it reduce them

 

            7.  have Maple plot your data and your parabola on the same graph.

 

            8.  pat yourself on the back!

 

Assignment 3:

 

Get out your calculator and find out how to do linear regression on it! You want to then run the same data as you used in Assignment 1 (and get the same results!).  Jot down what it took to get it to work for you. If you don't have the manual, TI has them all on line.  If you do have the manual, READ IT!  Can your calculator do any more than

just linear?? Please report!

 

Assignment 4:

 

What can you find for data on the price of housing in Massachusetts over the last, say, 5-10 years???