Chapter 02 - The Simple Regression Model#

Home | Python | R

import stata_setup
stata_setup.config("C:/Program Files/Stata18/", "se" ,splash=False)

Example 2.3. CEO Salary & Return on Equity;#

\(salary = \beta_0 + \beta_1 roe + u\)

%%stata
use ceosal1.dta
regress salary roe
. use ceosal1.dta

. 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
-------------+----------------------------------   Adj R-squared   =    0.0084
       Total |   391732982       208  1883331.64   Root MSE        =    1366.6
------------------------------------------------------------------------------
      salary | Coefficient  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
------------------------------------------------------------------------------
. 

Example 2.4#

%%stata
u wage1.dta, clear
sum wage educ
reg wage educ 
. 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
-------------+----------------------------------   Adj R-squared   =    0.1632
       Total |  7160.41429       525  13.6388844   Root MSE        =    3.3784

------------------------------------------------------------------------------
        wage | Coefficient  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
------------------------------------------------------------------------------

. 

Example 2.5#

%%stata
u vote1.dta, clear
reg voteA shareA
. 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
-------------+----------------------------------   Adj R-squared   =    0.8553
       Total |  48457.2486       172  281.728189   Root MSE        =    6.3848
------------------------------------------------------------------------------
       voteA | Coefficient  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
------------------------------------------------------------------------------

. 

Example 2.6#

Table 2.2

%%stata
use ceosal1.dta, clear
regress salary roe
esttab, r2 
predict salaryhat, xb 
predict uhat, residual 
list roe salary salaryhat uhat in 1/15, table separator(15)
. 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
-------------+----------------------------------   Adj R-squared   =    0.0084
       Total |   391732982       208  1883331.64   Root MSE        =    1366.6
------------------------------------------------------------------------------
      salary | Coefficient  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 |
     +--------------------------------------+

. 

Example 2.7 Wage & Education#

%%stata
u wage1.dta, clear
sum wage
qui reg wage educ 
esttab, r2 
display as text "if educ=12.56, then wage_hat = " as result -.90 + .54*12.56
. 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

. 

Example 2.8. CEO Salary - R-squared#

%%stata
use ceosal1.dta, clear
qui regress salary roe
esttab, r2 
. 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

. 

Example 2.9 Voting outcome - R-squared. See ## Example 2.5 for details.#

%%stata
u vote1.dta, clear
qui reg voteA shareA
esttab, r2 
. 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
. 

Example 2.3 in session2.4 Units of measurement & functional form#

%%stata
use ceosal1.dta, clear
g salardol=1000*salary
eststo: regress salardol roe
eststo: regress salary roe 
esttab, r2 
est clear
. 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
-------------+----------------------------------   Adj R-squared   =    0.0084
       Total |  3.9173e+14       208  1.8833e+12   Root MSE        =    1.4e+06
------------------------------------------------------------------------------
    salardol | Coefficient  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
-------------+----------------------------------   Adj R-squared   =    0.0084
       Total |   391732982       208  1883331.64   Root MSE        =    1366.6
------------------------------------------------------------------------------
      salary | Coefficient  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
. 

Example 2.10 A log wage equation (log-lin model; semi-elasticity )#

%%stata
u wage1.dta, clear
sum wage lwage educ
reg lwage educ 
esttab, r2 
. 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
-------------+----------------------------------   Adj R-squared   =    0.1843
       Total |  148.329751       525   .28253286   Root MSE        =    .48008
------------------------------------------------------------------------------
       lwage | Coefficient  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

. 

Example 2.11 Ceo Salary & Fim Sales (log-log model; elasticity)#

%%stata
use ceosal1.dta, clear
regress lsalary lsales 
esttab, r2 
. 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
-------------+----------------------------------   Adj R-squared   =    0.2070
       Total |  66.7221632       208  .320779631   Root MSE        =    .50436
------------------------------------------------------------------------------
     lsalary | Coefficient  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

. 

Example 2.12 Student math performance#

%%stata

u meap93.dta, clear
reg math10 lnchprg
esttab, r2 
. 
. 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
-------------+----------------------------------   Adj R-squared   =    0.1690
       Total |  44817.1805       407  110.115923   Root MSE        =    9.5659
------------------------------------------------------------------------------
      math10 | Coefficient  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

.