function z =regresion(x, y, mod, SSR_old)

[SSE, SSR, b] = modelo(x, y, mod);

v1 = 1;
v2 = length(y)-1-length(mod);
R = SSR - SSR_old;
F = R/(SSE/v2);
s2 = SSE/v2;
SST = SSE + SSR;
Fc = finv(0.95, v1, v2);

alfa = 0.01;

fprintf('---------------------------------------------------------------------\n');
fprintf('Analisis de Varianza');
fprintf('  y = %5.2f', b(1)); 
for m = 1:length(mod)
    if(b(m+1)>=0), fprintf(' + %5.2f * X(%d)', b(m+1), mod(m))
    else fprintf(' %5.2f * X(%d)', b(m+1), mod(m))
    end; 
end;
fprintf('\n');
fprintf('---------------------------------------------------------------------\n');
fprintf('Fuente de     Suma            Grados de      Cuadrado        F calc\n');
fprintf('Variacion     cuadrados       Libertad          medio         \n');
fprintf('---------------------------------------------------------------------\n');
fprintf('Regresion %13.2f  %13.f  %13.2f %13.2f\n', SSR, v1, SSR/v1, F);
fprintf('Error     %13.2f  %13.f  %13.2f \n', SSE, v2, s2);
fprintf('Total     %13.2f  %13.f  \n', SST, v1+v2);
fprintf('---------------------------------------------------------------------\n');
fprintf('Con (1-alfa) = %5.3f tenemos %13.2f > %13.2f\n', 1-alfa, F, Fc);
fprintf('R(bj|b) = SSR(bj U b) - SSR(b) = %13.2f R^2 = %13.5f\n', R, SSR/SST);
%fprintf('       SSE        SSR         R          s2          F       Fcalc\n');
%fprintf('%10.3f %10.3f %10.3f %10.3f %10.3f %10.3f\n', SSE, SSR, R, SSE/v2, f, fcal);
z = SSR;
fprintf('\n \n');