clear all close all clc load wage2.mat; % Obs: 935 data = wage; % 1. wage monthly earnings % 2. hours average weekly hours % 3. IQ IQ score % 4. KWW knowledge of world work score % 5. educ years of education % 6. exper years of work experience % 7. tenure years with current employer % 8. age age in years % 9. married =1 if married % 10. black =1 if black % 11. south =1 if live in south % 12. urban =1 if live in SMSA % 13. sibs number of siblings % 14. brthord birth order % 15. meduc mother's education % 16. feduc father's education % 17. lwage natural log of wage wage = data(:,1); hours = data(:,2); IQ = data(:,3); KWW = data(:,4); educ = data(:,5); exper = data(:,6); tenure = data(:,7); age = data(:,8); married = data(:,9); black = data(:,10); south = data(:,11); urban = data(:,12); sibs = data(:,13); brthord = data(:,14); meduc = data(:,15); feduc = data(:,16); lwage = data(:,17); avg_wage = mean(wage); avg_IQ = mean(IQ); std_wage = std(wage); std_IQ = std(IQ); figure subplot(2,1,1) plot(wage,'*') hold on plot(avg_wage*ones(size(wage)),'r') xlabel('pozorovani') ylabel('mzda') subplot(2,1,2) plot(IQ,'*') hold on plot(avg_IQ*ones(size(IQ)),'r') plot((avg_IQ+2*std_IQ)*ones(size(IQ)),'k:') plot((avg_IQ-2*std_IQ)*ones(size(IQ)),'k:') xlabel('pozorovani') ylabel('IQ') legend('IQ','prumer','2*std') yy = wage; XX = [ones(size(yy)) IQ hours]; result = ols(yy,XX); vnames = strvcat('mzda','konstanta','IQ'); prt_reg(result,vnames); ii = ones(935,1); M0 = eye(935)-ii*inv(ii'*ii)*ii'; XX0 = M0*XX; XX0(:,1)=[]; result = ols(M0*yy,XX0); vnames = strvcat('mzda','konstanta','IQ'); prt_reg(result,vnames); result = ols(yy,XX0); vnames = strvcat('mzda','konstanta','IQ'); prt_reg(result,vnames); result = ols(yy,[ones(935,1) XX0]); vnames = strvcat('mzda','konstanta','IQ'); prt_reg(result,vnames); result = ols(M0*yy,XX(:,2:end)); vnames = strvcat('mzda','konstanta','IQ'); prt_reg(result,vnames);