*==============================================================================* * Advanced Applied Econometrics * Jakub Muck * Exercise 12 * (i) 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 * In the code below there will be genereated marginal effects (mf), elasticities (el) *--------------------------------- * Linear model reg wage educ exper exper2 female estimates store model1 predict ehat1 * Marginal effect gen mf_educ1=_b[educ] gen mf_exper1=_b[exper]+2*_b[exper2] gen mf_female1=_b[female] * Elasticity gen el_educ1=_b[educ]*educ/wage gen el_exper1=(_b[exper] +2*_b[exper2])*exper/wage *gen el_female1=_b[female]*female/wage * Technically it could be clacualted. But the above commented line does not make sense. * But we can calaculate semi-elasticities in this case. *--------------------------------- * Log-linear model reg lwage educ exper exper2 female estimates store model2 predict ehat2 * Marginal effect gen mf_educ2=_b[educ]*wage gen mf_exper2=(_b[exper]+2*_b[exper2])*wage gen mf_female2=_b[female]*wage * Elasticity gen el_educ2=_b[educ]*educ gen el_exper2=(_b[exper] +2*_b[exper2])*exper *gen el_female2=_b[female]*female * Comparison of marginal effects sum mf* * Comparison of elasticities sum el_* * (ii) Histogram of residuals hist ehat1 hist ehat2 * (iii) Test for normality of the error term sktest ehat*, noadjust * (iv) Histogram of dependent variables hist wage hist lwage sktest wage lwage * (v) Testing colinearity cor educ exper exper2 female estimates replay model1 estat vif *(vi) Adding interaction gen female_educ=female*educ reg lwage educ exper exper2 female female_educ * alternatively, instead of generating new variable one might use expression "c.female##c.educ"