Back to main page |
**Email me at:**
Gene!

The program presented below will compute the coefficients for multiple linear regression on the HP-19C or HP-29C. It was written by Mike Richter and appeared in the V5N5P19 issue of PPC Journal (June 1978). Thanks to Mike wherever he is today!

This program is probably borderline in my decision to put it up on the website, since I try to only put up programs that I think people will actually try to key in and use. But, perhaps it will be useful to somebody. If these sort of programs ARE still useful, let me know. I can always add more stuff like this.

The form of the equation that this program computes is : a x + b y + c = z

1) Key in the program and initialize by CLRG.

2) Data are entered by X ENTER Y ENTER Z GSB 0.

3) Data are corrected by X ENTER Y ENTER Z GSB 1.

4) When all data points have been entered, compute the coefficients by GSB 9.

5) Coefficients will be in the stack in this order:

Stack register X will contain the "a" coefficient for X

Stack register Y will contain the "b" coefficient for Y

Stack register Z will be empty (have a zero in it)

Stack register T will contain the "c" coefficient (the "intercept")

6) You may compute these coefficients at any time, as the calculation does not upset or change any previously keyed in information. To continue entering data, just do step 2 above.

7) You may estimate a "Z" for any X and Y as follows: Enter X, RCL 7, *, Enter Y, RCL 0, *, +, RCL 8, +

**Sample Calculation: ** (x, y, z) = (0,0,3); (0,1,4); (1,0,5); (1,1,6).
After entering the data and doing a GSB 9, the following values should be in the stack:

X: 2, Y: 1, Z: 0, T: 3.5

Line Instruction 01 LBL 0 02 GSB 3 03 SIGMA+ 04 RCL 3 05 GTO 5 06 LBL 1 07 GSB 3 08 SIGMA- 09 RCL 3 10 CHS 11 LBL 5 12 ST0+ 4 13 * 14 STO+ 6 15 LSTX 16 RCL 1 17 * 18 STO+ 5 19 RCL. 0 20 RTN 21 LBL 3 22 STO 3 23 RDN 24 STO 2 25 X <> Y 26 STO 1 27 RTN 28 LBL 9 29 RCL . 0 30 RCL . 2 31 * 32 RCL . 1 33 X^2 34 - 35 STO 8 36 RCL . 0 37 RCL 6 38 * 39 RCL . 3 40 RCL 4 41 * 42 - 43 * 44 STO 0 45 RCL . 0 46 RCL . 5 47 * 48 RCL . 1 49 RCL . 3 50 * 51 - 52 STO 9 53 RCL . 0 54 RCL 5 55 * 56 RCL . 1 57 RCL 4 58 * 59 - 60 STO 7 61 * 62 STO- 0 63 RCL 8 64 RCL . 0 65 RCL . 4 66 * 67 RCL . 3 68 X^2 69 - 70 * 71 RCL 9 72 X^2 73 - 74 STO / 0 75 RCL 0 76 RCL 9 77 * 78 STO - 7 79 RCL 8 80 STO / 7 81 RCL 4 82 RCL 0 83 RCL . 3 84 * 85 - 86 RCL 0 87 RCL . 1 88 * 89 - 90 RCL . 0 91 / 92 STO 8 93 0 94 RCL 0 95 RCL 7 96 PRST 97 RTN

That's it!