Simple Linear Regression
Assumes stat regs 11 - 16. 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 X, Y, and Z. 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.
01 LBL "LR"
02 MEAN
03 *
04 RCL 16
05 *
06 CHS
07 RCL 15
08 +
09 RCL 11
10 X^2
11 RCL 16
12 /
13 CHS
14 RCL 12
15 +
16 /
17 STO 17
18 MEAN
19 RCL 17
20 *
21 -
22 STO 18
23 MEAN
24 *
25 RCL 16
26 *
27 CHS
28 RCL 15
29 +
30 RCL 16
31 1
32 -
33 ENTER
34 ENTER
35 SDEV
36 *
37 *
38 /
39 STO 19
40 RCL 18
41 RCL 17
42 RTN
43 LBL "XHAT"
44 RCL 18
45 -
46 RCL 17
47 /
48 RTN
49 LBL "YHAT"
50 RCL 17
51 *
52 RCL 18
53 +
54 END