Simple Linear Regression - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP-41C Software Library (/forum-11.html) +--- Thread: Simple Linear Regression (/thread-3951.html) |
Simple Linear Regression - Dave Britten - 05-23-2015 04:45 PM Nothing fancy, just simple linear regression to fill a niche. Calculates m and b for the equation y=mx+b, as well as the correlation r. This program assumes the default ΣREG 11, and stores its results in R17-R19. Modify accordingly if you prefer a non-default stat regs location. No modules required. Usage: Enter stat data normally, then run LR to compute m, b, and r, which are stored in R17, R18, and R19 respectively, and also placed on the stack in Z, Y, and X. Run LR again to recompute m, b, and r if stat data is modified. After running LR, run XHAT and YHAT to predict x or y respectively from the value present in the stack X register. The result will be left in X. If you run XHAT and YHAT frequently, you may wish to insert local alpha labels at the beginning of those subroutines. Good choices would be b and c, since the shifted functions on those keys feature a prominent "y" and "x" character, and they don't interfere with the stat keys. Code: 01 LBL "LR" |