#delimit ;
set more 1;
set matsize 700;
log using /volumes/ddisk/bgh/programs/goldinkatz.log, replace;

*USES ORIGINAL GOLDIN-KATZ DATA;
*THIS PROGRAM IS FROM LARRY AND FIRST PART OF PROGRAM DOES HIS TABLE 8.4 IN GOLDIN-KATZ;

*RENAME SOME VARIABLES FOR SIMPLICITY;
*RWAGE IS THE GK VARIABLE WTD, THE HIGH SCHOOL PREMIUM;
*HWAGE IS THE GK HISTORICAL RESCALING OF WTD, FOR 8-12 YRS OF SCHOOLING;
*RQUANT IS THE EFFICIENCY UNIT RATIO VARIABLE;
*I WILL USE THE RWAGE DATA THAT HAS NOT BEEN RESCALED, DOESN'T MATTER FOR POST-63 DATA;

use /volumes/ddisk/immigration/impact/goldinkatz/aggdata.dta, clear;

generate decade=int(year/10);

generate time1=year-1914;
generate time2=time1*time1;
generate time3=time1*time1*time1;
generate time4=time1*time1*time1*time1;

gen t49 = max(year-1949,0);
gen t59 = max(year-1959,0);
gen t92 = max(year-1992,0);

generate t69=max(year-1969,0);
generate t79=max(year-1979,0);
generate t89=max(year-1989,0);
generate t99=max(year-1999,0);

generate rquant49=rquant*(year>1949);
generate rquant59=rquant*(year>1959);
generate rquant92=rquant*(year>1992);

*COLUMN 1 REGRESSION;
regress hwage rquant t49 t92 time1;
regress hwage rquant rquant49 rquant92 t49 t92 time1;

*COLUMN 2 REGRESSION;
regress hwage rquant t59 t92 time1;
regress hwage rquant rquant59 t59 t92 time1;
regress hwage rquant rquant59 rquant92 t59 t92 time1;

*COLUMN 3 REGRESSION;
generate d49=(year==1949);
regress hwage rquant d49 t59 t92 time1;
regress hwage rquant rquant49 t59 t92 time1;
regress hwage rquant rquant49 rquant92 t59 t92 time1;
regress hwage rquant rquant59 t59 t92 time1;
regress hwage rquant rquant59 rquant92 t59 t92 time1;

*COLUMN 4 REGRESSION;
regress hwage rquant rquant49 t49 t92 time1;
regress hwage rquant rquant49 rquant92 t49 t92 time1;

generate inter1=time1*rquant;
generate inter2=time1*time1*rquant;

*COLUMN 5 REGRESSION;
regress hwage rquant inter1 time1 time2 time3 time4;
generate elast=_b[rquant] + _b[inter1]*time1;
tabulate decade, sum(elast);
drop elast;

regress hwage rquant inter1 inter2 time1 time2 time3 time4;
generate elast=_b[rquant] + _b[inter1]*time1 + _b[inter2]*time2;
tabulate decade, sum(elast);
drop elast;


*NOW COMES THE WORK FOR BGH;


*NOW I'M GOING TO RUN THE SAME REGRESSIONS USING ONLY THE POST-1963 CPS DATA;
*AND I'M USING THE ORIGINAL WAGE VARIABLE, NOT THE HISTORICAL TRANSFORMATION;
*I'LL ALSO REDEFINE THE TREND VARIABLE TO START FROM 1963;

keep if year>=1963;

drop time1 time2 time3 time4 inter1 inter2;
generate trend=year-1963;
generate trend2=trend*trend;
generate trend3=trend*trend*trend;


*COLUMN 1 BASELINE REGRESSION;
regress rwage rquant trend t92, robust;


*NO TREND;
regress rwage rquant, robust ;


*LINEAR SPECIFICATION;
regress rwage rquant trend, robust;


*A QUADRATIC TREND;
regress rwage rquant trend trend2, robust;


*A CUBIC TREND;
regress rwage rquant trend2 trend3, robust;


*A POST-1980 SPLINE;
generate t80=max(year-1980, 0);
regress rwage rquant trend t80, robust;
regress rwage rquant trend t80 t92, robust;



forvalues i=1964(1)2005 {;

generate y`i'=max(year-`i', 0);
regress rwage rquant trend y`i', robust;

};


log close;