# LinearModelFit with large number of coordinates

I am sorry if this is on here already (or if it is really easy!) I have looked and I am not sure how to go about it. I have data that is 1000 rows and each row contains 200 columns (x1,x2,x3,...)

I am trying to do linear regression of the form $y=\sum_{i=1}^{200}a_ix_i$, however seem to be unable to input it into Mathematica, am I meant to be doing something along the lines of the following:

LinearModelFit[data, {x01, x02, x03, ..., x199, x200}, {x01, x02, x03, ..., x199, x200}]


This doesn't seem like it should be the best way to do it! Please let me know where I am going wrong...

• LinearModelFit[{matrix, yVector}] May 11, 2018 at 22:02
• Answer can only be as specific as the question. We could help you more, if you gave more specific, but simplified version of the problem
– Johu
Sep 29, 2018 at 20:48
• @Johu thank you for your reply, but the answer provided by Coolwater was good for what I needed. Sep 29, 2018 at 20:53

All linear models are of the form $$\vec{y}=\hat{A}\vec{x}$$ and $$\vec{x}$$ can be a long vector. While this problem can be put into a form LinearModelFit[{{x11,c12,...,y1},{x21,x22,...,y2},...},{f1,f2,...},{x1,x2,...}] it might be more useful to use another supported form LinearModelFit[{m,v}], where m is the design matrix and v is the response vector. See the examples in the LinearModelFit documentation.
You could solve your Least-Square problem directly by finding a pseudo inverse PseudoInverse[A], but LinearModelFit has useful additional features for giving you statistics of the residuals.