## Chapter 2 - Examples

```-------------------------------------------------------------------------------------
name:  SN
log:  Wooldridge\intro-econx\iexample2.smcl
log type:  smcl
opened on:   5 Jan 2019, 16:59:02

. **********************************************
. * Solomon Negash - Replicating Examples
. * Wooldridge, Jeffery (2016). Introductory Econometrics: A Modern Approach. 6th ed.
. * STATA Program, version 15.1.

. * Chapter 2  - The Simple Regression Model
. * Computer Exercises (Examples)
. ******************** SETUP *********************

. *example2.1. N/A

. *example2.2. N/A

. *example2.3. CEO Salary & Return on Equity ; salary = b0 + b1roe + u
. use ceosal1.dta, clear

. regress salary roe

Source |       SS           df       MS      Number of obs   =       209
-------------+----------------------------------   F(1, 207)       =      2.77
Model |  5166419.04         1  5166419.04   Prob > F        =    0.0978
Residual |   386566563       207  1867471.32   R-squared       =    0.0132
Total |   391732982       208  1883331.64   Root MSE        =    1366.6

------------------------------------------------------------------------------
salary |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
roe |   18.50119   11.12325     1.66   0.098    -3.428196    40.43057
_cons |   963.1913   213.2403     4.52   0.000     542.7902    1383.592
------------------------------------------------------------------------------

. *example2.4.
. u wage1.dta, clear

. sum wage educ

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
wage |        526    5.896103    3.693086        .53      24.98
educ |        526    12.56274    2.769022          0         18

. reg wage educ

Source |       SS           df       MS      Number of obs   =       526
-------------+----------------------------------   F(1, 524)       =    103.36
Model |  1179.73204         1  1179.73204   Prob > F        =    0.0000
Residual |  5980.68225       524  11.4135158   R-squared       =    0.1648
Total |  7160.41429       525  13.6388844   Root MSE        =    3.3784

------------------------------------------------------------------------------
wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ |   .5413593    .053248    10.17   0.000     .4367534    .6459651
_cons |  -.9048516   .6849678    -1.32   0.187    -2.250472    .4407687
------------------------------------------------------------------------------

. *example2.5.
. u vote1.dta, clear

. reg voteA shareA

Source |       SS           df       MS      Number of obs   =       173
-------------+----------------------------------   F(1, 171)       =   1017.66
Model |  41486.2307         1  41486.2307   Prob > F        =    0.0000
Residual |  6971.01783       171  40.7661862   R-squared       =    0.8561
Total |  48457.2486       172  281.728189   Root MSE        =    6.3848

------------------------------------------------------------------------------
voteA |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
shareA |   .4638269   .0145397    31.90   0.000     .4351266    .4925272
_cons |   26.81221   .8872146    30.22   0.000     25.06091    28.56352
------------------------------------------------------------------------------

. *example2.6.  Table2.2
. use ceosal1.dta, clear

. regress salary roe

Source |       SS           df       MS      Number of obs   =       209
-------------+----------------------------------   F(1, 207)       =      2.77
Model |  5166419.04         1  5166419.04   Prob > F        =    0.0978
Residual |   386566563       207  1867471.32   R-squared       =    0.0132
Total |   391732982       208  1883331.64   Root MSE        =    1366.6

------------------------------------------------------------------------------
salary |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
roe |   18.50119   11.12325     1.66   0.098    -3.428196    40.43057
_cons |   963.1913   213.2403     4.52   0.000     542.7902    1383.592
------------------------------------------------------------------------------

. esttab, r2

----------------------------
(1)
salary
----------------------------
roe                 18.50
(1.66)

_cons               963.2***
(4.52)
----------------------------
N                     209
R-sq                0.013
----------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. predict salaryhat, xb

. predict uhat, residual

. list roe salary salaryhat uhat in 1/15, table separator(15)

+--------------------------------------+
|  roe   salary   salary~t        uhat |
|--------------------------------------|
1. | 14.1     1095   1224.058   -129.0581 |
2. | 10.9     1001   1164.854   -163.8543 |
3. | 23.5     1122   1397.969   -275.9692 |
4. |  5.9      578   1072.348   -494.3483 |
5. | 13.8     1368   1218.508    149.4923 |
6. |   20     1145   1333.215   -188.2151 |
7. | 16.4     1078   1266.611   -188.6108 |
8. | 16.3     1094   1264.761   -170.7607 |
9. | 10.5     1237   1157.454     79.5462 |
10. | 26.3      833   1449.773   -616.7725 |
11. | 25.9      567   1442.372   -875.3721 |
12. | 26.8      933   1459.023   -526.0231 |
13. | 14.8     1339   1237.009    101.9911 |
14. | 22.3      937   1375.768   -438.7678 |
15. | 56.3     2011   2004.808    6.191886 |
+--------------------------------------+

. *example2.7. Wage & education.
. u wage1.dta, clear

. sum wage

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
wage |        526    5.896103    3.693086        .53      24.98

. qui reg wage educ

. esttab, r2

----------------------------
(1)
wage
----------------------------
educ                0.541***
(10.17)

_cons              -0.905
(-1.32)
----------------------------
N                     526
R-sq                0.165
----------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. display as text "if educ=12.56, then wage_hat = " as result -.90 + .54*12.56
if educ=12.56, then wage_hat = 5.8824

. *example2.8. CEO Salary - R-squared.
. use ceosal1.dta, clear

. qui regress salary roe

. esttab, r2

----------------------------
(1)
salary
----------------------------
roe                 18.50
(1.66)

_cons               963.2***
(4.52)
----------------------------
N                     209
R-sq                0.013
----------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. *example2.9 Voting outcome - R-squared. See example2.5 for details.
. u vote1.dta, clear

. qui reg voteA shareA

. esttab, r2

----------------------------
(1)
voteA
----------------------------
shareA              0.464***
(31.90)

_cons               26.81***
(30.22)
----------------------------
N                     173
R-sq                0.856
----------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. *example2.3 in session2.4 Units of measurement & functional form
. use ceosal1.dta, clear

. g salardol=1000*salary

. eststo: regress salardol roe

Source |       SS           df       MS      Number of obs   =       209
-------------+----------------------------------   F(1, 207)       =      2.77
Model |  5.1664e+12         1  5.1664e+12   Prob > F        =    0.0978
Residual |  3.8657e+14       207  1.8675e+12   R-squared       =    0.0132
Total |  3.9173e+14       208  1.8833e+12   Root MSE        =    1.4e+06

------------------------------------------------------------------------------
salardol |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
roe |   18501.19   11123.25     1.66   0.098    -3428.196    40430.57
_cons |   963191.3   213240.3     4.52   0.000     542790.2     1383592
------------------------------------------------------------------------------
(est1 stored)

. eststo: regress salary roe

Source |       SS           df       MS      Number of obs   =       209
-------------+----------------------------------   F(1, 207)       =      2.77
Model |  5166419.04         1  5166419.04   Prob > F        =    0.0978
Residual |   386566563       207  1867471.32   R-squared       =    0.0132
Total |   391732982       208  1883331.64   Root MSE        =    1366.6

------------------------------------------------------------------------------
salary |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
roe |   18.50119   11.12325     1.66   0.098    -3.428196    40.43057
_cons |   963.1913   213.2403     4.52   0.000     542.7902    1383.592
------------------------------------------------------------------------------
(est2 stored)

. esttab, r2

--------------------------------------------
(1)             (2)
salardol          salary
--------------------------------------------
roe               18501.2           18.50
(1.66)          (1.66)

_cons            963191.3***        963.2***
(4.52)          (4.52)
--------------------------------------------
N                     209             209
R-sq                0.013           0.013
--------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. est clear

. *example2.10 A log wage equation (log-lin model; semi-elasticity )
. u wage1.dta, clear

. sum wage lwage educ

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
wage |        526    5.896103    3.693086        .53      24.98
lwage |        526    1.623268    .5315382  -.6348783   3.218076
educ |        526    12.56274    2.769022          0         18

. reg lwage educ

Source |       SS           df       MS      Number of obs   =       526
-------------+----------------------------------   F(1, 524)       =    119.58
Model |  27.5606288         1  27.5606288   Prob > F        =    0.0000
Residual |  120.769123       524  .230475425   R-squared       =    0.1858
Total |  148.329751       525   .28253286   Root MSE        =    .48008

------------------------------------------------------------------------------
lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
educ |   .0827444   .0075667    10.94   0.000     .0678796    .0976091
_cons |   .5837727   .0973358     6.00   0.000     .3925563    .7749891
------------------------------------------------------------------------------

. esttab, r2

----------------------------
(1)
lwage
----------------------------
educ               0.0827***
(10.94)

_cons               0.584***
(6.00)
----------------------------
N                     526
R-sq                0.186
----------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. *example2.11. Ceo Salary & Fim Sales (log-log model; elasticity)
. use ceosal1.dta, clear

. regress lsalary lsales

Source |       SS           df       MS      Number of obs   =       209
-------------+----------------------------------   F(1, 207)       =     55.30
Model |  14.0661688         1  14.0661688   Prob > F        =    0.0000
Residual |  52.6559944       207  .254376785   R-squared       =    0.2108
Total |  66.7221632       208  .320779631   Root MSE        =    .50436

------------------------------------------------------------------------------
lsalary |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lsales |   .2566717   .0345167     7.44   0.000     .1886224    .3247209
_cons |   4.821997   .2883396    16.72   0.000     4.253538    5.390455
------------------------------------------------------------------------------

. esttab, r2

----------------------------
(1)
lsalary
----------------------------
lsales              0.257***
(7.44)

_cons               4.822***
(16.72)
----------------------------
N                     209
R-sq                0.211
----------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. *example2.12 Student math performance
. u meap93.dta, clear

. reg math10 lnchprg

Source |       SS           df       MS      Number of obs   =       408
-------------+----------------------------------   F(1, 406)       =     83.77
Model |  7665.26597         1  7665.26597   Prob > F        =    0.0000
Residual |  37151.9145       406  91.5071786   R-squared       =    0.1710
Total |  44817.1805       407  110.115923   Root MSE        =    9.5659

------------------------------------------------------------------------------
math10 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
lnchprg |  -.3188643   .0348393    -9.15   0.000    -.3873523   -.2503763
_cons |   32.14271   .9975824    32.22   0.000     30.18164    34.10378
------------------------------------------------------------------------------

. esttab, r2

----------------------------
(1)
math10
----------------------------
lnchprg            -0.319***
(-9.15)

_cons               32.14***
(32.22)
----------------------------
N                     408
R-sq                0.171
----------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

. *example2.13. N/A

. log close
name:  SN
log:  Wooldridge\intro-econx\iexample2.smcl
log type:  smcl
closed on:   5 Jan 2019, 16:59:03
-------------------------------------------------------------------------------------
```