Re: Line fitting
- From: "John D'Errico" <woodchips@xxxxxxxxxxxxxxxx>
- Date: Wed, 20 Jun 2007 10:20:23 -0400
Alan wrote:
Hi,
Let say I have two matrices A and B. The value A is between 0 and
100.
Now, I need to find the relationship between A and B. I set three
breakpoints a1, a2, and a3 such that:
When A is 0<A<a1, B = m1A + c1
When A is a1<A<a2, B = m2A + c2
When A is a2<A<a3, B = m3A + c3
When A is a3<A<100, B = m4A + c4
The four equations are obtained using curve fitting technique (e.g.
polyfit function). In Matlab, is there any way to set these
breakpoints so that the R^2 of these equations are maximized?
Thanks,
Alan
This is known as a linear least squares
spline. Polyfit is not a solution, since
the pieces must be continuous.
Estimation of the break points of the
spline is a "free knot" problem, where
those parameters are also estimated from
the data. This can be solved using a
nonlinear least squares, nonlinear on
the breaks and linear on the spline
parameters.
It can also be solved using a stepwise
regression approach, as implemented in
MARS. I've not yet seen a MARS version
fully written in Matlab though.
Regardless, the solution is not one that
maximizes the total R^2. This is not how
linear regression modeling works. It
minimizes the sums of squares of the
residuals. By a stroke of coincidence ;-),
one measure of a good regression fit is
an R^2 near 1.
John
.
- Follow-Ups:
- Re: Line fitting
- From: Greg Heath
- Re: Line fitting
- References:
- Line fitting
- From: Alan
- Line fitting
- Prev by Date: fit a circle to a rather round shape JPG image using MATLAB image processing
- Next by Date: Re: Handles and Variable Names
- Previous by thread: Line fitting
- Next by thread: Re: Line fitting
- Index(es):
Relevant Pages
|