# Multiple simple linear regression

Lets $X_{n \times p}$ ans $Y_{k\times n}$ be two matrix that their columns have been centered (the means columns of both matrix are equal to 0).

Using R I can get $C_{k\times p}=cov(Y, X)$ that is a matrix whose elements $c_{ij}$ are the covariance of the columns $y_i$ and $x_j$.

Lets $B_{k\times p}$ and $T_{k \times p }$ be two matrix where:

• $B_{k\times p}$ is a matrix whose elements $b_{ij}$ are the coefficient of a simple linear regression between the columns $y_i$ and $x_j$ (the coefficients of the R output lm(Y[,i]~X[,j]))
• $T_{k \times p }$ is a matrix whose elements $t_{ij}$ are the t-values associated to the coefficients $b_{ij}$.

How can I get this two matrix $B_{k\times p}$ and $T_{k \times p }$ using R? Is it possible to get this matrix without loops? What is the best way to get this matrix (in an efficient way)? I want to get this matrix through a R function or matrix calculation (if possible).

For example I can get $C=n(Y^*)^TX^*$ where $Y^*$ and $X^*$ are the Y and X matrix standarized (by columns).

I found how to get the $B_{k \times p}$ matrix.
lets $Sy$ and $Sx$ be two diagonal matrix with the standard deviation of $Y$ and $X$.
$B=Sy C Sx^{-1}$.
I found how to get $T_{k \times p}$ matrix
$T=\frac{R\sqrt{n-2}}{\sqrt{1-R^2}}$ where $R_{k \times p}$ is a matrix with whose elements are the $\rho_{ij}$