@=================================================================@ @:::::::::::::: OLS.SET:::::::::::::::::::::::::::::::::::::::::::@ @ Basic OLS routine (ncm 8/10/99) @ @ --Written by Nelson Mark ---------------------------------------@ @-----------------------------------------------------------------@ @ Usage: {b,resid,vcv,tratio,rsq}=ols(y,x,c); @ @ @ @ Inputs: y: (T X 1) vector of dependent variables @ @ x: (T X k) matrix of independent variables (no constant)@ @ c=0: No constant @ @ =1: include constant @ @ =2: include constant and trend @ @ @ @ Output: b: OLS estimates. Constant (trend) is last element @ @ resid: Vector of OLS residuals @ @ vcv: OLS coefficient vector covariance matrix @ @ tratio: Vector of OLS t-ratios @ @ rsq: R-square @ @-----------------------------------------------------------------@ proc(5) = ols(y,x,c); local df,i,j,b,resid,vcv,tratio,rsq,sigsq,se; if c eq 1; x=x~ones(rows(x),1); endif; if c eq 2; x=x~ones(rows(x),1)~seqa(1,1,rows(x)); endif; df=rows(x)-cols(x); b=inv(x'x)*x'y; resid=y-x*b; sigsq=resid'resid/df; vcv=sigsq*inv(x'x); se=sqrt(diag(vcv)); tratio=b./se; rsq=1-((resid'resid)/(y'y)); retp(b,resid,vcv,tratio,rsq); endp;