Home > freetb4matlab > statistics > base > ols.m

# ols

## PURPOSE

% Ordinary least squares estimation for the multivariate model

## SYNOPSIS

function [BETA, SIGMA, R] = ols (Y, X)

## DESCRIPTION

% -*- texinfo -*-
% @deftypefn {Function File} {[@var{beta}, @var{sigma}, @var{r}] =} ols (@var{y}, @var{x})
% Ordinary least squares estimation for the multivariate model
% @iftex
% @tex
% $y = x b + e$
% with
% $\bar{e} = 0$, and cov(vec($e$)) = kron ($s, I$)
% @end tex
% @end iftex
% @ifnottex
% @math{y = x b + e} with
% @math{mean (e) = 0} and @math{cov (vec (e)) = kron (s, I)}.
% @end ifnottex
%  where
% @iftex
% @tex
% $y$ is a $t \times p$ matrix, $x$ is a $t \times k$ matrix,
% $b$ is a $k \times p$ matrix, and $e$ is a $t \times p$ matrix.
% @end tex
% @end iftex
% @ifnottex
% @math{y} is a @math{t} by @math{p} matrix, @math{x} is a @math{t} by
% @math{k} matrix, @math{b} is a @math{k} by @math{p} matrix, and
% @math{e} is a @math{t} by @math{p} matrix.
% @end ifnottex
%
% Each row of @var{y} and @var{x} is an observation and each column a
% variable.
%
% The return values @var{beta}, @var{sigma}, and @var{r} are defined as
% follows.
%
% @table @var
% @item beta
% The OLS estimator for @var{b}, @code{@var{beta} = pinv (@var{x}) *
% @var{y}}, where @code{pinv (@var{x})} denotes the pseudoinverse of
% @var{x}.
%
% @item sigma
% The OLS estimator for the matrix @var{s},
%
% @example
% @group
% @var{sigma} = (@var{y}-@var{x}*@var{beta})'
%   * (@var{y}-@var{x}*@var{beta})
%   / (@var{t}-rank(@var{x}))
% @end group
% @end example
%
% @item r
% The matrix of OLS residuals, @code{@var{r} = @var{y} - @var{x} *
% @var{beta}}.
% @end table
% @end deftypefn

## CROSS-REFERENCE INFORMATION

This function calls:
This function is called by:

Generated on Sat 16-May-2009 00:04:49 by m2html © 2003