1 /*Extended Yet Another Curve Fitting Solution (The poor man's RMA)
3 An extension of yacfs.mod adding a Weight parameter:
4 When set to 1 the model produces best fit by least squares with all error in y and none in x (YonX);
5 When set to zero the model produces best fit by least squares with all error in x and none in y (XonY);
6 When set to 0.5 the model assumes equal error in x and y producing results similar to fitting by Reduced Major Axis Analysis.
8 Nigel_Galloway@operamail.com
12 param Sx {z in Sample};
13 param Sy {z in Sample};
21 XonY1 :sum{z in Sample} q*Sy[z]*Sy[z] + sum{z in Sample} p*Sy[z] = sum{z in Sample} Sy[z]*Sx[z];
22 XonY2 :sum{z in Sample} q*Sy[z] + sum{z in Sample} p = sum{z in Sample} Sx[z];
23 YonX1 :sum{z in Sample} a*Sx[z]*Sx[z] + sum{z in Sample} b*Sx[z] = sum{z in Sample} Sy[z]*Sx[z];
24 YonX2 :sum{z in Sample} a*Sx[z] + sum{z in Sample} b = sum{z in Sample} Sy[z];
28 param W := Weight*a + (1-Weight)*(1/q);
29 printf "\nbest linear fit is:\n\ty = %f %s %fx\n\n", b*Weight - (1-Weight)*(p/q), if W < 0 then "-" else "+", abs(W);