Linear regression analysis program with graph plot for DM42
Posted: Mon Feb 12, 2018 10:29 am
Here is my linear regression graph plotting program, which gives gradients, intercepts and standard errors in both (correctly!). It uses a menu too, and the graph can be manipulated in a few ways: explained below.
First, the code, including my timing programs too (sorry).
Next, the .raw file.
[OLDER ATTACHMENT REMOVED]
To use, place a matrix on the X-register with dimensions Zx2, where Z is the number of data points. The left column of the matrix is the x-axis values and the right column of the matrix is the y-axis values.
You can exit out of this by pressing a different menu button (not the F1 button, that just redraws the graph. Maybe I'll change that to a 'BACK' button in a later version) or pressing R/S.
The other buttons that show gradient, error in gradient, intercept and error in intercept all show the values on the screen using the current display settings (to be updated in a future version) and leave values on the stack if you EXIT out. Pressing the CHNGE allows some graph manupulation, such as SWAPX which swaps the X and Y axes around (and indicates such with the flag 1 being set), Z^? raises an axis to a power (2, 0.5, -1, whatever you like, first you give the power, then you choose the axis to affect) and CHNGE does some other change to a given axis, but needs a program called CHANGE with the change to implement.
The menu works pretty well, and I'm happy with the outcome so far. I just need to tweak the display settings - I want the program to choose 3-sigfig SCI notation for the gradients, intercepts and errors being displayed, then return to the previous settings when the program is EXITed. Shouldn't be too tricky to do at some time soon.
Please let me know what you think and what I need to do to improve it. If it's broken, let me know! Uses the default statistical registers, Flag 1, 2 and Flag 81.
First, the code, including my timing programs too (sorry).
Code: Select all
[OLDER CODE REMOVED
[OLDER ATTACHMENT REMOVED]
To use, place a matrix on the X-register with dimensions Zx2, where Z is the number of data points. The left column of the matrix is the x-axis values and the right column of the matrix is the y-axis values.
You can exit out of this by pressing a different menu button (not the F1 button, that just redraws the graph. Maybe I'll change that to a 'BACK' button in a later version) or pressing R/S.
The other buttons that show gradient, error in gradient, intercept and error in intercept all show the values on the screen using the current display settings (to be updated in a future version) and leave values on the stack if you EXIT out. Pressing the CHNGE allows some graph manupulation, such as SWAPX which swaps the X and Y axes around (and indicates such with the flag 1 being set), Z^? raises an axis to a power (2, 0.5, -1, whatever you like, first you give the power, then you choose the axis to affect) and CHNGE does some other change to a given axis, but needs a program called CHANGE with the change to implement.
The menu works pretty well, and I'm happy with the outcome so far. I just need to tweak the display settings - I want the program to choose 3-sigfig SCI notation for the gradients, intercepts and errors being displayed, then return to the previous settings when the program is EXITed. Shouldn't be too tricky to do at some time soon.
Please let me know what you think and what I need to do to improve it. If it's broken, let me know! Uses the default statistical registers, Flag 1, 2 and Flag 81.