___  ____  ____  ____  ____ tm
 /__    /   ____/   /   ____/
___/   /   /___/   /   /___/    5.0   Copyright 1984-1997
  Statistics/Data Analysis            Stata Corporation

. * program to illustrate effects of ill-conditioning on OLS
. * x1 is a trend; x2 is a trend + eps, where eps(0,sigma^2).
. * Note the regression results as sigma -> 0.
. *
. * CFB ec761 Fall 1997
. *
. set obs 100
obs was 0, now 100

. gen x1=_n/100.0

. program define conditio
  1. local i = 0
  2. while `i'<`1' {
  3. scalar sigma=10.0^-`i'
  4. dis " "
  5. dis "*** sigma = " sigma " ***"
  6. gen eps=sigma*invnorm(uniform())
  7. gen eps2=invnorm(uniform())
  8. gen x2=x1+eps
  9. gen y=2.0+10.0*x1+10.0*x2+eps2
 10. correlate x1 x2
 11. regress y x1 x2
 12. local i=`i'+1
 13. drop eps
 14. drop eps2
 15. drop x2
 16. drop y
 17. }
 18. end

. conditio 5
 
*** sigma = 1 ***
(obs=100)

        |       x1       x2
--------+------------------
      x1|   1.0000
      x2|   0.3241   1.0000


  Source |       SS       df       MS                  Number of obs =     100
---------+------------------------------               F(  2,    97) = 5784.99
   Model |  11960.0944     2  5980.04718               Prob > F      =  0.0000
Residual |  100.270545    97  1.03371696               R-squared     =  0.9917
---------+------------------------------               Adj R-squared =  0.9915
   Total |  12060.3649    99  121.821868               Root MSE      =  1.0167

------------------------------------------------------------------------------
       y |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
      x1 |   10.12255   .3723146     27.188   0.000       9.383608    10.86149
      x2 |   10.01934   .1117699     89.643   0.000       9.797503    10.24117
   _cons |   1.921866   .2052406      9.364   0.000        1.51452    2.329212
------------------------------------------------------------------------------
 
*** sigma = .1 ***
(obs=100)

        |       x1       x2
--------+------------------
      x1|   1.0000
      x2|   0.9467   1.0000


  Source |       SS       df       MS                  Number of obs =     100
---------+------------------------------               F(  2,    97) = 1956.23
   Model |  3426.83467     2  1713.41733               Prob > F      =  0.0000
Residual |  84.9599842    97  .875876126               R-squared     =  0.9758
---------+------------------------------               Adj R-squared =  0.9753
   Total |  3511.79465    99  35.4726732               Root MSE      =  .93588

------------------------------------------------------------------------------
       y |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
      x1 |   10.39441   1.006406     10.328   0.000       8.396975    12.39185
      x2 |   9.781533   .9688272     10.096   0.000       7.858679    11.70439
   _cons |   1.864677   .1889523      9.869   0.000       1.489659    2.239695
------------------------------------------------------------------------------
 
*** sigma = .01 ***
(obs=100)

        |       x1       x2
--------+------------------
      x1|   1.0000
      x2|   0.9993   1.0000


  Source |       SS       df       MS                  Number of obs =     100
---------+------------------------------               F(  2,    97) = 1504.37
   Model |  3507.75671     2  1753.87836               Prob > F      =  0.0000
Residual |  113.087978    97  1.16585544               R-squared     =  0.9688
---------+------------------------------               Adj R-squared =  0.9681
   Total |  3620.84469    99  36.5741888               Root MSE      =  1.0797

------------------------------------------------------------------------------
       y |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
      x1 |   -2.91624   10.26391     -0.284   0.777      -23.28726    17.45478
      x2 |   23.46838      10.28      2.283   0.025       3.065425    43.87133
   _cons |   1.669024   .2183565      7.644   0.000       1.235646    2.102401
------------------------------------------------------------------------------
 
*** sigma = .001 ***
(obs=100)

        |       x1       x2
--------+------------------
      x1|   1.0000
      x2|   1.0000   1.0000


  Source |       SS       df       MS                  Number of obs =     100
---------+------------------------------               F(  2,    97) = 2002.94
   Model |  3392.66099     2  1696.33049               Prob > F      =  0.0000
Residual |  82.1511384    97  .846918953               R-squared     =  0.9764
---------+------------------------------               Adj R-squared =  0.9759
   Total |  3474.81213    99  35.0991124               Root MSE      =  .92028

------------------------------------------------------------------------------
       y |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
      x1 |   196.9501   89.33464      2.205   0.030       19.64554    374.2546
      x2 |  -176.8903   89.38894     -1.979   0.051      -354.3026    .5219925
   _cons |   1.907223   .1871233     10.192   0.000       1.535835    2.278611
------------------------------------------------------------------------------
 
*** sigma = .0001 ***
(obs=100)

        |       x1       x2
--------+------------------
      x1|   1.0000
      x2|   1.0000   1.0000


  Source |       SS       df       MS                  Number of obs =     100
---------+------------------------------               F(  2,    97) = 1496.37
   Model |  3420.77919     2   1710.3896               Prob > F      =  0.0000
Residual |   110.87328    97   1.1430235               R-squared     =  0.9686
---------+------------------------------               Adj R-squared =  0.9680
   Total |  3531.65247    99  35.6732573               Root MSE      =  1.0691

------------------------------------------------------------------------------
       y |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
      x1 |  -54.96045   1065.972     -0.052   0.959      -2170.619    2060.698
      x2 |   75.22354   1065.992      0.071   0.944      -2040.476    2190.923
   _cons |   1.839889   .2174912      8.460   0.000       1.408229    2.271548
------------------------------------------------------------------------------

. exit,clear