***PANEL DATA***** **indicate the working path cd "C:\Users\Aki\Documents\stata" log using april25.log, replace use nlswork ***start with declaring that data is panel xtset idcode year **describe our data xtdescribe **summary stats xtsum hours sum hours xtsum race //xtsum provides more detailed summary statistics information, including within and between variation/st.dev. Within: is how individual varies over time (the same individual). Between: how individual's data varies compared to other individuals in the dataset tab race xttab race **running regressions **the relationship between education and wage reg ln_wage collgrad i.race ttl_exp hours reg ln_wage collgrad i.race ttl_exp hours, cluster (idcode) //if we have repeated individuals/households observed over time, clustering standard errors is useful. sum year reg ln_wage collgrad i.race ttl_exp hours i.year, cluster (idcode) //to control for time trend and macro conditions, need to include a time variable **to control for some unobserved heterogeneity, use panel data methods **fixed effect xtreg ln_wage collgrad i.race ttl_exp hours i.year, fe //time invariant variables will be dropped from the results table **random effect xtreg ln_wage collgrad i.race ttl_exp hours i.year, re //correlation between X var and U is assumed to be zero **Hausman test (helps to decide between fixed and random effects) use nlswork, clear xtreg ln_wage age collgrad i.union, fe estimates store fixed_effects xtreg ln_wage age collgrad i.union, re estimates store random_effects hausman fixed_effects random_effects //P-value is 0.0000: reject Ho. Hausman test suggests that fixed effects results are more reliable log close