y: dependent variable
X: independent variable
r: residual
$$y=X\beta+r$$
$$\beta=inv(X’*X)*X’*y$$
$$\sigma^2=r’*r/df$$
$$df=N-rank(X)$$
$$\sigma_\beta^2=\sigma^2inv(X’X)$$
$$T_\beta=\beta/\sigma_\beta$$
$$contrast variance = c’*\sigma_\beta^2*c$$
$$T_{contrast}=c’\beta/\sqrt{contrast variance}$$
$$r=\beta\frac{std(x)}{std(y)}$$
$$\beta=r\frac{std(y)}{std(x)}$$
$$var(y) = \beta^2var(x)+ResSS/(n)$$