%% Exercise 89 2011

Y=[230 181 165 150 97 192 181 189 172 170]';
X=[125 99 97 115 120 100 80 90 95 125;
   200 55 105 85 0 150 85 120 110 130;
   109 107 98 71 82 103 111 93 86 78]';
[n p]=size(X);

X=[ones(n,1) X]; % adding one colum

beta=inv(X'*X)*X'*Y % estimation of the linear coefficient beta hat

e=Y-X*beta; % deviation

Y_hat=X*beta; % the linear regression line

SE=sqrt((Y-Y_hat)'*(Y-Y_hat)/(n-(p+1))); % standard deviation of beta hat

t=beta./SE % test statistics

alpha=0.1; % 5% significance level

tinv(1-alpha/2,n-(p+1)) 