Best Regression Fit +- HP Forums (http://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: Best Regression Fit (/thread-9440.html) |
RE: Best Regression Fit - Namir - 12-28-2017 06:54 AM Here is a third version, BESTFIT3, that maps the X and Y data to values in the range of (1, 2), making all transformations possible: The function returns: 1) Best Rsqr value. 2) Power of best Y transformation (0 means ln(y)). 3) Power of best X transformation (0 means ln(x)). 4) Best slope. 5) Best intercept. 6) Minimum X value. 7) Maximum X value. 8) Minimum Y value. 9) Maximum Y value. Make sure you use the powers, slope, intercept, minima, and maxima in estimating Yhat values: Yhat' = (slope * ((X-xmin)/(xmax-xmin)+1)^xpwr + intercept)^(1/ypwr) Yhat = ymin + (Yhat'-1)*(ymax-ymin) if xpwr=0 and ywpr!=0 use: Yhat' = (slope * ln((X-xmin)/(xmax-xmin)+1) + intercept)^(1/ypwr) Yhat = ymin + (Yhat'-1)*(ymax-ymin) if xpwr!=0 and ywpr=0 use: Yhat' = exp(slope * ((X-xmin)/(xmax-xmin)+1)^xpwr + intercept) Yhat = ymin + (Yhat'-1)*(ymax-ymin) if both xpwr and ypwr are zero, use: Yhat' = exp(slope * ln((X-xmin)/(xmax-xmin)+1) + intercept) Yhat = ymin + (Yhat'-1)*(ymax-ymin) Use ln() functions when xpwr s 0 and use exp() when the ypwr is 0. Code: EXPORT BESTFIT3(Mat, IdxX, IdxY) |