Path: news.mathworks.com!not-for-mail
From: "Russ Scott" <robinandruss@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: linear regression - inconsistent results
Date: Thu, 6 Nov 2008 21:28:01 +0000 (UTC)
Organization: US Department of Agriculture
Lines: 38
Message-ID: <gevnh1$bnn$1@fred.mathworks.com>
Reply-To: "Russ Scott" <robinandruss@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1226006881 12023 172.30.248.35 (6 Nov 2008 21:28:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 6 Nov 2008 21:28:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 213282
Xref: news.mathworks.com comp.soft-sys.matlab:499383


I've been noticing when using regress or polyfit that I'm getting inconsistent result when I switch the 1 independent variable with the dependent variable. Mathematically this does not make sense to me.

If y = mx + b

then 

x = y/m - b/m

But I've found for certain datasets that when I flip the y and x around using either regress (and adding a column of ones to X) or polyfit(x,y,1) I get non-consistent results.

This is a short example to illustrate my problem.

>> d=[    0.0074143     0.052035
    0.0076173    0.0014361
    0.0077408   -0.0041507
     0.013317     0.054487
     0.013289     0.061777
     0.013346     0.055137
      0.01397    -0.046578
     0.014114    -0.026229
     0.014658     0.042499
     0.020282   -0.0010642];
>> polyfit(d(:,2),d(:,1),1)

ans =

    -0.011263     0.012788

>> polyfit(d(:,1),d(:,2),1)

ans =

      -1.0641     0.032315

THESE ARE INCONSISTENT RESULTS AREN'T THEY?
e.g., 
1/-0.011263 ~=  -1.0641