I want to estimate regression equation $Y=A(X-\bar X)+b+E$, where these variables are multivariate. $Y$ is matrix. $E$ is error, I need to estimate $A$ and $b$. First I decided to estimate them in simple case: $y=a(x_i-\bar x)+b+e$. Differentiated $(y_i-b-a(x_i-\bar x))^2$ with respect to $a$ and $b$
$\sum (y_i-b-a(x_i-\bar x)))=0$
$\sum (x_i-\bar x)(y_i-b-a(x_i-\bar x))=0$
I got
$\hat b=\bar y$
$\hat a=\sum (y_i-\bar y)(x_i-\bar x)/\sum (x_i-\bar x)$
Can you please help me to extend this to multivariate case?
Edit1: $X-\bar X={X_i-\bar X, i=\overline {1,n}}$ is also a matrix with $n$ columns.