clear version 9.0 log using first_differences_by_hand.log, replace #delimit ; set more off ; *cd "/Users/goodrich/Documents/teaching/Quant1_f06/first_differences/"; *************************************************************************; * File-Name: first_differences_by_hand.do *; * Date: Nov 19, 2006 *; * Author: MG *; * Purpose: Calculate first differences. *; * Data Used: CARD.dta *; * Output File: first_differences_by_hand.log *; * Data Output: simulated_betas.dta *; * Previous File: first_differences.do *; * Machine: mac mini in melanie's office *; * Status: WHONOZ? *; *************************************************************************; use CARD.dta; * Drop some variables we don't need. *; drop reg661-reg669; * Look at Data we will use. *; sum wage exper expersq IQ motheduc educ black south; *************************************************************************; * Run regression with hourly wage in cents as the dependent variable, *; * and the following indenpendent variables: *; * exper years of work experience *; * expersq exper^2 *; * IQ individual's IQ-score *; * motheduc mother's years of schooling *; * educ years of schooling *; * black 1 if black, 0 otherwise *; * south 1 if in the south in 1966, 0 otherwise *; *************************************************************************; regress wage exper IQ motheduc educ black south; *************************************************************************; * Now draw 1000 values of the betahats. *; * The drawnorm command is weird, so it requires us to first 'preserve' *; * the old dataset, as drawnorm blows it away. *; *************************************************************************; preserve; drawnorm MG_b1-MG_b7, n(1000) means(e(b)) cov(e(V)) clear; save simulated_betas, replace; histogram MG_b1, normal; graph export beta_experience.pdf, replace; restore; merge using simulated_betas; summarize _merge; drop _merge; summarize; keep in 1/1000; summarize; *************************************************************************; * The hypothetical individual was computed by setting the independent *; * variables at their sample mean or mode. The hypothetical individual *; * has 9 years of work experience, an IQ of 102, 13 years of *; * schooling, is not black, did not live in the south in 1966, and *; * the hypothetical individual's mother had 10 years of schooling. *; *************************************************************************; scalar h_exper = 9; scalar h_IQ = 102; scalar h_motheduc = 10; scalar h_educ = 13; scalar h_black = 0; scalar h_south = 0; scalar h_constant = 1; generate x_betahat1 = MG_b1*h_exper + MG_b2*h_IQ + MG_b3*h_motheduc + MG_b4*h_educ + MG_b5*h_black + MG_b6*h_south + MG_b7*h_constant; *************************************************************************; * How does our hypothetical individual's predicted hourly wage *; * in cents change if the individual is black, instead of not black? *; *************************************************************************; scalar h_black = 1; generate x_betahat_black = MG_b1*h_exper + MG_b2*h_IQ + MG_b3*h_motheduc + MG_b4*h_educ + MG_b5*h_black + MG_b6*h_south + MG_b7*h_constant; generate diff1 = x_betahat1 - x_betahat_black; summarize x_betahat1 x_betahat_black diff1; *************************************************************************; * How does our hypothetical individual's predicted hourly wage *; * in cents change if the individual was in the south in 1966? *; *************************************************************************; scalar h_black = 0; scalar h_south = 1; generate x_betahat_south =MG_b1*h_exper + MG_b2*h_IQ + MG_b3*h_motheduc + MG_b4*h_educ + MG_b5*h_black + MG_b6*h_south + MG_b7*h_constant; generate diff2 = x_betahat1 - x_betahat_south; summarize x_betahat1 x_betahat_south diff2; *************************************************************************; * How does our hypothetical individual's predicted hourly wage *; * in cents change if the individual's education is two standard *; * deviations below the sample mean compared to two standard *; * deviations above the sample mean? (7.9 vs. 18.62) *; *************************************************************************; scalar h_south = 0; scalar h_educ = ( 13.26 - 2*2.68 ); generate x_betahat_low_educ = MG_b1*h_exper + MG_b2*h_IQ + MG_b3*h_motheduc + MG_b4*h_educ + MG_b5*h_black + MG_b6*h_south + MG_b7*h_constant; scalar h_educ = ( 13.26 + 2*2.68 ); generate x_betahat_high_educ = MG_b1*h_exper + MG_b2*h_IQ + MG_b3*h_motheduc + MG_b4*h_educ + MG_b5*h_black + MG_b6*h_south + MG_b7*h_constant; generate diff3 = x_betahat_low_educ - x_betahat_high_educ; summarize x_betahat_low_educ x_betahat_high_educ diff3; log close; exit;