clear;


x = [
     1.74  5.30 10.80;
     6.32  5.42  9.40;
     6.22  8.41  7.20;
    10.52  4.63  8.50;
     1.19 11.60  9.40;
     1.22  5.85  9.90;
     4.10  6.62  8.00;
     6.32  8.72  9.10;
     4.08  4.42  8.70;
     4.15  7.60  9.20;
    10.15  4.83  9.40
     1.72  3.12  7.60;
     1.70  5.30  8.20]

y = [ 25.5; 31.2; 25.9; 38.4; 18.4; 26.7; 26.4; 25.9; 32.0; 25.2; 39.7; 35.7; 26.5]

%x = [
%     78 48.2 2.75 29.5;
%     69 45.5 2.15 26.3;
%     77 46.3 4.41 32.2;
%     88 49.0 5.52 36.5;
%     67 43.0 3.21 27.2;
%     80 48.0 4.32 27.7;
%     74 48.0 2.31 28.3;
%     94 53.0 4.30 30.3;
%    102 58.0 3.71 28.7]

%x = [
%     78  2.75;
%     69  2.15;
%     77  4.41;
%     88  5.52;
%     67  3.21;
%     80  4.32;
%     74  2.31;
%     94  4.30;
%    102  3.71]
%y = [57.5; 52.8; 61.3; 67.0; 53.5; 62.7; 56.2; 68.5; 69.2;]
    
n = length(x(:,1))
k = length(x(1,:)) + 1

%Cov = inv([x, y]'*[x, y]);

[SSE, SSR, p] = modelo(x, y, 0)

SST = SSE + SSR;

S2 = SSE/(n-k-1);
f = (SSR/k)/S2

%p(4)
%sqrt(SSE/(n-k-1))
%Cov(3,3)
%t = p(4)/sqrt(SSE*Cov(3,3)/(n-k-1))

%for m = 1: k-1
%  [SSE_R, SSR_R, p_R] = modelo(x, y, m);
%  f_R = (SSR - SSR_R)/S2
%  fcalc = finv(0.99, 1, n-k-1)
%end;