Re: Fitting data on a vertical line
- To: mathgroup at christensen.cybernetics.net
- Subject: [mg1565] Re: Fitting data on a vertical line
- From: rubin at msu.edu (Paul A. Rubin)
- Date: Sat, 24 Jun 1995 06:39:26 -0400
- Organization: Michigan State University
In article <3sd9dm$n5n at news0.cybernetics.net>,
phpull at unix1.sncc.lsu.edu (Joe Wade Pulley) wrote:
->Hello,
-> I have recently accidentally asked Mathematica to do a linear
->least squares fit to a set of data which were exactly vertically
->placed. Instead of giving me an error or an infinite slope,
->Mathematica spits out some sort of fit which is totally wrong.
->For example, if I make up a list of data which is similar to mine, I
->get the following results.
->
->
->
->In[1]:=
->ls={{2.1,3},{2.1,4},{2.1,5},{2.1,6},{2.1,7}}
->
->Out[1]=
->{{2.1, 3}, {2.1, 4}, {2.1, 5}, {2.1, 6}, {2.1, 7}}
->
->In[2]:=
->ft=Fit[ls,{1,x},x]
->
->Out[2]=
->0.924214 + 1.94085 x
->
->Obviously, this equation does not "fit" the data I have given. The
->equation x=2.1 would. Can anyone explain this very unusual behavior.
The equation x=2.1 is not a linear model in x, which is what you requested.
You are asking for "the" linear function of x which minimizes total
squared error at the data points. Since all data points have the same
abscissa (2.1), any linear function whose value at x=2.1 is 5 ties for
least squared error. Note that the function coughed up by Fit qualifies
(it evaluates to 5 at x=2.1). It happens that there are uncountably many
possible OLS fits to this data. Why Fit chose that one is a mystery to me,
but it is in fact a correct answer.
Paul
**************************************************************************
* Paul A. Rubin Phone: (517) 432-3509 *
* Department of Management Fax: (517) 432-1111 *
* Eli Broad Graduate School of Management Net: RUBIN at MSU.EDU *
* Michigan State University *
* East Lansing, MI 48824-1122 (USA) *
**************************************************************************
Mathematicians are like Frenchmen: whenever you say something to them,
they translate it into their own language, and at once it is something
entirely different. J. W. v. GOETHE