Saturday, December 7, 2024

Casio fx-CG50 and TI-84 Plus CE: Multiple Linear Regression

Casio fx-CG50 and TI-84 Plus CE: Multiple Linear Regression


We have arrived at the last month of 2024. What a crazy year. I hope for smoother and peaceful times ahead.



Introduction


The program MLREG fits bi-variate data to the linear regression equation:


y = b0 + b1 * t + b2 * x


where t and x are the independent variables, and y is the dependent variable. The program uses a numerical method known as normal equations, to solve the system:


n * b0 + Σ(t) * b1 + Σ(x) * b2 = Σ(y)

Σ(t) * b0 + Σ(t^2) * b1 + Σ(t*x) * b2 = Σ(t*y)

Σ(x) * b0 + Σ(t*x) * b1 + Σ(x^2) * b2 = Σ(x*y)


or in matrix form:


[ [ n ,Σ(t), Σ(x) ] [ Σ(t), Σ(t^2), Σ(t*x) ] [ Σ(x), Σ(t*x), Σ(x^2) ] ] * [ [ b0 ] [ b1 ] [ b2 ] ]

= [ [ Σ(y) ] [ Σ(t*y) ] [ Σ(x*y) ] ]


where:

n is the number of data points,

Σ(t) is the sum of all t data,

Σ(x) is the sum of all x data,

Σ(y) is the sum of all y data,

x * t, t * y, x * y, t^2, x^2 are all represent of the variable element-by-element multiplication of each set


The calculator programs assign the following variables:

n * b0 + Σ(t) * b1 + Σ(x) * b2 = Σ(y)

Σ(t) * b0 + Σ(t^2) * b1 + Σ(t*x) * b2 = Σ(t*y)

Σ(x) * b0 + Σ(t*x) * b1 + Σ(x^2) * b2 = Σ(x*y)


A = n

B = Σ(t)

C = Σ(x)

D = Σ(t^2)

E = Σ(t*x)

F = Σ(x^2)

X = Σ(y)

Y = Σ(t*y)

Z = Σ(x*y)




Casio fx-CG 50 Program: MLREG


This is programmed in Casio Basic.


“Y=B0+B1×T+B2×X”

“T LIST”? → List 4

“X LIST”? → List 5

“Z LIST”? → List 6

If Dim List 4 ≠ Dim List 5 Or Dim List 5 ≠ Dim List 6 Or Dim List 4 ≠ Dim List 6

Then

“LISTS NOT SAME LENGTH” ◢

Stop

IfEnd

Dim List 4 → A

Sum List 4 → B

Sum List 5 → C

Sum (List 4²) → D

Sum (List 4 × List 5) → E

Sum (List 5²) → F

Sum List 6 → X

Sum (List 6 × List 4) → Y

Sum (List 6 × List 5) → Z

“B0,B1,B2=” ◢

[ [A, B, C ][B, D, E][C, E, F] ] ⁻¹ × [ [ X ][ Y ][ Z ] ] → Mat Z



TI-84 Plus CE Program: MLREG


ClrHome

Disp “Y=B0+B1*T+B2*X”

Input “T LIST: “, L₄

Input “X LIST: “, L₅

Input “Y LIST: “, L₆

If dim(L₄) ≠ dim(L₅) or dim(L₅) ≠ dim(L₆) or dim(L₄) ≠ dim(L₆)

Then

Disp “LISTS NOT EQUAL SIZE”

Stop

End

dim(L₄) → A

sum(L₄) → B

sum(L₅) → C

sum(L₄ ²) → D

sum(L₄ * L₅) → E

sum(L₅ ²) → F

sum(L₆) → X

sum(L₆ * L₄) → Y

sum(L₆ * L₅) → Z

[ [ A, B, C ] [ B, D, E ] [ C, E, F ] ] ⁻¹ * [ [ X ] [ Y ] [ Z ] ] → [ J ]

Disp “B0,B1,B2= “, [ J ]


Note: [ J ] is matrix J is called form the Matrix menu.



An Online Multiple Linear Regression Calculator


A multiple linear regression calculator which determine coefficients, quadrants, and other statistics can be found on the stats.blue web page: https://stats.blue/Stats_Suite/multiple_linear_regression_calculator.html


Examples


Example 1


t

x

y

1.12

22.3

100

1.16

22.1

104

1.19

21.8

107

1.23

21.4

110

1.28

21.1

114


Result:

B0 = -48.8333333

B1 = 99.99999999 (TI-84 Plus CE rounds this to 100)

B2 = 1.666666666


Equation:

y = -48.8333333 + 99.99999999 * t + 1.666666666 * x



Example 2


t

x

y

10.2

1.95

1000

10.5

3.00

1002

10.8

4.00

1005

11.1

4.95

1007

11.6

5.80

1009

11.8

6.75

1012

12.1

7.80

1015


Result:

B0 = 1008.157502

B1 = -1.429759754

B2 = 3.052897088


y = 1008.157502 – 1.429759754 * t + 3.052897088 * x


Until next time, when a new series will be introduced. Stay tuned,



Eddie


All original content copyright, © 2011-2024. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts   Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your ...