CE1 Sol
CE1 Sol
. do ce1
1. -
2.
. use caschool.dta, clear
3.
. * list testscr str [output suppressed]
4.
. summarize testscr str
5.
. summarize testscr str, detail
testscr
-------------------------------------------------------------
Percentiles Smallest
1% 612.65 605.55
5% 623.15 606.75
10% 630.375 609 Obs 420
25% 640 612.5 Sum of Wgt. 420
str
-------------------------------------------------------------
Percentiles Smallest
1% 15.13898 14
5% 16.41658 14.20176
10% 17.34573 14.54214 Obs 420
25% 18.58179 14.70588 Sum of Wgt. 420
6.
. correlate testscr str
(obs=420)
| testscr str
-------------+------------------
testscr | 1.0000
str | -0.2264 1.0000
7.
. scatter testscr str
8.
. twoway (lfit testscr str) (scatter testscr str)
9.
. regress testscr str
------------------------------------------------------------------------------
testscr | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
str | -2.279808 .4798256 -4.75 0.000 -3.22298 -1.336637
_cons | 698.933 9.467491 73.82 0.000 680.3231 717.5428
------------------------------------------------------------------------------
10.
. regress testscr str, robust
------------------------------------------------------------------------------
| Robust
testscr | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
str | -2.279808 .5194892 -4.39 0.000 -3.300945 -1.258671
_cons | 698.933 10.36436 67.44 0.000 678.5602 719.3057
------------------------------------------------------------------------------
11.
. clear
12.
. set seed [use your student number]
BE AWARE: From here the output given will be somewhat different from the output
you get. The samples you draw below, are based on the seed you chose. The output
below is based on another seed and hence the output is somewhat different.
13.
. set obs 1000
obs was 0, now 1000
14.
. generate x = 10+2*rnormal()
. generate u = rnormal()
. generate y = 10+x+u
. * list y x
. summarize y x
15.
. regress y x
------------------------------------------------------------------------------
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
x | .9945438 .0158696 62.67 0.000 .9634022 1.025685
_cons | 9.938967 .1611753 61.67 0.000 9.622686 10.25525
------------------------------------------------------------------------------
From the definition of y (part 14) we see that β0 =10 and β1= 1. Every student has drawn a different sample
from the population regression model, hence numerical values will be different for the OLS estimators and,
hence, the estimation errors. For the seed used here (see 12) the estimation errors are 9.939 - 10 = -0.061 for
β0 and 0.995 - 1 = -0.005 for β1.
16.
. generate xx = 10+2*rnormal()
. generate uu = rnormal()
. generate yy = 10+xx+uu
. regress yy xx
The estimation errors are now 9.916 - 10 = -0.084 for β0 and 1.013 - 1 = 0.013 for β1. These are different from
the ones in 15 because we have drawn new data. New x's or new u's will yield new y's and if we do regression
the estimation results will deviate.
17.
If you would repeat this experiment many times you would get many different estimates of the parameters β0
and β1. For each new draw of x and u a new set of estimates. The average of all these different estimates will
be equal to the actual values 10 and 1 used to create y and this reflects essentially the unbiasedness property.
Also the average estimation errors will be zero. Resampling data and, hence, OLS estimates you get on average
the true values.
18.
In the case of artificial data (Monte Carlo) we have full control on the model and the data. So, we actually
know the model and e.g. the real parameter values. As a result we can calculate estimation errors. For real data,
this is impossible since we do not know the true model and the true values of the parameters in particular. A
Monte-Carlo analysis is only used to evaluate the quality of an estimation method. It has no real empirical
content.
19.
The relevant output is in part 15. If you perform a test or have to evaluate you always have to go through the
steps you learned in your statistics class. Be aware that we require you to do so also in examinations.
(1) 𝐻𝐻0 : β1 = 0.95 vs 𝐻𝐻1 : β1 ≠ 0.95
(2) 𝑡𝑡 = (1.025 − 0.95)/0.016 = 4.659. Under the null and approximately/asymptotically t is N(0,1)
distributed.
(3) Critical value at 5%: 1.96.
(4) Conclusion: reject the null since |t| > critical value.
No error is made, because you reject a false hypothesis (the true value of β1 is 1).
20.
The relevant output is in part 15.
(1) 𝐻𝐻0 : 𝛽𝛽1 = 1 vs 𝐻𝐻1 : 𝛽𝛽1 ≠ 1
(2) 𝑡𝑡 = (1.025 − 1)/0.016 = 1.563. Under the null and approximately/asymptotically t is N(0,1)
distributed.
(3) Critical value at 5%: 1.96.
(4) Conclusion: do not reject the null since |t| < critical value.
No error is made, because you do not reject a correct hypothesis (the true value of β1 is 1). About 5% of the
students will make a Type 1 error (rejecting H0 while it is correct).
21.
. regress y x in 1/10
------------------------------------------------------------------------------
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
x | 1.163825 .1839276 6.33 0.000 .7396873 1.587963
_cons | 8.523538 1.854429 4.60 0.002 4.247217 12.79986
------------------------------------------------------------------------------
The estimation errors are now 8.524 - 10 = -1.476 for β0 and 1.164 - 1 = 0.164 for β1. Since in the case of using
10 observations instead of 1000, the precision of an estimator will be less, the estimation errors are often larger
for n = 10 than for n = 1000. However, now and then, they can be smaller because of coincidence because the
estimate depends on the sample which is randomly drawn.
22.
More observations imply less uncertainty about estimates, hence lower standard errors. The latter play a
prominent role in the calculation of the confidence intervals. Hence, more observations imply narrower
confidence intervals. To understand this better look at the variance of the regression coefficients as given in
Appendix 5.1 of S&W.
23.
. generate w=2*x
. regress y w
------------------------------------------------------------------------------
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
w | .4972719 .0079348 62.67 0.000 .4817011 .5128426
_cons | 9.938967 .1611753 61.67 0.000 9.622686 10.25525
------------------------------------------------------------------------------
We multiply the regressor x by 2, i.e. w = 2x. Comparing the new population regression model:
𝑦𝑦𝑖𝑖 = 𝛽𝛽0* + 𝛽𝛽1* 𝑤𝑤𝑖𝑖 + 𝑢𝑢𝑖𝑖* with the original one 𝑦𝑦𝑖𝑖 = 𝛽𝛽0 + 𝛽𝛽1 𝑥𝑥𝑖𝑖 + 𝑢𝑢𝑖𝑖 it is easily seen that we should have
𝛽𝛽*0 = 𝛽𝛽0 and 𝛽𝛽*1 = 𝛽𝛽1⁄2.Hence, we expect that the regression coefficient of 𝛽𝛽1to change (and its
standard error), but all other regression outcomes (t values, R2, etc.) should stay unchanged. Try as an
exercise to derive all this analytically (hint: use the variance-covariance rules stated in Chapter 3 of
Stock & Watson).
For example,
� ∑𝑛𝑛𝑖𝑖=1(𝑤𝑤𝑖𝑖 − 𝑤𝑤̄ ) (𝑦𝑦𝑖𝑖 − 𝑦𝑦̄ ) ∑𝑛𝑛𝑖𝑖=1(2x𝑖𝑖 − 2𝑥𝑥̄ ) (𝑦𝑦𝑖𝑖 − 𝑦𝑦̄ )
*
𝛽𝛽1 = = �1
= 0.5𝛽𝛽
∑𝑛𝑛𝑖𝑖=1 (𝑤𝑤𝑖𝑖 − 𝑤𝑤̄ )2 ∑𝑛𝑛𝑖𝑖=1 (2x𝑖𝑖 − 2𝑥𝑥̄ )2
24.
. correlate y x w resid, covariance
(obs=1000)
| y x w resid
-------------+------------------------------------
y | 5.11047
x | 4.09735 4.11983
w | 8.1947 8.23966 16.4793
resid | 1.03547 2.2e-09 4.4e-09 1.03547
. correlate y x w resid
(obs=1000)
| y x w resid
-------------+------------------------------------
y | 1.0000
x | 0.8930 1.0000
w | 0.8930 1.0000 1.0000
resid | 0.4501 0.0000 0.0000 1.0000
1
We have 𝑣𝑣𝑣𝑣𝑣𝑣(𝑤𝑤) = 𝑣𝑣𝑣𝑣𝑣𝑣(2x) = 4var(𝑥𝑥).Note that 𝑢𝑢 �̄ = 𝑛𝑛 ∑𝑛𝑛𝑖𝑖=1 𝑢𝑢�𝚤𝚤 = 0 (results from the OLS normal
equation (= first order conditions of minimizing the SSR w.r.t. the constant), we also have
𝑛𝑛 𝑛𝑛
1 1 1
𝑣𝑣𝑣𝑣𝑣𝑣(𝑢𝑢�) = �(𝑢𝑢�𝚤𝚤 − 𝑢𝑢�̄)2 = �(𝑢𝑢�𝚤𝚤 )2 = 𝑆𝑆𝑆𝑆𝑆𝑆
𝑛𝑛 − 1 𝑛𝑛 − 1 𝑛𝑛 − 1
𝑖𝑖=1 𝑖𝑖=1
25.
All this can be derived analytically using the variance-covariance rules stated in Chapter 3 of Stock
& Watson, but applied to this specific sample. The OLS normal equations (= first order condition of
minimizing the SSR) for the simple regression model are ∑𝑛𝑛𝑖𝑖=1 𝑢𝑢�𝚤𝚤 = 0 and ∑𝑛𝑛𝑖𝑖=1 𝑢𝑢�𝚤𝚤 𝑥𝑥𝑖𝑖 = 0. From these
we can derive
𝑛𝑛 𝑛𝑛
1 1 1 1
𝑐𝑐𝑐𝑐𝑐𝑐(𝑥𝑥, 𝑢𝑢�) = �(𝑥𝑥𝑖𝑖 − 𝑥𝑥̄ ) (𝑢𝑢�𝚤𝚤 − 𝑢𝑢�̄) = �(𝑥𝑥𝑖𝑖 − 𝑥𝑥̄ ) (𝑢𝑢�𝚤𝚤 ) = ∑𝑥𝑥𝑖𝑖 𝑢𝑢�𝚤𝚤 − 𝑥𝑥̄ ∑𝑢𝑢�𝚤𝚤
𝑛𝑛 − 1 𝑛𝑛 − 1 𝑛𝑛 − 1 𝑛𝑛 − 1
𝑖𝑖=1 𝑖𝑖=1
= 0.
Of course, all variances and covariances used here are sample variances and covariances.