Linear Regression Calculations

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Mkolbe
Posts: 20
Joined: Tue Apr 04, 2017 12:45 am

Linear Regression Calculations

Post by Mkolbe » Fri Jul 23, 2021 5:07 am

We are developing a Visual Lansa Sales Forecasting system.

One potential method we may forecast is through the use of a "trend" in sales history using multiple years of sales data.

If we are asked to calculate this trend through the use of Linear Regression calculations (e.g. X and Y values, slope, etc), I'm curious if there are
any built-in functions and/or Operators that would help in these calculations or would we have to write custom code to do the calculations "long-hand"?

My initial search of the available Mathematical Built-In Functions only finds: Exponential, Random_Num_Generator, Round, and Square_Root.

User avatar
Dino
Posts: 163
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Linear Regression Calculations

Post by Dino » Fri Jul 23, 2021 9:45 am

While built-ins still supported and in use for several things, we now have intrinsic functions, which depends on the type of field and are much faster and easier to use. You just need to add a dot after the field and after a brief second Visual LANSA will display in a drop down all the different intrinsic functions available for you.

For example in this code I am defining a couple of fields as FLOAT and with that, I can use intrinsics like exponential, power, arccosine, arcsine, logarithm, power, sqrt, etc. etc :

Code: Select all

Define Field(#amount1) Type(*FLOAT)
Define Field(#amount2) Type(*FLOAT)
#amount1 := 2
#amount2 := 4
#amount1 := #amount2.Exponential
#amount1 := #amount2.Power( 4 )
and you can combine multiple intrinsic functions, for example:

Code: Select all

#std_amnt := (15/4).AsNumber.Round( HalfUp )
allow autocomplete in the LANSA editor to assist you when creating the lines of codes. just press the . and wait for the dropdown to see all the options.

you can find more about intrinsic here: https://docs.lansa.com/15/en/lansa015/i ... 6_0015.htm

Mkolbe
Posts: 20
Joined: Tue Apr 04, 2017 12:45 am

Re: Linear Regression Calculations

Post by Mkolbe » Sat Jul 24, 2021 3:29 am

I doubted that there was quick "Linear Regression" built-in function, but at least knowing these intrinsic functions exist will help in us developing our own logic. Thanks

Post Reply