0
$\begingroup$

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$
1
  • 8
    $\begingroup$ Don't use MatrixForm. It is a wrapper only meant for display. $\endgroup$ Feb 7, 2019 at 21:47

2 Answers 2

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$
5
$\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.