*==============================================================================* * Advanced Applied Econometrics * Jakub Muck * Exercise 13 * importing data, generating variables of interest and regression clear all use "http://e-web.sgh.waw.pl/jmuck/AAE/Datasets/cps.dta" gen lwage=ln(wage) gen exper2=exper^2 * (ii) regression and generating plots of squared residuals vs explanatory * variables reg lwage educ female exper exper2 estimates store ols predict ehat,res gen ehat2=ehat^2 scatter ehat2 educ scatter ehat2 female scatter ehat2 exper * (iii) The Goldfeld-Quandt test (female vs male) reg lwage educ exper exper2 if female==1 scalar sigma2_female=e(rss)/e(df_r) scalar df_female=e(df_r) reg lwage educ exper exper2 if female==0 scalar sigma2_male=e(rss)/e(df_r) scalar df_male=e(df_r) * Displaying variances, their ratio and test statistics disp sigma2_female disp sigma2_male disp sigma2_female/sigma2_male scalar F=sigma2_male/sigma2_female scalar F_crit=invF(df_male, df_female, 0.95) scalar F_pval=Ftail(df_male,df_female,F) disp "The Goldfeld-Quandt test stratistics: " F disp "The 5% critical value:" F_crit disp "P-value: " F_pval * (iv) The Goldfeld-Quandt test (high-educated vs low-educated) reg lwage educ exper exper2 if educ>12 scalar sigma2_high=e(rss)/e(df_r) scalar df_high=e(df_r) reg lwage educ exper exper2 if educ<13 scalar sigma2_low=e(rss)/e(df_r) scalar df_low=e(df_r) * Displaying variances, their ratio and test statistics disp sigma2_high disp sigma2_low disp sigma2_high/sigma2_low scalar F=sigma2_high/sigma2_low scalar F_crit=invF(df_high, df_low, 0.95) scalar F_pval=Ftail(df_high,df_low,F) disp "The Goldfeld-Quandt test stratistics: " F disp "The 5% critical value:" F_crit disp "P-value: " F_pval * (v) The White test (squares only) gen educ2=educ^2 gen exper4=exper^4 reg ehat2 educ female exper exper2 educ2 exper4 scalar LM=e(r2)*e(N) scalar crit=invchi2(6,0.95) scalar pval=chi2tail(6,LM) disp "The White test stratistics: " LM disp "The 5% critical value:" crit disp "P-value: " pval * The White test (squares and interactions) gen educ_female=educ*female gen educ_exper=educ*exper gen educ_exper2=educ*exper2 gen female_exper=female*exper gen female_exper2=female*exper2 gen exper3=exper^3 reg ehat2 educ female exper exper2 educ2 exper4 educ_female educ_exper educ_exper2 female_exper female_exper2 exper3 scalar LM=e(r2)*e(N) scalar crit=invchi2(12,0.95) scalar pval=chi2tail(12,LM) disp "The White test stratistics: " LM disp "The 5% critical value:" crit disp "P-value: " pval ************** * There are built-in Stata postestimation command like * estat hettest (many version of Breusch-Pagan test) * estat imtest, white (White test with interractions) * (vi) OLS with the HC/White standard errors reg lwage educ female exper exper2, vce(robust) estimates store ols_hc estimates table ols*, b se p * (vii) weighted least squares - variance of the error term depends on education gen weight1=1/educ reg lwage educ female exper exper2 [w=weight1] estimates store wls1 * (viii) weighted least squares - feasible approach gen lehat2=ln(ehat2) reg lehat2 educ female exper exper2 predict lehat2_hat gen ehat2_hat=exp(lehat2_hat) gen weight2=1/(ehat2_hat^.5) reg lwage educ female exper exper2 [w=weight2] estimates store wls2 estimates table ols ols_hc wls1 wls2, b se p