Guide to Linear Regression
alexhwoods.com
alexhwoods.com
(specifics here: https://april.eecs.umich.edu/courses/eecs568_f12/linefitting... )
If this comment has even one takeaway, I would like that to be "don't invert, unless you are very sure that is exactly what you need". In some scenarios inverses are indeed required, solving linear equations are almost always not that scenario.
The reason I said iterative optimization algorithms can be used for regression because linear regression is a quadratic optimization problem. We have analytic solutions because of special linear algebra properties. It can be said that we have a good handle on quadratic optimization problems, hence the multitude of algorithm choices. General optimization algorithms necessarily carry cost in numerical instability, but it may be a cost worth paying, especially for large data sets.
Finally, I want to echo your sentiment that DO NOT invert. Solve linear equations should be by tailored algorithms. In theory they yield identical results, in practice specific algorithms are much better.
and helpfully, in this context, if you're starting from the point of minimising the L2 error between the output of some linear function and a target, then the resulting linear system will have the form $A^T A x = A^T b$, so the matrix in question is $A^T A$, so it'll always be positive semidefinite.
The one question which remains: Is there a more intuitive guide which helps you with deciding which features you need to choose in order to get a good regression?
The code goes like this -
install.packages('corrplot') library(corrplot)
mcor <- cor(crime) # if crime is your dataframe corrplot(mcor)
That's one easy way to start out. Perhaps I'll write a post on feature engineering.
http://kastnerkyle.github.io/posts/linear-regression/
Closed form is at the bottom, basically invalidating the whole rest of my post.