HP Forums

Full Version: (20S and 21S) Simple Logistic Regression
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This program attempts to fit a simple logistic curve of data (X, Y) to the equation:

y = 1/(A + B*e^(-x))

By the following transformations:

X’ = e^(-X)
Y’ = 1/Y

And performing linear regression analysis on X’ and Y’. Note that the data point which includes Y = 0 is not allowed.

The keystrokes for the HP 20S and HP 21S are slightly different. Each program will be shown separately.

Input:
Initialize the data: XEQ A
For each data point: x, [INPUT], y, XEQ B
Calculate the parameters: XEQ C. B is shown first, then A.

HP 20S Program: Simple Logistic Regression
Code:

STEP    CODE    KEY
01    61, 41, A    LBL A
02    61, 75    CLRΣ 
03    61, 26    RTN
04    61, 41, B    LBL B
05    15    1/X
06    51, 31    SWAP
07    32    +/-
08    12    e^x
09    51, 31    SWAP
10    16    Σ+
11    61, 26    RTN
12    61, 41, C    LBL C
13    61, 16    m, b
14    26    R/S
15    51, 31    SWAP
16    61, 26     RTN

HP 21S Program: Simple Logistic Regression

Code:

STEP    CODE    KEY
01    61, 41, A    LBL A
02    61, 75    CLRΣ 
03    61, 26    RTN
04    61, 41, B    LBL B
05    15    1/X
06    51, 31    SWAP
07    32    +/-
08    12    e^x
09    51, 31    SWAP
10    16    Σ+
11    61, 26    RTN
12    61, 41, C    LBL C
13    51, 14    m, b
14    26    R/S
15    51, 31    SWAP
16    61, 26     RTN
Reference URL's