Formulation is as follows
yi=β0+i=1∑kβixi+εi
where i=1,2…,k is the number of regressors.
LSE:∂βi∂SSE=0
Let X∈R1×k and B∈Rk+1×1. Then we need k+1 equations.
Now follow:
yiyi^=β0+i=1∑kβixi+εi=β0+i=1∑kβixi
Then we replace y with Y vector, combining all the equations
Y=y1y2⋮yn , X=11⋮1x1x2⋮xn , B=[β0β1] , ϵ=ϵ1ϵ2⋮ϵn
then
Y=XB+ϵ
is our multiple linear model.
SSE here is
SSE=(Y−XB)T(Y−XB)=ϵTϵ
and LSE is
dBdSSEdBd(Y−XB)T(Y−XB)−2XT(Y−XB)XTXB−XTY(XTX)BB^LSE=0=0=0=0=XTY=(XTX)−1XTY
Here B^LSE is Best Linear Unbiased Estimator for B.
E[B^]V(B^)SE(B^)=B=[V(β^0)Cov(β^1,β^0))Cov(β^0,β^1)V(β^1)]=σ2(XTX)−1=σ2diag(XTX)−1
And sums of square are
SSTSSESSR=YTY−n1YTJY , J=([11…1]T)n×1=εTε=(Y−XB^)T(Y−XB^)=SST−SSE
In R use
solve(A) to find A−1.
t(A) for AT
lm(y~x1+x2+...xn) for multiple linear regression