Verbeek 5ed. Chapter 2 - Linear Regression
Examples
----------------------------------------------------------------------------------------------------
name: SN
log: \5iexample2_s.smcl
log type: smcl
opened on: 5 Jun 2020, 11:33:46
**********************************************
* Solomon Negash - Examples
* Verbeek(2017). A Giude To Modern Econometrics. 5ed.
* STATA Program, version 16.1.
* Chapter 2 - Introduction to Linear Regression
******************** **** *********************
*Figure 2.1 Simple linear regression: fitted line and observation points, hypothetical data
clear
set seed 123
set obs 100
g x = uniform()
g eps = runiform()
g y = x + .5 + eps
twoway (scatter y x) (lfit y x), title("Figure 2.1 Simple linear regression: fitted line and
observation points", size(*.8)) legend(off)
*Table 2.1 Individual Wages
use "Data/Wages1.dta", clear
reg wage male
Source | SS df MS Number of obs = 3,294
-------------+---------------------------------- F(1, 3292) = 107.93
Model | 1117.26971 1 1117.26971 Prob > F = 0.0000
Residual | 34076.9173 3,292 10.351433 R-squared = 0.0317
-------------+---------------------------------- Adj R-squared = 0.0315
Total | 35194.187 3,293 10.6875758 Root MSE = 3.2174
------------------------------------------------------------------------------
wage | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
male | 1.166097 .1122422 10.39 0.000 .9460258 1.386169
_cons | 5.146924 .0812248 63.37 0.000 4.987668 5.30618
------------------------------------------------------------------------------
* Table 2.2
reg wage male school exper
Source | SS df MS Number of obs = 3,294
-------------+---------------------------------- F(3, 3290) = 167.63
Model | 4666.31659 3 1555.43886 Prob > F = 0.0000
Residual | 30527.8705 3,290 9.27898798 R-squared = 0.1326
-------------+---------------------------------- Adj R-squared = 0.1318
Total | 35194.187 3,293 10.6875758 Root MSE = 3.0461
------------------------------------------------------------------------------
wage | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
male | 1.344369 .1076759 12.49 0.000 1.13325 1.555487
school | .6387977 .0327958 19.48 0.000 .5744954 .7031
exper | .1248255 .0237628 5.25 0.000 .0782342 .1714167
_cons | -3.380018 .4649765 -7.27 0.000 -4.291691 -2.468346
------------------------------------------------------------------------------
test school=exper=0
( 1) school - exper = 0
( 2) school = 0
F( 2, 3290) = 191.24
Prob > F = 0.0000
*Table 2.3 CAPM regression (without intercept)
u "Data/Capm5.dta", clear
reg foodrf rmrf, nocons
Source | SS df MS Number of obs = 660
-------------+---------------------------------- F(1, 659) = 948.26
Model | 7500.0027 1 7500.0027 Prob > F = 0.0000
Residual | 5212.1658 659 7.90920454 R-squared = 0.5900
-------------+---------------------------------- Adj R-squared = 0.5894
Total | 12712.1685 660 19.2608614 Root MSE = 2.8123
------------------------------------------------------------------------------
foodrf | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rmrf | .7548109 .0245117 30.79 0.000 .7066804 .8029414
------------------------------------------------------------------------------
reg durblrf rmrf, nocons
Source | SS df MS Number of obs = 660
-------------+---------------------------------- F(1, 659) = 1584.65
Model | 14954.0435 1 14954.0435 Prob > F = 0.0000
Residual | 6218.8779 659 9.43684052 R-squared = 0.7063
-------------+---------------------------------- Adj R-squared = 0.7058
Total | 21172.9214 660 32.0801839 Root MSE = 3.0719
------------------------------------------------------------------------------
durblrf | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rmrf | 1.065827 .0267745 39.81 0.000 1.013254 1.118401
------------------------------------------------------------------------------
reg cnstrrf rmrf, nocons
Source | SS df MS Number of obs = 660
-------------+---------------------------------- F(1, 659) = 2262.26
Model | 18134.9986 1 18134.9986 Prob > F = 0.0000
Residual | 5282.75449 659 8.01631941 R-squared = 0.7744
-------------+---------------------------------- Adj R-squared = 0.7741
Total | 23417.7531 660 35.4814441 Root MSE = 2.8313
------------------------------------------------------------------------------
cnstrrf | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rmrf | 1.173725 .0246771 47.56 0.000 1.125269 1.22218
------------------------------------------------------------------------------
*Table 2.4 CAPM regression (with intercept)
reg foodrf rmrf
Source | SS df MS Number of obs = 660
-------------+---------------------------------- F(1, 658) = 926.56
Model | 7245.32113 1 7245.32113 Prob > F = 0.0000
Residual | 5145.27877 658 7.8195726 R-squared = 0.5847
-------------+---------------------------------- Adj R-squared = 0.5841
Total | 12390.5999 659 18.8021243 Root MSE = 2.7963
------------------------------------------------------------------------------
foodrf | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rmrf | .746687 .0245302 30.44 0.000 .6985201 .7948539
_cons | .3204065 .1095524 2.92 0.004 .1052921 .5355209
------------------------------------------------------------------------------
reg durblrf rmrf
Source | SS df MS Number of obs = 660
-------------+---------------------------------- F(1, 658) = 1573.23
Model | 14846.5253 1 14846.5253 Prob > F = 0.0000
Residual | 6209.53493 658 9.43698318 R-squared = 0.7051
-------------+---------------------------------- Adj R-squared = 0.7046
Total | 21056.0602 659 31.9515329 Root MSE = 3.072
------------------------------------------------------------------------------
durblrf | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rmrf | 1.068863 .026948 39.66 0.000 1.015949 1.121778
_cons | -.1197493 .1203502 -1.00 0.320 -.3560661 .1165675
------------------------------------------------------------------------------
reg cnstrrf rmrf
Source | SS df MS Number of obs = 660
-------------+---------------------------------- F(1, 658) = 2232.68
Model | 17923.4422 1 17923.4422 Prob > F = 0.0000
Residual | 5282.27559 658 8.02777446 R-squared = 0.7724
-------------+---------------------------------- Adj R-squared = 0.7720
Total | 23205.7178 659 35.2135323 Root MSE = 2.8333
------------------------------------------------------------------------------
cnstrrf | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rmrf | 1.174412 .0248546 47.25 0.000 1.125608 1.223216
_cons | -.0271114 .1110013 -0.24 0.807 -.2450708 .190848
------------------------------------------------------------------------------
*Table 2.5 CAPM regressions (with intercept and January dummy)
reg foodrf rmrf jan
Source | SS df MS Number of obs = 660
-------------+---------------------------------- F(2, 657) = 469.94
Model | 7292.79687 2 3646.39843 Prob > F = 0.0000
Residual | 5097.80303 657 7.75921314 R-squared = 0.5886
-------------+---------------------------------- Adj R-squared = 0.5873
Total | 12390.5999 659 18.8021243 Root MSE = 2.7855
------------------------------------------------------------------------------
foodrf | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rmrf | .7489516 .0244525 30.63 0.000 .7009372 .7969661
jan | -.9710764 .3925784 -2.47 0.014 -1.741936 -.2002168
_cons | .4001843 .1137949 3.52 0.000 .1767388 .6236297
------------------------------------------------------------------------------
reg durblrf rmrf jan
Source | SS df MS Number of obs = 660
-------------+---------------------------------- F(2, 657) = 785.48
Model | 14846.8533 2 7423.42665 Prob > F = 0.0000
Residual | 6209.2069 657 9.45084764 R-squared = 0.7051
-------------+---------------------------------- Adj R-squared = 0.7042
Total | 21056.0602 659 31.9515329 Root MSE = 3.0742
------------------------------------------------------------------------------
durblrf | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rmrf | 1.068675 .0269867 39.60 0.000 1.015685 1.121666
jan | .0807189 .4332643 0.19 0.852 -.7700308 .9314686
_cons | -.1263806 .1255883 -1.01 0.315 -.3729835 .1202222
------------------------------------------------------------------------------
reg cnstrrf rmrf jan
Source | SS df MS Number of obs = 660
-------------+---------------------------------- F(2, 657) = 1119.70
Model | 17941.8761 2 8970.93804 Prob > F = 0.0000
Residual | 5263.84168 657 8.01193559 R-squared = 0.7732
-------------+---------------------------------- Adj R-squared = 0.7725
Total | 23205.7178 659 35.2135323 Root MSE = 2.8305
------------------------------------------------------------------------------
cnstrrf | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rmrf | 1.173001 .0248475 47.21 0.000 1.124211 1.221791
jan | .6050988 .3989204 1.52 0.130 -.1782139 1.388412
_cons | -.0768226 .1156332 -0.66 0.507 -.3038778 .1502325
------------------------------------------------------------------------------
*Table 2.6 CAPM regression (with intercept) Madoff's returns
use "Data/madoff.dta", clear
reg fslrf rmrf
Source | SS df MS Number of obs = 215
-------------+---------------------------------- F(1, 213) = 14.54
Model | 6.44404169 1 6.44404169 Prob > F = 0.0002
Residual | 94.4286913 213 .443327189 R-squared = 0.0639
-------------+---------------------------------- Adj R-squared = 0.0595
Total | 100.872733 214 .471367911 Root MSE = .66583
------------------------------------------------------------------------------
fslrf | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
rmrf | .0408859 .010724 3.81 0.000 .0197471 .0620246
_cons | .5049538 .0456993 11.05 0.000 .414873 .5950347
------------------------------------------------------------------------------
*Table 2.7 Alternative specifications with dummy variables
u "Data/Wages1.dta", clear
g female = 0
replace female=1 if male==0
(1,569 real changes made)
reg wage male
Source | SS df MS Number of obs = 3,294
-------------+---------------------------------- F(1, 3292) = 107.93
Model | 1117.26971 1 1117.26971 Prob > F = 0.0000
Residual | 34076.9173 3,292 10.351433 R-squared = 0.0317
-------------+---------------------------------- Adj R-squared = 0.0315
Total | 35194.187 3,293 10.6875758 Root MSE = 3.2174
------------------------------------------------------------------------------
wage | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
male | 1.166097 .1122422 10.39 0.000 .9460258 1.386169
_cons | 5.146924 .0812248 63.37 0.000 4.987668 5.30618
------------------------------------------------------------------------------
reg wage female
Source | SS df MS Number of obs = 3,294
-------------+---------------------------------- F(1, 3292) = 107.93
Model | 1117.26971 1 1117.26971 Prob > F = 0.0000
Residual | 34076.9173 3,292 10.351433 R-squared = 0.0317
-------------+---------------------------------- Adj R-squared = 0.0315
Total | 35194.187 3,293 10.6875758 Root MSE = 3.2174
------------------------------------------------------------------------------
wage | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
female | -1.166097 .1122422 -10.39 0.000 -1.386169 -.9460258
_cons | 6.313021 .077465 81.50 0.000 6.161137 6.464906
------------------------------------------------------------------------------
reg wage male female, nocons
Source | SS df MS Number of obs = 3,294
-------------+---------------------------------- F(2, 3292) = 5328.38
Model | 110312.663 2 55156.3313 Prob > F = 0.0000
Residual | 34076.9173 3,292 10.351433 R-squared = 0.7640
-------------+---------------------------------- Adj R-squared = 0.7638
Total | 144389.58 3,294 43.8341166 Root MSE = 3.2174
------------------------------------------------------------------------------
wage | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
male | 6.313021 .077465 81.50 0.000 6.161137 6.464906
female | 5.146924 .0812248 63.37 0.000 4.987668 5.30618
------------------------------------------------------------------------------
log close
name: SN
log: \5iexample2_s.smcl
log type: smcl
closed on: 5 Jun 2020, 11:33:47
----------------------------------------------------------------------------------------------------