% % Written by: % -- % John L. Weatherwax 2009-04-21 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- close all; drawnow; clear functions; rehash; clc; [X,Y] = load_narula_wellington(); n = size(X,1); alpha = 0.05; % prepend a column of zeros for the constant term: X = [ ones(n,1), X ]; % begin with a regression model consisting of ALL variables: % [beta,sC,s_hat,t_stats,SSE,SSR,SSTO,R2,MSR,MSE,F_ratio,MI] = wwx_regression(X,Y,1); % drop the variable X_2: X(:,2+1) = []; [beta,sC,s_hat,t_stats,SSE,SSR,SSTO,R2,MSR,MSE,F_ratio,MI] = wwx_regression(X,Y,1); % drop the variable X_4: X(:,4) = []; p = 2; [beta,sC,s_hat,t_stats,SSE,SSR,SSTO,R2,MSR,MSE,F_ratio,MI] = wwx_regression(X,Y,1); % evaluate the sale price of this house: x = [ 1, 10.0, 1.5 ]; y_hat = (x) * beta; s2 = MSE; s = sqrt(MSE); t_value = tinv( 1-0.5*alpha, n-p-1 ); % the prediction interval is given by: y_hat + t_value * s * sqrt( ( 1 + x * (MI * x.') ) ) * [ -1, +1 ]