[Top][All Lists]

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

RE: regress vs polyfit

From: Allen.Windhorn
Subject: RE: regress vs polyfit
Date: Mon, 20 Jun 2011 09:31:03 -0500


-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of 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" ?

I haven't used regress before -- thanks for bringing it to my
attention.  It looks as if it is a more general least-squares
algorithm.  For linear fitting you would just make your X matrix
something like:

X =

   1.000000   0.103900
   1.000000   0.092700
   1.000000   0.082700
   1.000000   0.073900
   1.000000   0.065900
   1.000000   0.058700
   1.000000   0.052400
   1.000000   0.046900
   1.000000   0.041800
   1.000000   0.037300

where the second column is the "real" x values.  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.  Of course if you were fitting more than one variable
you would add columns of x's to the X matrix, and if you were
doing a polynomial fit the first column would be 1, the next
x, then x^2, then x^3 etc.


reply via email to

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