[R] Re gression with Intersection Constraint

S M Niaz Arifin niazarifin at yahoo.com
Wed Aug 20 09:16:56 CEST 2008


Hi,
Previously I posted a thread asking help on how to best-fit (in the least
squares sense) a straight line through a set of data points. Thanks a lot to
all replying to it. I managed it in Matlab using a function 'fit_3D_data'
(link: 
http://webscripts.softpedia.com/script/Scientific-Engineering-Ruby/Statistics-and-Probability/Orthogonal-Linear-Regression-in-3D-space-35532.html).

But to add a 'simple' constraint to the problem, I am stuck. Here it is:

I have two sets of data points, representing two separate straight lines
(call A and R) that intersect at a point. I need to find the least-square
fit to these lines, subject to their intersection constraint. So, the
important part is that the two best-fit lines must intersect at the 'best'
intersection point as determined by the data points.
Is there any way to do this in R (I am also trying in Matlab, but yet to get
any solution)?

Here is what it looks like in Matlab:

load pointsA.txt
xdataA = pointsA(:,1);
ydataA = pointsA(:,2);
zdataA = pointsA(:,3);
 
load pointsR.txt
xdataR = pointsR(:,1);
ydataR = pointsR(:,2);
zdataR = pointsR(:,3);
 
fit_3D_data(xdataA,ydataA,zdataA,'line','on','on');
fit_3D_data(xdataR,ydataR,zdataR,'line','on','on');

Thanks a lot for your time.

-- 
View this message in context: http://www.nabble.com/Regression-with-Intersection-Constraint-tp19064048p19064048.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list