-------------
       log:  C:\Users\110g093\Documents\43523-Newbold-Stat-6e\gpa-act.smcl
  log type:  smcl
 opened on:  21 Sep 2017, 16:11:07

. edit

. gen gpa=var1

. gen act=var2

. describe

Contains data
  obs:             8
 vars:             4
 size:           136 (99.9% of memory free)
-------------
              storage  display     value
variable name   type   format      label      variable label
-------------


var1              float    %9.0g


var2              byte     %8.0g


gpa               float    %9.0g


act               float    %9.0g


-------------
Sorted by:
     Note:  dataset has changed since last saved

. summarize

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        var1 |         8      3.2125    .3833592        2.7        3.7
        var2 |         8      25.875    2.850439         21         30
         gpa |         8      3.2125    .3833592        2.7        3.7
         act |         8      25.875    2.850439         21         30

. display


. display 3*3
9

. list

     +-------------------------+
     | var1   var2   gpa   act |
     +-------------------------+
  1. |  2.8     21   2.8    21 |
  2. |  3.4     24   3.4    24 |
  3. |    3     26     3    26 |
  4. |  3.5     27   3.5    27 |
  5. |  3.6     29   3.6    29 |
     +-------------------------+
  6. |    3     25     3    25 |
  7. |  2.7     25   2.7    25 |
  8. |  3.7     30   3.7    30 |
     +-------------------------+

. drop var1 var2

. log off
       log:  C:\Users\110g093\Documents\43523-Newbold-Stat-6e\gpa-act.smcl
  log type:  smcl
 paused on:  21 Sep 2017, 16:13:27
-------------


-------------
       log:  C:\Users\110g093\Documents\43523-Newbold-Stat-6e\gpa-act.smcl
  log type:  smcl
resumed on:  21 Sep 2017, 16:14:40

. egen totgpa=sum(gpa)
totgpa already defined
r(110);

. drop totgpa

. egen totgpa=sum(gpa)

. egen totact=sum(act)

. gen dif_gpa = gpa - totgpa/8

. gen dif_act = act - totact/8

. browse

. gen dif_gpa_act =  dif_gpa * dif_act

. browse

. gen dif_act2 =  dif_act * dif_act

. egen totdif_act2 = sum(dif_act2)

. egen totdif_gpa_act =  sum( dif_gpa_act)

. gen beta1=  totdif_gpa_act / totdif_act2

. browse

. gen beta0= totgpa/8 - beta1* totact/8

. browse

. gen resid =  gpa - beta0 - beta1* act

. browse

. gen resid2 = resid*resid

. egen totresid2 = sum(resid2)

. gen sigma2hat =  totresid2 / 6

. browse

. log off
       log:  C:\Users\110g093\Documents\43523-Newbold-Stat-6e\gpa-act.smcl
  log type:  smcl
 paused on:  21 Sep 2017, 16:26:03
-------------


-------------
       log:  C:\Users\110g093\Documents\43523-Newbold-Stat-6e\gpa-act.smcl
  log type:  smcl
resumed on:  21 Sep 2017, 16:27:27

. regress gpa act

      Source |       SS       df       MS              Number of obs =       8
-------------+------------------------------           F(  1,     6) =    8.20
       Model |  .594024707     1  .594024707           Prob > F      =  0.0287
    Residual |  .434725292     6  .072454215           R-squared     =  0.5774
-------------+------------------------------           Adj R-squared =  0.5070
       Total |     1.02875     7  .146964286           Root MSE      =  .26917

-------------+----------------------------------------------------------------
         gpa |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         act |   .1021978    .035692     2.86   0.029     .0148626     .189533
       _cons |   .5681319   .9284214     0.61   0.563    -1.703633    2.839897
-------------+----------------------------------------------------------------

. browse
. clear

** type "exit" to exit Stata.

. log close
       log:  C:\Users\110g093\Documents\43523-Newbold-Stat-6e\gpa-act.smcl
  log type:  smcl
 closed on:  21 Sep 2017, 16:29:06
-------------