******************************************************************************** * Author: Henrique Castro Martins * Email: hcm@iag.puc-rio.br * Date: May 2020 * Please, let me know if you find any error in the code below. * Please, download the dataset CEOSAL1.dta from the website: https://www.cengage.com/aise/economics/wooldridge_3e_datasets/ * This is a dataset used by Wooldridge - Introductory Econometris 7ed. ******************************************************************************** * Importing dataset use "CEOSAL1.DTA" , replace * Statistics of salary sum salary , d * OLS model reg salary roe predict salaryhat , xb /* Predict values for dependent variable */ predict uhat, resid /* Predict regression residuals */ egen salarymean = mean(salary) /* Generating the mean of salary */ * r-squared is simply the ratio of portion explained over total that could be explained - Understanding what SSR, SSE and SST mean twoway (scatter salary roe) (lfit salary roe) (lfit salarymean roe) egen sst = total((salary - salarymean)^2) /* Sum of Squares Total */ egen ssr = total((salary - salaryhat)^2) /* Sum of Squares Residual */ egen ssrB = total(uhat^2) /* Sum of Squares Residual */ egen sse = total((salaryhat - salarymean)^2) /* Sum of Squares Explained */ di sse / sst * Regression in ln --> coeficients are % changes reg lsalary lsales /* means that a 1% increase in sales leads to a 0.257% of increase in salary */ * Regression with binary variables - it is a comparison of means bys utility : sum salary /* See the salaries when firm is utility and when it is not */ reg salary utility * Regression with roe/100 gen roe100 = roe / 100 reg salary roe100 /* Only changes the "magnitude" of Beta, but interpretation is the same. */