[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: regress vs polyfit

From: Mike Miller
Subject: RE: regress vs polyfit
Date: Tue, 21 Jun 2011 02:26:29 -0500 (CDT)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

On Mon, 20 Jun 2011, address@hidden wrote:

From Thomas Grzybowski:

I am new to octave and want to fit a single regression line to some data. I have been using polyfit, and was looking at regress, but I find regress confusing. From the regress "Help":

* `X' is a matrix of regressors, with the first column filled with the constant value 1

I do not understand the help instructions. My data is simply x,y pairs - what is this help about - "the constant value 1" ?

The program appears to fit an equation like y = a0*x0+a1*x1+a2*x2... where a0 is the constant term and the x0's are all 1, so that if you didn't want a constant term you would just omit that first column.

I'm sure that's right. This is the standard way of doing things. In this equation...

y = X*b + e

...y and e are vectors of length N, X is an N x p matrix and b is a vector of length p. If you have X and y and you want the least-squares solution for b, do this:

b = X\y ;

That's the easiest way.

To have an intercept term in the model, there has to be a column of ones in the X matrix. The b element that corresponds to that column of ones (normally the first column) is the intercept.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]