% This program demonstrates how to read in data from a file. 
%
% Written by Kyongwook Choi
% Created on January 20, 1999
% Last Updated on January 20, 1999

load q10data.txt;
y = q10data(:,1);
x = q10data(:,2);

% check how many observations are in the data set

[nobs junk]=size(x);

% Next run OLS with constant

xvar=[ones(nobs,1) x];

xpx=((xvar)'*(xvar));
I=inv(xpx);

bhat=I*xvar'*y

% Run OLS without constant

xpx1=x'*x;
Invx=inv(xpx1);

bhat1=Invx*x'*y
