Stata Textbook Examples
Regression Analysis by Example, Third Edition
Chapter 11: Variable Selection Procedures

Table 11.1, page 295.
use http://www.ats.ucla.edu/stat/stata/examples/chp/p189, clear
corr x1-x6

(obs=30)
         |       x1       x2       x3       x4       x5       x6
---------+------------------------------------------------------
      x1 |   1.0000
      x2 |   0.5583   1.0000
      x3 |   0.5967   0.4933   1.0000
      x4 |   0.6692   0.4455   0.6403   1.0000
      x5 |   0.1877   0.1472   0.1160   0.3769   1.0000
      x6 |   0.2246   0.3433   0.5316   0.5742   0.2833   1.0000
VIFs and eigenvalues, page 295.

Note: The collin.ado program written by ATS can be installed on your computer over the Internet by typing findit collin (see How can I use the findit command to search for programs and get additional help? for more information about using findit).

collin  x1 x2 x3 x4 x5 x6

  Collinearity Diagnostics

                        SQRT                           Cond
  Variable       VIF    VIF    Tolerance  Eigenval     Index
-------------------------------------------------------------
       x1-      2.67    1.63    0.3749     3.1692     1.0000
        x6      1.60    1.27    0.6247     1.0063     1.7746
                2.27    1.51    0.4403     0.7629     2.0382
                3.08    1.75    0.3249     0.5525     2.3950
                1.23    1.11    0.8143     0.3172     3.1607
                1.95    1.40    0.5124     0.1918     4.0654
-------------------------------------------------------------
  Mean VIF      2.13              Condition Number    4.0654
Part of Table 11.2, page 296.

Note: The probability to enter option, pe, was set to .99 so that all of the variables would enter and their order of entry observed.
* Stata 8 code.
sw regress y x1 x2 x3 x4 x5 x6, pe(.99)

* Stata 9 code and output.
stepwise, pe(.99): regress y x1 x2 x3 x4 x5 x6

                      begin with empty model
p = 0.0000 ^lt;  0.9900  adding   x1
p = 0.1278 ^lt;  0.9900  adding   x3
p = 0.2082 ^lt;  0.9900  adding   x6
p = 0.5616 ^lt;  0.9900  adding   x2
p = 0.6426 ^lt;  0.9900  adding   x4
p = 0.7963 ^lt;  0.9900  adding   x5

  Source |       SS       df       MS                  Number of obs =      30
---------+------------------------------               F(  6,    23) =   10.50
   Model |  3147.96634     6  524.661057               Prob > F      =  0.0000
Residual |  1149.00032    23  49.9565359               R-squared     =  0.7326
---------+------------------------------               Adj R-squared =  0.6628
   Total |  4296.96667    29  148.171264               Root MSE      =   7.068

------------------------------------------------------------------------------
       y |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
      x1 |   .6131876   .1609831      3.809   0.001       .2801687    .9462065
      x3 |   .3203321   .1685203      1.901   0.070      -.0282787    .6689429
      x6 |  -.2170567   .1782095     -1.218   0.236       -.585711    .1515977
      x2 |  -.0730501   .1357247     -0.538   0.596       -.353818    .2077178
      x4 |   .0817321   .2214777      0.369   0.715      -.3764293    .5398936
      x5 |   .0383814   .1469954      0.261   0.796      -.2657018    .3424647
   _cons |   10.78708   11.58926      0.931   0.362      -13.18713    34.76128
------------------------------------------------------------------------------
Part of table 11.3, page 297.

Note: The probability to remove option, pr, was set to .01 so that all of the variables except the last one would be removed and their order of removal observed.
* Stata 8 code.
sw regress y x1 x2 x3 x4 x5 x6, pr(.01)

* Stata 9 code and output.
stepwise, pr(.01): regress y x1 x2 x3 x4 x5 x6

                      begin with full model
p = 0.7963 >= 0.0100  removing x5
p = 0.6426 >= 0.0100  removing x4
p = 0.5616 >= 0.0100  removing x2
p = 0.2082 >= 0.0100  removing x6
p = 0.1278 >= 0.0100  removing x3

  Source |       SS       df       MS                  Number of obs =      30
---------+------------------------------               F(  1,    28) =   59.86
   Model |  2927.58425     1  2927.58425               Prob > F      =  0.0000
Residual |  1369.38241    28  48.9065148               R-squared     =  0.6813
---------+------------------------------               Adj R-squared =  0.6699
   Total |  4296.96667    29  148.171264               Root MSE      =  6.9933

------------------------------------------------------------------------------
       y |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
      x1 |   .7546098   .0975329      7.737   0.000       .5548227    .9543969
   _cons |   14.37632   6.619986      2.172   0.039       .8158929    27.93675
------------------------------------------------------------------------------
Regression equation, page 296.

Note: The probability to remove option, pr, was set to .33 to correspond to a t-value of 1.0.
* Stata 8 code.
sw regress y x1 x2 x3 x4 x5 x6, pr(.33)

* Stata 9 code and output.
stepwise, pr(.33): regress y x1 x2 x3 x4 x5 x6

                      begin with full model
p = 0.7963 >= 0.3300  removing x5
p = 0.6426 >= 0.3300  removing x4
p = 0.5616 >= 0.3300  removing x2

  Source |       SS       df       MS                  Number of obs =      30
---------+------------------------------               F(  3,    26) =   22.92
   Model |  3117.85753     3  1039.28584               Prob > F      =  0.0000
Residual |  1179.10914    26  45.3503515               R-squared     =  0.7256
---------+------------------------------               Adj R-squared =  0.6939
   Total |  4296.96667    29  148.171264               Root MSE      =  6.7343

------------------------------------------------------------------------------
       y |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
      x1 |   .6227297   .1181464      5.271   0.000       .3798763    .8655832
      x6 |  -.1869508   .1448537     -1.291   0.208      -.4847019    .1108003
      x3 |    .312387   .1541997      2.026   0.053      -.0045751    .6293491
   _cons |   13.57774     7.5439      1.800   0.084      -1.928967    29.08445
------------------------------------------------------------------------------
Tables 11.7 and 11.8, page 301.
use http://www.ats.ucla.edu/stat/stata/examples/chp/p301, clear
list year ftp unemp m lic

         year        ftp      unemp          m        lic 
  1.     1961     260.35         11      455.5     178.15  
  2.     1962      269.8          7      480.2     156.41  
  3.     1963     272.04        5.2      506.1     198.02  
  4.     1964     272.96        4.3      535.8      222.1  
  5.     1965     272.51        3.5        576     301.92  
  6.     1966     261.34        3.2      601.7     391.22  
  7.     1967     268.89        4.1      577.3     665.56  
  8.     1968     295.99        3.9      596.9    1131.21  
  9.     1969     319.87        3.6      613.5      837.8  
 10.     1970     341.43        7.1      569.3      794.9  
 11.     1971     356.59        8.4      548.8     817.74  
 12.     1972     376.69        7.7      563.4     583.17  
 13.     1973     390.19        6.3      609.3     709.59 
 
list year gr clear w nman

         year         gr      clear             w       nman 
  1.     1961     215.98       93.4        558724      538.1  
  2.     1962     180.48       88.5        538584      547.6  
  3.     1963     209.57       94.4        519171      562.8  
  4.     1964     231.67         92        500457        591  
  5.     1965     297.65         91        482418      626.1  
  6.     1966     367.62       87.4        465029      659.8  
  7.     1967     616.54       88.3        448267      686.2  
  8.     1968    1029.75       86.1        432109      699.6  
  9.     1969     786.23         79        416533      729.9  
 10.     1970     713.77       73.9        401518      757.8  
 11.     1971     750.43       63.4        398046      755.3  
 12.     1972    1027.38       62.5        373095        787  
 13.     1973      666.5       58.9        359647      819.8
 
list year g he we h

         year          g         he         we          h 
  1.     1961      133.9       2.98     117.18        8.6  
  2.     1962      137.6       3.09     134.02        8.9  
  3.     1963      143.6       3.23     141.68       8.52  
  4.     1964      150.3       3.33     147.98       8.89  
  5.     1965      164.3       3.46     159.85      13.07  
  6.     1966      179.5        3.6     157.19      14.57  
  7.     1967      187.5       3.73     155.29      21.36  
  8.     1968      195.4       2.91     131.75      28.03  
  9.     1969      210.3       4.25     178.74      31.49  
 10.     1970      223.8       4.47      178.3      37.39  
 11.     1971      227.7       5.04     209.54      46.26  
 12.     1972      230.9       5.47     240.05      47.24  
 13.     1973      230.2       5.76     258.05      52.33 
Table 11.9, page 301.
regress h g m w, beta

  Source |       SS       df       MS                  Number of obs =      13
---------+------------------------------               F(  3,     9) =  115.03
   Model |   3139.9039     3  1046.63463               Prob > F      =  0.0000
Residual |  81.8858502     9  9.09842781               R-squared     =  0.9746
---------+------------------------------               Adj R-squared =  0.9661
   Total |  3221.78975    12  268.482479               Root MSE      =  3.0164

------------------------------------------------------------------------------
       h |      Coef.   Std. Err.       t     P>|t|                       Beta
---------+--------------------------------------------------------------------
       g |   .1041508   .1527901      0.682   0.513                   .2354133
       m |  -.1330913   .0297607     -4.472   0.002                  -.4046823
       w |  -.0002635   .0000972     -2.711   0.024                  -1.024555
   _cons |   199.3063   81.57561      2.443   0.037                          .
------------------------------------------------------------------------------
Table 11.1, page 302.
regress h g, beta

  Source |       SS       df       MS                  Number of obs =      13
---------+------------------------------               F(  1,    11) =  122.93
   Model |  2957.17935     1  2957.17935               Prob > F      =  0.0000
Residual |  264.610399    11  24.0554908               R-squared     =  0.9179
---------+------------------------------               Adj R-squared =  0.9104
   Total |  3221.78975    12  268.482479               Root MSE      =  4.9046

------------------------------------------------------------------------------
       h |      Coef.   Std. Err.       t     P>|t|                       Beta
---------+--------------------------------------------------------------------
       g |   .4238596   .0382288     11.087   0.000                   .9580545
   _cons |  -53.61314   7.230834     -7.415   0.000                          .
------------------------------------------------------------------------------

regress h m, beta

  Source |       SS       df       MS                  Number of obs =      13
---------+------------------------------               F(  1,    11) =    4.68
   Model |  961.954657     1  961.954657               Prob > F      =  0.0533
Residual |  2259.83509    11  205.439554               R-squared     =  0.2986
---------+------------------------------               Adj R-squared =  0.2348
   Total |  3221.78975    12  268.482479               Root MSE      =  14.333

------------------------------------------------------------------------------
       h |      Coef.   Std. Err.       t     P>|t|                       Beta
---------+--------------------------------------------------------------------
       m |   .1797066   .0830479      2.164   0.053                   .5464227
   _cons |  -74.87015   46.38238     -1.614   0.135                          .
------------------------------------------------------------------------------

regress h w, beta

  Source |       SS       df       MS                  Number of obs =      13
---------+------------------------------               F(  1,    11) =   95.44
   Model |  2888.84975     1  2888.84975               Prob > F      =  0.0000
Residual |  332.939995    11  30.2672723               R-squared     =  0.8967
---------+------------------------------               Adj R-squared =  0.8873
   Total |  3221.78975    12  268.482479               Root MSE      =  5.5016

------------------------------------------------------------------------------
       h |      Coef.   Std. Err.       t     P>|t|                       Beta
---------+--------------------------------------------------------------------
       w |  -.0002436   .0000249     -9.770   0.000                  -.9469213
   _cons |   135.5437   11.40463     11.885   0.000                          .
------------------------------------------------------------------------------

regress h g m, beta

  Source |       SS       df       MS                  Number of obs =      13
---------+------------------------------               F(  2,    10) =  103.29
   Model |  3073.02599     2  1536.51299               Prob > F      =  0.0000
Residual |  148.763759    10  14.8763759               R-squared     =  0.9538
---------+------------------------------               Adj R-squared =  0.9446
   Total |  3221.78975    12  268.482479               Root MSE      =   3.857

------------------------------------------------------------------------------
       h |      Coef.   Std. Err.       t     P>|t|                       Beta
---------+--------------------------------------------------------------------
       g |   .5083883   .0426769     11.912   0.000                   1.149116
       m |  -.0885298   .0317246     -2.791   0.019                   -.269187
   _cons |  -20.05391   13.30252     -1.508   0.163                          .
------------------------------------------------------------------------------

regress h g w, beta

  Source |       SS       df       MS                  Number of obs =      13
---------+------------------------------               F(  2,    10) =   56.05
   Model |  2957.94195     2  1478.97098               Prob > F      =  0.0000
Residual |  263.847795    10  26.3847795               R-squared     =  0.9181
---------+------------------------------               Adj R-squared =  0.9017
   Total |  3221.78975    12  268.482479               Root MSE      =  5.1366

------------------------------------------------------------------------------
       h |      Coef.   Std. Err.       t     P>|t|                       Beta
---------+--------------------------------------------------------------------
       g |   .3840859   .2373508      1.618   0.137                   .8681538
       w |  -.0000235    .000138     -0.170   0.868                  -.0912077
   _cons |  -35.58906   106.2883     -0.335   0.745                          .
------------------------------------------------------------------------------

regress h m w, beta

  Source |       SS       df       MS                  Number of obs =      13
---------+------------------------------               F(  2,    10) =  182.07
   Model |  3135.67622     2  1567.83811               Prob > F      =  0.0000
Residual |  86.1135256    10  8.61135256               R-squared     =  0.9733
---------+------------------------------               Adj R-squared =  0.9679
   Total |  3221.78975    12  268.482479               Root MSE      =  2.9345

------------------------------------------------------------------------------
       h |      Coef.   Std. Err.       t     P>|t|                       Beta
---------+--------------------------------------------------------------------
       m |  -.1414025   .0264117     -5.354   0.000                  -.4299537
       w |  -.0003282   .0000207    -15.888   0.000                  -1.275933
   _cons |   252.5913   22.69316     11.131   0.000                          .
------------------------------------------------------------------------------

How to cite this page

Report an error on this page or leave a comment

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.