Multiple linear regression for the HP-42S

By Namir Shammas

MLRAN is a program that performs multiple linear regression and provides the following results:

- Coefficients of multiple linear regressions
- Coefficient of determination and its adjusted value
- The regression ANOVA table

Where

SSE = Y' Y - C'X'Y

SST = Y' Y - sum(Y)^2 / N

DF Residuals = K

DF Error = N - K - 1

DF Total = N - 1

MSR = SSR / K

MSE = SSE / (N - K - 1)

Fstat = MSR / MSE

R2 = SSR / SST

R2adj = 1 - (1 - R2) (N - 1) / (N - K - 1)

Where

- Before you start the program you must enter the dependent variable's observations is a column matrix (call it MY) and the independent variables' observations in a matrix (call it MX). The first column of this matrix must be full of ones. The second column in the matrix contains the data for the first independent variable. The third column in the matrix contains the data for the second independent variable, and so on. You can create and edit these matrices in the stack with or without storing them. I recommend storing them to be on the safe side.
- Push matrix MY into the stack (if no in the stack already).
- Push matrix MX into the stack (if no in the stack already)
- Start the program by executing the command XEQ "MLRAN"
- The program prints the regression results.
- To view or review the output on the display execute XEQ "VWRS". The program places the matrix MC on the stack and executes an EDIT command. The program halts while you are inspecting the matrix elements. Once you are done, press R/S to view the other results. Press R/S to view the next results. The program beeps when you there are no more results to display.
- To clear the program's variables except variables MX, MY, and MC, execute the command XEQ "CLRANV". Please remember that once you execute this step you cannot execute step 6 since the variables for the ANOVA table are deleted.

Given the following matrix of observations:

2 2 34 101.010

3 7 26 81.191

4 3 76 14.439

5 5 43 61.667

6 9 23 108.915

7 2 15 113.257

Fit the model:

The column matrix

81.191

14.439

61.667

108.915

113.257

The matrix

1 3 7 26

1 4 3 76

1 5 5 43

1 6 9 23

1 7 2 15

Enter these matrices either in the stack (

MC= [ 4x1 Matrix ]

1:1= 152.0517

2:1= -0.9443

3:1= -1.2403

4:1= -1.7125

R2= 0.9182

R2ADJ= 0.7955

ANOVA TABLE

SSR= 6,445.0129

SSE= 574.2363

SST= 7,019.2492

DFR= 3.0000

DFE= 2.0000

DFT= 5.0000

MSR= 2,148.3376

MSE= 287.1182

FSTAT= 7.4824

The fitted model is:

The coefficient of determination for the above model and data is 0.9182.

To review the results on the LCD, execute command

1:1=152.0517 -> (view next element)

2:1=-0.9443 -> (view next element)

3:1=-1.2403 -> (view next element)

4:1=-1.7125

EXIT

RUN

R2=0.9182

RUN

R2ADJ=0.7955

RUN

SSR=6,445.0129

RUN

SSE=574.2363

RUN

SST=7,019.2492

RUN

DFR=3.0000

RUN

DFE=2.0000

RUN

DFT=5.0000

RUN

MSR=2,148.3376

RUN

MSE=287.1182

RUN

FSTAT=7.4824

RUN

(audible beep)

(The program listing with comments can be downloaded here: listing.txt)

Binary files for emulators:

Raw binary: mlran.raw Binary for HP-42X: mlran.42x (HP-48) mlran49.42x (HP-49)

Generated by 42s2html - 15 June 2005, 11:38