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];

[SSE, SSR, b] = modelo(x, y, [1 2 3])

n = length(x(:,1));
k = length(x(1,:));

v1 = k;
v2 = n-k-1;

S = sqrt(SSE/(n-k-1))

Cov =inv([ones(length(x(:,1)),1), x]'*[ones(length(x(:,1)),1), x])

Tc = Tinv(0.99, v2);
Fc = Finv(0.98, 1, v2);

mods= [2 3; 1 3; 1 2]
for m = 2:k+1;
  T = b(m)/S/sqrt(Cov(m,m));
  [SSE_r, SSR_r, b_r] = modelo(x, y, mods(m-1,:))
  F = (SSR - SSR_r)/S/S
  fprintf('prueba (t)para X%d %10.3f < %10.3f < %10.3f \n', m-1, -Tc, T, Tc);
  fprintf('prueba (f)para X%d %10.3f < %10.3f \n', m-1, Fc, F);
end;
