function partial_resid_plots(X,results,vnames)

% PARTIAL_RESIDUAL_PLOTS displays the partial residual plots for each
% variable in an OLS regression using the outputs of OLS_TS.

%INPUTS:        X = nxk vector of explanatory variables 
%         results = output of ols_ts
%          vnames = names of variables, for example
%                  strvcat('y','var1',var2'). 



beta = results.beta;

m = length(beta);

b = beta(2:m);

k = m - 1;

resid = results.resid;

n = length(resid);

for i = 1:k
    
    Xi = X(:,i);
    
    resid_i = b(i)*Xi + resid;
    
    plot(Xi,resid_i,'k.','MarkerSize',15); hold on;
    
    plot(Xi,b(i)*Xi,'r');
    
    title(['Partial Residual Plot for ',vnames(i+1,:)],'FontSize',12,'FontWeight','bold');

    xlabel(vnames(i+1,:),'FontName','Times','FontSize',12,'FontWeight','bold');
    
    pause;
    
    clf;
    
end
    
close all;   
