Motivation
I'm using TeXmacs to write math assignments and Maxima as CAS program. I recently found out how to use plot2d
in gnuplot via Maxima.
Questions
- I now need to plot a linear regression line using some coordinates / table data.
- And it would be nice to be able to get the linear regression function
f(x) = mx+b
orf(x) = a+bx
from the same data. Nice to have - not required. - I also need to draw a residual plot from the same data. Perhaps getting the
r^2
value.
Researched
I have read https://stackoverflow.com/a/9077851/205696 which answers how to draw a regression line in gnuplot but I do not know how to port that to the plot2d
function in Maxima.
I also read this Q/A that explains how to calculate the equation for linear regression with Maxima but I am frankly not good enough in math to understand what is actually going on.
I found out that I can plot linear regressions with GeoGebra, but I do not see a way to draw a residual plot or to get f(x) = mx+b
on the data I have provided (I can calculate f(x) = ax+b
from observation but it would be nice to get exact numbers).
Explanatory images
Data table and linear regression line in TI Nspire.
Data table, linear regression line and residual plot in TI Nspire.