(35S) Linearized SCurve (Logistic Curve) Regression

03122018, 04:08 AM
(This post was last modified: 03132018 05:05 AM by gerry_in_polo.)
Post: #1




(35S) Linearized SCurve (Logistic Curve) Regression
HP35s Program  Linearized SCurve (Logistic Curve) Regression (Gerardo V. Lozada, M.S., P.E.E., HP35s, 20180310)
Linearizes the Logistic Function (SCurve) so that linear regression may be performed on historical data. S = F/(1+b*e^(c*T)) Program S accepts and stores into F the projected ultimate value or upper limit of the variable to be forecasted and then the given pairs of historical data in the sequence of S (dependent) and then T (independent, i.e. Time), storing them into statistical pair memory via the Σ+ key. Program F then displays F, calculates and displays the values of r, r^2, ln(b), b and c using the 35s' builtin linear regression variables and then uses these values to compute S from given values of T. The program listings below have been cleansed of typographical errors noticed by Dieter (thanks) that resulted from my longhand transcription of the program listing on my 35s (no USB on the 35s to automatically transfer a program). This program has been tested several times on my 35s before I uploaded the listing here. Historical Data Input Routine S001 LBL S S002 CLΣ S003 INPUT F S004 INPUT S S005 RCL F S006 x<>y S007 ÷ S008 1 S009  S010 LN S011 INPUT T S012 Σ+ S013 STOP S014 GTO S004 Regression and Forecasting Routine F001 LBL F F002 VIEW F F003 r F004 STO R F005 VIEW R F006 x^2 F007 STO R F008 VIEW R F009 m F010 +/ F011 STO C F012 VIEW C F013 b F014 STO B F015 VIEW B F016 e^x F017 STO B F018 VIEW B F019 INPUT T F020 RCL C F021 x F022 +/ F023 e^x F024 RCL B F025 x F026 1 F027 + F028 RCL F F029 x<>y F030 ÷ F031 STO S F032 VIEW S GTO F019 

03122018, 09:55 AM
(This post was last modified: 03122018 12:26 PM by Dieter.)
Post: #2




RE: (35S) Linearized SCurve (Logistic Curve) Regression
(03122018 04:08 AM)gerry_in_polo Wrote: HP35s Program  Linearized SCurve (Logistic Curve) Regression (Gerardo V. Lozada, M.S., P.E.E., HP35s, 20180310) First of all: thank you very much for a useful program. I hope you do not mind a few remarks and corrections that will make the program work as intended. ;) (03122018 04:08 AM)gerry_in_polo Wrote: Linearizes the Logistic Function (SCurve) so that linear regression may be performed on historical data. This probably should read S = F / (1+b*e^(–c*T)) (03122018 04:08 AM)gerry_in_polo Wrote: Historical Data Input Routine There is no line S004 where the last step could jump to. Also the variable transformation (linearization) seems to be wrong. I think there is only an X<>Y missing which would explain both problems: S = F / (1+b*e^(–c*T)) <=> ln(F/S – 1) = ln b + (–c)*T So it has to be F/S instead of S/F: Code: S001 LBL S Notes: The STOP after the Σ+ was removed as it is not required – the program directly jumps back to the S prompt. And the CLΣ was placed after the INPUT to avoid clearing the Σ registers if the program is inadvertedly run. I finally tried another version that adds a Σ– function for removing erroneous data and has the user enter the data pairs via T [ENTER] S which is faster than separate prompts for both values. Dieter 

03122018, 11:36 AM
Post: #3




RE: (35S) Linearized SCurve (Logistic Curve) Regression
(03122018 09:55 AM)Dieter Wrote:I also think this is a usseful program, at least for biology and many other subjects(03122018 04:08 AM)gerry_in_polo Wrote: HP35s Program  Linearized SCurve (Logistic Curve) Regression (Gerardo V. Lozada, M.S., P.E.E., HP35s, 20180310) After Dieter´s corrections I would like to test with a numerical example; could you please post some example to illustrate. Thank you in advance, Pedro 

03122018, 01:20 PM
(This post was last modified: 03122018 06:43 PM by Dieter.)
Post: #4




RE: (35S) Linearized SCurve (Logistic Curve) Regression
(03122018 11:36 AM)PedroLeiva Wrote: After Dieter´s corrections I would like to test with a numerical example; could you please post some example to illustrate. For F=100 assume the following data: Code: T 1 2 3 4 5 Start program: Code: [XEQ] S [ENTER] Enter data pairs: Code: S? 20 [R/S] Calculate regression: Code: XEQ F [ENTER] Forecast T => S: Code: [R/S] T? BTW, I would remove the output of ln b (line F014 and F015) since this can be misleading. The value is ln b but the display says it's b. The same is true for the regression coefficient. I'd simply display r here ("R=") and have r² in X so that it may be displayed by pressing the [<=] key, if required. Dieter 

03122018, 02:37 PM
(This post was last modified: 03122018 02:45 PM by gerry_in_polo.)
Post: #5




RE: (35S) Linearized SCurve (Logistic Curve) Regression
I know but I want to see all the variables. The HP35s allows only one letter per variable. They can be easily removed from the program if you want to. The STOP was added so you can see the data counter progress. Again you can remove it. e^(b*T) is a typographical error, it is e^(c*T) in the program. The program listing itself is correct, I have run it several times on various data. Thank you for pointing out the typographical error.


03122018, 05:57 PM
(This post was last modified: 03122018 06:20 PM by Dieter.)
Post: #6




RE: (35S) Linearized SCurve (Logistic Curve) Regression
(03122018 02:37 PM)gerry_in_polo Wrote: I know but I want to see all the variables. The HP35s allows only one letter per variable. They can be easily removed from the program if you want to. The STOP was added so you can see the data counter progress. Again you can remove it. Fine. (03122018 02:37 PM)gerry_in_polo Wrote: e^(b*T) is a typographical error, it is e^(c*T) in the program. The program listing itself is correct, I have run it several times on various data. Gerardo, the S program cannot be correct as it has a jump to line S004 at the end. But such a line does not exist: in the listing line S003 is directly followed by S005. So could you please check again and compare the listing in your post with the original program? I still think that there is a line missing. Please take a look at this part of the code: S005 INPUT S S006 RCL F S007 ÷ S008 1 S009  S010 LN Since S is less than F the quotient S/F is < 1, and this minus 1 is negative. So the program tries to calculate the logarithm of a negative number – which cannot be correct. Dieter 

03122018, 06:54 PM
(This post was last modified: 03122018 08:11 PM by SlideRule.)
Post: #7




RE: (35S) Linearized SCurve (Logistic Curve) Regression
(03122018 11:36 AM)PedroLeiva Wrote: … I would like to test with a numerical example; could you please post some example to illustrate … Equations(s) w Example(s) for the Gompertz Curve from pages 4849 of the HP41 User Library Solutions Business StatMarketingSales booklet… [attachment=5748] [attachment=5749] … as well as the HP12 Solutions Manual … [attachment=5750] [attachment=5751] … and a PPX59 approach … [attachment=5752] BEST! SlideRule 

03122018, 09:34 PM
Post: #8




RE: (35S) Linearized SCurve (Logistic Curve) Regression
(03122018 06:54 PM)SlideRule Wrote:Thank you, I will try these examples(03122018 11:36 AM)PedroLeiva Wrote: … I would like to test with a numerical example; could you please post some example to illustrate … Pedro 

03122018, 10:24 PM
(This post was last modified: 03122018 10:31 PM by gerry_in_polo.)
Post: #9




RE: (35S) Linearized SCurve (Logistic Curve) Regression
Another typographical error, the problem when I have to transcribe the program listing by hand from the 35s manually (no USB). Thanks for catching it. S005 should be S004, inserted the missing x<>y after RCL F. Will update the listing. But the original program on my 35s runs fine, it is the hand transcription which had errors. Corrected the typos now ☺.


« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)