0
$\begingroup$

This question already has an answer here:

This is

MatrixForm[ {{1., 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1.5, 1.5, 1.5, 2, 2, 2.2, 2.4, 2.5, 2.5, 2.8, 2.8, 3, 3, 3.2, 3.3}}]

$X^t$ and this

MatrixForm[ {{101.4, 117.4, 117.1, 106.2, 131.9, 146.9, 146.8, 133.9, 111.3, 123, 125.1, 145.2, 134.3, 144.5, 143.7, 146.9}}] $Y^t$,

I tried [x*Transpose[x]] but Mathematica does nothing, does not gives the 2x2 matrix.

At first I tried to indicate the complete $(X^tX)^{-1}X^tY$ but returned a really big output, I didn't understand fully so I tried first by parts.

Could someone please help?

$\endgroup$

marked as duplicate by corey979, Henrik Schumacher, JimB, m_goldberg, Michael E2 Feb 8 at 0:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 8
    $\begingroup$ Don't use MatrixForm. It is a wrapper only meant for display. $\endgroup$ – Henrik Schumacher Feb 7 at 21:47
3
$\begingroup$
Xt = {{1., 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1.5, 1.5,
     1.5, 2, 2, 2.2, 2.4, 2.5, 2.5, 2.8, 2.8, 3, 3, 3.2, 3.3}};

Yt = {101.4, 117.4, 117.1, 106.2, 131.9, 146.9, 146.8, 133.9, 111.3, 
   123, 125.1, 145.2, 134.3, 144.5, 143.7, 146.9};

Inverse[Xt.Transpose[Xt]].Xt.Yt

{93.3422, 15.6485}

Or

X = Transpose@{{1., 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 
     1.5, 1.5, 1.5, 2, 2, 2.2, 2.4, 2.5, 2.5, 2.8, 2.8, 3, 3, 3.2, 3.3}};

Y = {101.4, 117.4, 117.1, 106.2, 131.9, 146.9, 146.8, 133.9, 111.3, 
   123, 125.1, 145.2, 134.3, 144.5, 143.7, 146.9};

Inverse[Transpose[X].X].Transpose[X].Y
$\endgroup$
4
$\begingroup$

It looks like what you are after is the least squares solution. This is probably most robustly done using the LeastSquares function...

x = Transpose@{{1., 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 
           {1, 1.5, 1.5, 1.5, 2, 2, 2.2, 2.4, 2.5, 2.5, 2.8, 2.8, 3, 3, 3.2, 3.3}};
y = {101.4, 117.4, 117.1, 106.2, 131.9, 146.9, 146.8, 133.9, 111.3, 123, 125.1, 
            145.2, 134.3, 144.5, 143.7, 146.9};
LeastSquares[x, y]
$\endgroup$

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