function [B_hat, R_sqd]=ols(y,x) [t n]=size(x), B_hat=inv(x'*x)*(x'*y), R_sqd=1-((y-B_hat*x)'*(y-B_hat*x)/t)/cov(y)