0
$\begingroup$

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...

$\endgroup$
3
  • 4
    $\begingroup$ LinearModelFit[{matrix, yVector}] $\endgroup$
    – Coolwater
    Commented May 11, 2018 at 22:02
  • $\begingroup$ 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 $\endgroup$
    – Johu
    Commented Sep 29, 2018 at 20:48
  • $\begingroup$ @Johu thank you for your reply, but the answer provided by Coolwater was good for what I needed. $\endgroup$
    – wilsnunn
    Commented Sep 29, 2018 at 20:53

1 Answer 1

3
$\begingroup$

Turning a great comment into an answer.

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.