Simple Regression Analysis of Agresti & Finlay data from Table 9.4


[Stata Program]

use http://www.gseis.ucla.edu/courses/data/hsales
 
describe
summarize price size
plot price size
correlate price size
regress price size
predict yhat
predict resid, residual
predict zresid, rstandard
graph price yhat size, connect(.s)
more
stem zresid
graph zresid, histogram normal bin(15)
qnorm zresid
sort zresid
list size price zresid in 1/5
list size price zresid in -5/l
rvpplot size, yline(0)
rvfplot, yline(0)
drop if price >=250
regress price sizeÊ
plot price sizeÊ
predict zresid2, rstandard
graph zresid2,histogram normal bin(15)
                             
  
[Stata Output]
 
. describe
 
Contains data from http://www.gseis.ucla.edu/courses/data/hsales.dta
  obs:            93                          
 vars:             5                          7 Dec 1999 15:53
 size:         2,232 (98.1% of memory free)
-------------------------------------------------------------------------------
   1. price     float  %9.0g                  sell price in 1,000's
   2. size      float  %9.0g                  sq feet in 1,000's
   3. bdrms     float  %9.0g                  number bedrooms
   4. bathrms   float  %9.0g                  number bathrooms
   5. new       float  %9.0g       nl         new house?
-------------------------------------------------------------------------------
Sorted by:  
 
. summarize price size
 
Variable |     Obs        Mean   Std. Dev.       Min        Max
---------+-----------------------------------------------------
   price |      93    99.53333   44.18413       17.5      309.4  
    size |      93    1.649677   .5252607         .4       3.85  
 
. plot price size
 
   309.4 +  
    s    |                                                      *
    e    |  
    l    |                                                                 *
    l    |  
         |  
    p    |  
    r    |  
    i    |  
    c    |                                         *
    e    |                                   *
         |  
    i    |                               ** *   *           *
    n    |                          * * **      *
         |                      ***** * **  *   *
    1    |                  ******* ** **
    ,    |              * ****  * **      *
    0    |              ************
    0    |           ***    *
    0    |        *
    17.5 + *     * * *     *
          +----------------------------------------------------------------+
               .4               sq feet in 1,000's                   3.85
 
. correlate price size
(obs=93)
 
         |    price     size
---------+------------------
   price |   1.0000
    size |   0.8988   1.0000
 
. regress price size

  Source |       SS       df       MS                  Number of obs =      93
---------+------------------------------               F(  1,    91) =  382.63
   Model |  145097.459     1  145097.459               Prob > F      =  0.0000
Residual |  34508.4029    91  379.213218               R-squared     =  0.8079
---------+------------------------------               Adj R-squared =  0.8058
   Total |  179605.862    92  1952.23763               Root MSE      =  19.473
 
------------------------------------------------------------------------------
   price |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
    size |   75.60684   3.865208     19.561   0.000       67.92908     83.2846
   _cons |  -25.19356    6.68845     -3.767   0.000      -38.47935   -11.90778
------------------------------------------------------------------------------
 
. predict yhat
. predict resid, residual
. predict zresid, rstandard
 
. graph price yhat size, connect(.s)
 

 
. stem zresid
 
Stem-and-leaf plot for zresid (Standardized residuals)
 
zresid rounded to nearest multiple of .01
plot in units of .01
 
 -3** | 03
 -2** | 69
 -2** | 36
 -1** | 93,68
 -1** | 46,32,26,13,07,03,02,01
 -0** | 93,85,85,84,84,83,75,72,72,57,55,54
 -0** | 49,47,43,38,38,38,38,37,34,33,29,21,19,18,11,10,06
  0** | 05,05,06,07,11,13,15,20,21,22,28,31,33,33,33,36,36,37,43,48,49,49
  0** | 53,54,56,57,58,59,66,69,69,72,74,78,81,93,93,94,95
  1** | 02,04,09,10,10,10,13,14,17,26,46
  1** | 
  2** | 
  2** | 
  3** | 
  3** | 
  4** | 
  4** | 65
 
. graph zresid, histogram normal bin(15)
 

 
. qnorm zresid
 

 
. sort zresid
. list size price zresid in 1/5
 
          size      price     zresid
  1.      3.05        149  -3.033176
  2.      1.28       19.6  -2.691249
  3.       2.1       88.1  -2.357733
  4.      1.74         69  -1.929348
  5.       2.4        124  -1.684739
 
. list size price zresid in -5/l
 
          size      price     zresid
 89.      1.43        105   1.140879
 90.      1.62        120   1.172573
 91.      1.15         86   1.258087
 92.      2.25      172.9   1.455004
 93.       3.3      309.4   4.652866
 
. rvpplot size, yline(0)
 

 
. rvfplot, yline(0)
 

 
drop if price>=250
. regress price size
 
      Source |       SS       df       MS              Number of obs =      91
-------------+------------------------------           F(  1,    89) =  268.65
       Model |  76106.4446     1  76106.4446           Prob > F      =  0.0000
    Residual |  25212.8979    89  283.290988           R-squared     =  0.7512
-------------+------------------------------           Adj R-squared =  0.7484
       Total |  101319.342    90  1125.77047           Root MSE      =  16.831

------------------------------------------------------------------------------
       price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        size |    65.6568   4.005764    16.39   0.000     57.69743    73.61617
       _cons |  -10.29033   6.676088    -1.54   0.127    -23.55558    2.974911
------------------------------------------------------------------------------
 
. plot price size
 
     190 +  
    s    |                                                     *
    e    |  
    l    |                                             *
    l    |  
         |  
    p    |                                        *   *    *               *
    r    |                                       ****      *
    i    |                                  * *  *
    c    |                              *     *  *         *
    e    |                            ** ****    * *  *
         |                         ***  **  * **
    i    |                        *  **          *
    n    |                   * *** *  ** **         *
         |                   ** * * *  ***
    1    |                    ***  ** *    *
    ,    |               *       *
    0    |                 *
    0    |  
    0    |          **  *
    17.5 + *       *            *
          +----------------------------------------------------------------+
               .4               sq feet in 1,000's                   3.05
 
. predict zresid2, rstandard
. graph zresid2,histogram normal bin(15)