%% 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

beta_0=[65.67;0;0;0];

Y_0=X*beta_0;

alpha=0.05; % 5% significance level

LR_test=n*log(sum((Y-Y_0).^2)/sum((Y-Y_hat).^2)) % LR test statistics

chi2inv(1-alpha,p+1) % chi-square distribution

F_test=(n-p-1)/(p+1)*(sum((Y-Y_0).^2)/sum((Y-Y_hat).^2)-1) % F-test statistics

finv(1-alpha,p+1,n-p-1) % F distribution



