input id x y
1 1 2
2 3 3
3 5 6
4 7 5
5 9 9
end
summarize x y
correlate x y
regress y x
predict yhat
predict resid, residual
predict zresid, rstandard
plot y x
graph y yhat x, connect(.s)
plot resid x
plot zresid x

-----------------------------------------------
 
summarize x y
 
Variable |     Obs        Mean   Std. Dev.       Min        Max
---------+-----------------------------------------------------
       x |       5           5   3.162278          1          9  
       y |       5           5   2.738613          2          9  
        
correlate x y
 
(obs=5)
 
         |        x        y
---------+------------------
       x |   1.0000
       y |   0.9238   1.0000
   
regress y x
 
  Source |       SS       df       MS                  Number of obs =       5
---------+------------------------------               F(  1,     3) =   17.45
   Model |       25.60     1       25.60               Prob > F      =  0.0250
Residual |        4.40     3  1.46666667               R-squared     =  0.8533
---------+------------------------------               Adj R-squared =  0.8044
   Total |       30.00     4        7.50               Root MSE      =  1.2111

------------------------------------------------------------------------------
       y |      Coef.   Std. Err.       t     P>|t|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
       x |         .8   .1914854      4.178   0.025       .1906079    1.409392
   _cons |          1        1.1      0.909   0.430      -2.500691    4.500691
------------------------------------------------------------------------------
 
predict yhat
predict resid, residual
predict zresid, rstandard
plot y x
 
       9 +  
         |                                                                 *
         |  
         |  
         |  
         |  
         |  
         |  
         |  
         |  
    y    |                                 *
         |  
         |                                                 *
         |  
         |  
         |  
         |  
         |  
         |                 *
         |  
       2 + *
          +----------------------------------------------------------------+
                1                        x                               9
 
graph y yhat x, connect(.s)
  

                 
plot resid x
 
       1 +  
         |                                 *
         |  
         |                                                                 *
         |  
         |  
    R    |  
    e    | *
    s    |  
    i    |  
    d    |  
    u    |  
    a    |                 *
    l    |  
    s    |  
         |  
         |  
         |  
         |  
         |  
    -1.6 +                                                 *
          +----------------------------------------------------------------+
                1                        x                               9
  
plot zresid x
 
 1.04447 +  
    S    |                                                                 *
    t    |                                 *
    a    |  
    n    |  
    d    |  
    a    |  
    r    | *
    d    |  
    i    |  
    z    |  
    e    |  
    d    |                 *
         |  
    r    |  
    e    |  
    s    |  
    i    |  
    d    |  
    u    |  
-1.57908 +                                                 *
          +----------------------------------------------------------------+
                1                        x                               9