summaryrefslogtreecommitdiff
path: root/macros/ols.sci
diff options
context:
space:
mode:
Diffstat (limited to 'macros/ols.sci')
-rw-r--r--macros/ols.sci36
1 files changed, 18 insertions, 18 deletions
diff --git a/macros/ols.sci b/macros/ols.sci
index f2b0b35..e9a9148 100644
--- a/macros/ols.sci
+++ b/macros/ols.sci
@@ -1,22 +1,22 @@
-/*
-Description:
- Ordinary least squares estimation.
- OLS applies to the multivariate model y = x*b + e with mean (e) = 0 and
- cov (vec (e)) = kron (s, I). where y is a t by p matrix, x is a t by k matrix, b is a k by p matrix, and e is a t by p matrix.
- Each row of y and x is an observation and each column a variable.
- The return values beta, sigma, and r are defined as follows.
-Calling Sequence:
- [beta, sigma, r] = ols (y, x)
-Arguments:
- beta:
- The OLS estimator for b. beta is calculated directly via inv (x'*x) * x' * y if the matrix x'*x is of full rank. Otherwise, beta = pinv (x) * y where pinv (x) denotes the pseudoinverse of x.
- sigma
- The OLS estimator for the matrix s,
- sigma = (y-x*beta)'* (y-x*beta) / (t-rank(x))
- r
- The matrix of OLS residuals, r = y - x*beta.
-*/
+
function [bt, sigma, r] = ols (y, x)
+// Description:
+// Ordinary least squares estimation.
+// OLS applies to the multivariate model y = x*b + e with mean (e) = 0 and
+// cov (vec (e)) = kron (s, I). where y is a t by p matrix, x is a t by k matrix, b is a k by p matrix, and e is a t by p matrix.
+// Each row of y and x is an observation and each column a variable.
+// The return values beta, sigma, and r are defined as follows.
+// Calling Sequence:
+// [beta, sigma, r] = ols (y, x)
+// Arguments:
+// beta:
+// The OLS estimator for b. beta is calculated directly via inv (x'*x) * x' * y if the matrix x'*x is of full rank. Otherwise, beta = pinv (x) * y where pinv (x) denotes the pseudoinverse of x.
+// sigma
+// The OLS estimator for the matrix s,
+// sigma = (y-x*beta)'* (y-x*beta) / (t-rank(x))
+// r
+// The matrix of OLS residuals, r = y - x*beta.
+
function [u , p] = formatted_chol(z)
//p flags whether the matrix A was positive definite and chol does not fail. A zero value of p indicates that matrix A is positive definite and R gives the factorization. Otherwise, p will have a positive value.
ierr = execstr (" u = chol (z);",'errcatch' )