﻿ Chapter 4 Single-Equation Linear Model and OLS Estimation

## Chapter 4 Single-Equation Linear Model and OLS Estimation

### Examples

```------------------------------------------------------------------------------------------
name:  SN
log:  myReplications\iiexample4
log type:  smcl
opened on:   5 Jun 2019, 14:06:09
. **********************************************
. * Solomon Negash - Replicating Examples
. * Wooldridge (2010). Economic Analysis of Cross-Section and Panel Data. 2nd ed.
. * STATA Program, version 15.1.

. * Chapter 4  - Single-Equation and OLS Estimation
. * Computer Exercises (Examples)
. **********************************************

. // ﻿Example4.1 Wage equation for married working women
. bcuse mroz, clear  nodesc

. reg lwage exper expersq educ age kidslt6 kidsge6

Source |       SS           df       MS      Number of obs   =       428
-------------+----------------------------------   F(6, 421)       =     13.19
Model |  35.3398149         6  5.88996914   Prob > F        =    0.0000
Residual |  187.987636       421  .446526452   R-squared       =    0.1582
-------------+----------------------------------   Adj R-squared   =    0.1462
Total |  223.327451       427  .523015108   Root MSE        =    .66823

------------------------------------------------------------------------------
lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
exper |    .039819    .013393     2.97   0.003     .0134936    .0661444
expersq |  -.0007812   .0004022    -1.94   0.053    -.0015718    9.37e-06
educ |    .107832   .0144021     7.49   0.000      .079523    .1361409
age |  -.0014653   .0052925    -0.28   0.782    -.0118682    .0089377
kidslt6 |  -.0607106   .0887626    -0.68   0.494    -.2351837    .1137625
kidsge6 |   -.014591   .0278981    -0.52   0.601     -.069428    .0402459
_cons |  -.4209079    .316905    -1.33   0.185    -1.043821    .2020052
------------------------------------------------------------------------------

. test kidsge6 kidslt6 age

( 1)  kidsge6 = 0
( 2)  kidslt6 = 0
( 3)  age = 0

F(  3,   421) =    0.24
Prob > F =    0.8705

. predict u, residual
(325 missing values generated)

. //LM1 page64
. reg lwage exper expersq educ

Source |       SS           df       MS      Number of obs   =       428
-------------+----------------------------------   F(3, 424)       =     26.29
Model |  35.0223023         3  11.6741008   Prob > F        =    0.0000
Residual |  188.305149       424  .444115917   R-squared       =    0.1568
-------------+----------------------------------   Adj R-squared   =    0.1509
Total |  223.327451       427  .523015108   Root MSE        =    .66642

------------------------------------------------------------------------------
lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
exper |   .0415665   .0131752     3.15   0.002     .0156697    .0674633
expersq |  -.0008112   .0003932    -2.06   0.040    -.0015841   -.0000382
educ |   .1074896   .0141465     7.60   0.000     .0796837    .1352956
_cons |  -.5220407   .1986321    -2.63   0.009    -.9124668   -.1316145
------------------------------------------------------------------------------

. predict u_r, residual
(325 missing values generated)

. reg u_r exper expersq educ age kidslt6 kidsge6

Source |       SS           df       MS      Number of obs   =       428
-------------+----------------------------------   F(6, 421)       =      0.12
Model |  .317512527         6  .052918754   Prob > F        =    0.9942
Residual |  187.987638       421  .446526456   R-squared       =    0.0017
-------------+----------------------------------   Adj R-squared   =   -0.0125
Total |  188.305151       427  .440995669   Root MSE        =    .66823

------------------------------------------------------------------------------
u_r |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
exper |  -.0017475    .013393    -0.13   0.896    -.0280729    .0245779
expersq |     .00003   .0004022     0.07   0.941    -.0007606    .0008206
educ |   .0003423   .0144021     0.02   0.981    -.0279666    .0286512
age |  -.0014653   .0052925    -0.28   0.782    -.0118682    .0089377
kidslt6 |  -.0607106   .0887626    -0.68   0.494    -.2351837    .1137625
kidsge6 |   -.014591   .0278981    -0.52   0.601     -.069428    .0402459
_cons |   .1011327    .316905     0.32   0.750    -.5217804    .7240459
------------------------------------------------------------------------------

. display "N*Rsquared =" e(r2)*e(N)
N*Rsquared =.72167628

. di chi2tail(3, e(r2)*e(N))
.86809401

. //LM2 page65 (example4.1 cont'd)
. foreach x of var age kidslt kidsg{
2. reg `x' exper* edu
3. predict r_`x', residual
4. gen ures`x'= u_r*r_`x'
5. }

Source |       SS           df       MS      Number of obs   =       753
-------------+----------------------------------   F(3, 749)       =     48.91
Model |  8027.34887         3  2675.78296   Prob > F        =    0.0000
Residual |  40977.8224       749  54.7100433   R-squared       =    0.1638
-------------+----------------------------------   Adj R-squared   =    0.1605
Total |  49005.1713       752  65.1664512   Root MSE        =    7.3966

------------------------------------------------------------------------------
age |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
exper |  -.1424069    .096921    -1.47   0.142     -.332676    .0478621
expersq |    .016711   .0031269     5.34   0.000     .0105724    .0228496
educ |  -.4363879   .1192663    -3.66   0.000     -.670524   -.2022518
_cons |   46.43838   1.521431    30.52   0.000      43.4516    49.42515
------------------------------------------------------------------------------
(325 missing values generated)

Source |       SS           df       MS      Number of obs   =       753
-------------+----------------------------------   F(3, 749)       =     13.85
Model |  10.8498698         3  3.61662327   Prob > F        =    0.0000
Residual |  195.599001       749  .261146864   R-squared       =    0.0526
-------------+----------------------------------   Adj R-squared   =    0.0488
Total |  206.448871       752  .274533073   Root MSE        =    .51103

------------------------------------------------------------------------------
kidslt6 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
exper |  -.0145597   .0066962    -2.17   0.030    -.0277052   -.0014142
expersq |   .0000493    .000216     0.23   0.819    -.0003748    .0004734
educ |   .0282583     .00824     3.43   0.001     .0120821    .0444345
_cons |   .0365076   .1051141     0.35   0.728    -.1698457    .2428609
------------------------------------------------------------------------------
(325 missing values generated)

Source |       SS           df       MS      Number of obs   =       753
-------------+----------------------------------   F(3, 749)       =     26.14
Model |  124.144723         3  41.3815742   Prob > F        =    0.0000
Residual |  1185.88981       749  1.58329747   R-squared       =    0.0948
-------------+----------------------------------   Adj R-squared   =    0.0911
Total |  1310.03453       752  1.74206719   Root MSE        =    1.2583

------------------------------------------------------------------------------
kidsge6 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
exper |  -.0221468   .0164879    -1.34   0.180    -.0545148    .0102212
expersq |  -.0009084   .0005319    -1.71   0.088    -.0019526    .0001359
educ |  -.0264995   .0202892    -1.31   0.192      -.06633     .013331
_cons |    2.07601   .2588212     8.02   0.000     1.567909    2.584111
------------------------------------------------------------------------------
(325 missing values generated)

. gen one=1

. reg one ures*, noc

Source |       SS           df       MS      Number of obs   =       428
-------------+----------------------------------   F(3, 425)       =      0.17
Model |  .521512118         3  .173837373   Prob > F        =    0.9147
Residual |  427.478488       425  1.00583174   R-squared       =    0.0012
-------------+----------------------------------   Adj R-squared   =   -0.0058
Total |         428       428           1   Root MSE        =    1.0029

------------------------------------------------------------------------------
one |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
uresage |  -.0028426   .0109138    -0.26   0.795    -.0242943     .018609
ureskidslt6 |  -.0940857   .1710924    -0.55   0.583    -.4303783    .2422068
ureskidsge6 |  -.0266196    .059492    -0.45   0.655    -.1435548    .0903155
------------------------------------------------------------------------------

. display "LM= N-SSRo =" e(N)-e(rss)
LM= N-SSRo =.52151212

. di chi2tail(3, e(N)-e(rss))
.9141405

. //Example4.2 NA

. //Example4.3 Using IQ as a Proxy for Ability
. bcuse nls80, clear  nodesc

. reg lwage exper tenure married south urban black educ

Source |       SS           df       MS      Number of obs   =       935
-------------+----------------------------------   F(7, 927)       =     44.75
Model |  41.8377619         7  5.97682312   Prob > F        =    0.0000
Residual |  123.818521       927  .133569063   R-squared       =    0.2526
-------------+----------------------------------   Adj R-squared   =    0.2469
Total |  165.656283       934  .177362188   Root MSE        =    .36547

------------------------------------------------------------------------------
lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
exper |    .014043   .0031852     4.41   0.000      .007792     .020294
tenure |   .0117473    .002453     4.79   0.000     .0069333    .0165613
married |   .1994171   .0390502     5.11   0.000     .1227801     .276054
south |  -.0909036   .0262485    -3.46   0.001     -.142417   -.0393903
urban |   .1839121   .0269583     6.82   0.000     .1310056    .2368185
black |  -.1883499   .0376666    -5.00   0.000    -.2622717   -.1144281
educ |   .0654307   .0062504    10.47   0.000     .0531642    .0776973
_cons |   5.395497    .113225    47.65   0.000      5.17329    5.617704
------------------------------------------------------------------------------

. reg lwage exper tenure married south urban black educ iq

Source |       SS           df       MS      Number of obs   =       935
-------------+----------------------------------   F(8, 926)       =     41.27
Model |  43.5360162         8  5.44200202   Prob > F        =    0.0000
Residual |  122.120267       926  .131879338   R-squared       =    0.2628
-------------+----------------------------------   Adj R-squared   =    0.2564
Total |  165.656283       934  .177362188   Root MSE        =    .36315

------------------------------------------------------------------------------
lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
exper |   .0141458   .0031651     4.47   0.000     .0079342    .0203575
tenure |   .0113951   .0024394     4.67   0.000     .0066077    .0161825
married |   .1997644   .0388025     5.15   0.000     .1236134    .2759154
south |  -.0801695   .0262529    -3.05   0.002    -.1316916   -.0286473
urban |   .1819463   .0267929     6.79   0.000     .1293645    .2345281
black |  -.1431253   .0394925    -3.62   0.000    -.2206304   -.0656202
educ |   .0544106   .0069285     7.85   0.000     .0408133     .068008
iq |   .0035591   .0009918     3.59   0.000     .0016127    .0055056
_cons |   5.176439   .1280006    40.44   0.000     4.925234    5.427644
------------------------------------------------------------------------------

. //Example4.4 Effects of Job Training Grants on Worker Productivity *(JTRAIN.RAW)
. use jtrain1, clear

. regress lscrap grant if year==1988

Source |       SS           df       MS      Number of obs   =        54
-------------+----------------------------------   F(1, 52)        =      0.02
Model |  .039451758         1  .039451758   Prob > F        =    0.8895
Residual |  105.323208        52  2.02544631   R-squared       =    0.0004
-------------+----------------------------------   Adj R-squared   =   -0.0188
Total |   105.36266        53  1.98797472   Root MSE        =    1.4232

------------------------------------------------------------------------------
lscrap |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
grant |   .0566004   .4055519     0.14   0.890     -.757199    .8703998
_cons |    .408526   .2405616     1.70   0.095    -.0741962    .8912482
------------------------------------------------------------------------------

. regress lscrap grant lscrap_1 if year==1988

Source |       SS           df       MS      Number of obs   =        54
-------------+----------------------------------   F(2, 51)        =    174.94
Model |  91.9584791         2  45.9792396   Prob > F        =    0.0000
Residual |  13.4041809        51  .262827077   R-squared       =    0.8728
-------------+----------------------------------   Adj R-squared   =    0.8678
Total |   105.36266        53  1.98797472   Root MSE        =    .51267

------------------------------------------------------------------------------
lscrap |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
grant |  -.2539697   .1470311    -1.73   0.090    -.5491469    .0412076
lscrap_1 |   .8311606   .0444444    18.70   0.000     .7419347    .9203865
_cons |    .021237   .0890967     0.24   0.813    -.1576321    .2001061
------------------------------------------------------------------------------

. //Example4.5
. bcuse nls80, clear  nodesc

. reg lwage exper tenure married south urban black educ iq c.educ#c.iq

Source |       SS           df       MS      Number of obs   =       935
-------------+----------------------------------   F(9, 925)       =     36.76
Model |  43.6401231         9  4.84890256   Prob > F        =    0.0000
Residual |   122.01616       925  .131909362   R-squared       =    0.2634
-------------+----------------------------------   Adj R-squared   =    0.2563
Total |  165.656283       934  .177362188   Root MSE        =    .36319

------------------------------------------------------------------------------
lwage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
exper |   .0139072   .0031768     4.38   0.000     .0076725    .0201418
tenure |   .0113929   .0024397     4.67   0.000     .0066049    .0161808
married |   .2008658   .0388267     5.17   0.000     .1246671    .2770644
south |  -.0802354    .026256    -3.06   0.002    -.1317637   -.0287072
urban |   .1835758   .0268586     6.83   0.000     .1308649    .2362867
black |  -.1466989   .0397013    -3.70   0.000    -.2246139   -.0687839
educ |   .0184559   .0410608     0.45   0.653    -.0621272    .0990391
iq |  -.0009418   .0051625    -0.18   0.855    -.0110734    .0091899
|
c.educ#c.iq |   .0003399   .0003826     0.89   0.375    -.0004109    .0010907
|
_cons |   5.648248   .5462963    10.34   0.000     4.576124    6.720372
------------------------------------------------------------------------------

. test iq c.educ#c.iq

( 1)  iq = 0
( 2)  c.educ#c.iq = 0

F(  2,   925) =    6.83
Prob > F =    0.0011

. //discripancy in coef & se of education

. //Example4.6 NA
. //Example4.7 NA
. //Example4.8 NA

. log close
name:  SN
log:  myReplications\iiexample4
log type:  smcl
closed on:   5 Jun 2019, 14:06:12
------------------------------------------------------------------------------------------
```