Std. error for OLS Least sequares is an important statistic used for data analysis.
The function OLSError in this file demonstrated calculation of standard error for the coefficients of OLS
The fucntion is :
OLSError(xMat As Variant, yArr As Variant, beta As Variant) As Variant
xMat : matrix of independent variables
yMat : array of observed variables
beta : estimated coefficeints of regression model obtained by OLS
It returns an array of std. error values.
Algorithm is:
1.Get array of residuals
ResidualsVec = yArr - xMat*beta
2. Calcualte residual sum of sqaures (RSS)
rss = ResidualsVec'*ResidualsVec
3.Calculate degrees of freedom
df = no. of observed variables - no. of parameters in xMat
4.Calculate variance of residuals
Residualsvariance = rss / df
5.Calculate std. error vector