function [x_est,residual] = caoGLM(A,y)

% Usage:  [x_est] = caoGLM(A,y)
%
% A is a design matrix, with a different column for each stimulus or noise
% model, and nTpts rows.
%
% y is the data, with a different column for each voxel, and nTpts rows.

ATAinvAT = inv(A'*A)*A';

x_est = ATAinvAT*y;

residual = A*x_est - y;