Linear Statistical Models: Regression

CRF-322 Example

Updataed for Stata 11


use http://www.philender.com/courses/data/crf322, clear

tab1 method book computer

-> tabulation of method  

     method |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |         24       33.33       33.33
          2 |         24       33.33       66.67
          3 |         24       33.33      100.00
------------+-----------------------------------
      Total |         72      100.00

-> tabulation of book  

       book |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |         36       50.00       50.00
          2 |         36       50.00      100.00
------------+-----------------------------------
      Total |         72      100.00

-> tabulation of computer  

   computer |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |         36       50.00       50.00
          1 |         36       50.00      100.00
------------+-----------------------------------
      Total |         72      100.00


summarize test, detail

                            test
-------------------------------------------------------------
      Percentiles      Smallest
 1%          152            152
 5%          158            156
10%          161            157       Obs                  72
25%        170.5            158       Sum of Wgt.          72

50%        182.5                      Mean              184.5
                        Largest       Std. Dev.      17.83887
75%        198.5            217
90%          206            219       Variance       318.2254
95%          217            224       Skewness       .2806147
99%          228            228       Kurtosis       2.387098

stem test

Stem-and-leaf plot for test

  15* | 2
  15. | 6789
  16* | 0012444
  16. | 569
  17* | 000133334
  17. | 556699
  18* | 00001234
  18. | 6779
  19* | 00004444
  19. | 56789999
  20* | 12344
  20. | 5669
  21* | 
  21. | 579
  22* | 4
  22. | 8

kdensity test, normal



table book computer, by(method) con(freq)

----------------------
method    |  computer 
and book  |    0     1
----------+-----------
1         |
        1 |    6     6
        2 |    6     6
----------+-----------
2         |
        1 |    6     6
        2 |    6     6
----------+-----------
3         |
        1 |    6     6
        2 |    6     6
----------------------


table book computer, by(method) con(mean test)

----------------------
method    |  computer 
and book  |    0     1
----------+-----------
1         |
        1 |  169   168
        2 |  173   188
----------+-----------
2         |
        1 |  172   204
        2 |  187   200
----------+-----------
3         |
        1 |  173   189
        2 |  182   209
----------------------

table book computer, by(method) con(sd test)

------------------------------
method    |      computer     
and book  |        0         1
----------+-------------------
1         |
        1 | 14.81891  8.602325
        2 | 9.797959  10.86278
----------+-------------------
2         |
        1 | 10.93618  12.68069
        2 | 14.01428  10.07968
----------+-------------------
3         |
        1 |  11.6619  12.61745
        2 |  17.1114   14.3527
------------------------------

egen grp=group(method book computer)

graph box test, over(method) over(book) over(computer)



histogram test, by(method book computer)




/* note abbreviations in anova command */

anova test method book computer meth#book meth#com book#com meth#book#com


                           Number of obs =      72     R-squared     =  0.5840
                           Root MSE      = 12.5167     Adj R-squared =  0.5077

                  Source |  Partial SS    df       MS           F     Prob > F
    ---------------------+----------------------------------------------------
                   Model |       13194    11  1199.45455       7.66     0.0000
                         |
                  method |        3675     2      1837.5      11.73     0.0001
                    book |        2048     1        2048      13.07     0.0006
                computer |        5202     1        5202      33.20     0.0000
             method#book |         259     2       129.5       0.83     0.4425
         method#computer |         903     2       451.5       2.88     0.0638
           book#computer |          32     1          32       0.20     0.6529
    method#book#computer |        1075     2       537.5       3.43     0.0388
                         |
                Residual |        9400    60  156.666667   
    ---------------------+----------------------------------------------------
                   Total |       22594    71  318.225352   

predict cmean

effectsize meth#book#com

anova effect size for meth#book#com with dep var = test

total variance accounted for
omega2         = .03347887
eta2           = .047579
Cohen's f      = .1861143

partial variance accounted for
partial omega2 = .0632526
partial eta2   = .1026253

effectsize method

anova effect size for method with dep var = test

total variance accounted for
omega2         = .14776124
eta2           = .1626538
Cohen's f      = .41638936

partial variance accounted for
partial omega2 = .2295959
partial eta2   = .28107075

effectsize book

anova effect size for book with dep var = test

total variance accounted for
omega2         = .0831331
eta2           = .09064353
Cohen's f      = .301116

partial variance accounted for
partial omega2 = .14359468
partial eta2   = .17889588

effectsize computer

anova effect size for computer with dep var = test

total variance accounted for
omega2         = .2217664
eta2           = .23023812
Cohen's f      = .53381759

partial variance accounted for
partial omega2 = .30904933
partial eta2   = .35625257

twoway (line cmean computer if book==1 & method==1)(line cmean computer if book==2 & method==1)



twoway (line cmean computer if book==1 & method==2)(line cmean computer if book==2 & method==2)



twoway (line cmean computer if book==1 & method==3)(line cmean computer if book==2 & method==3)



/* using anovaplot -- findit it anovaplot */

anovaplot book method computer, scatter(msym(i)) scheme(lean1)



/* simple two-way effect using anovalator -- findit anovalator */

anovalator book computer, 2way fratio at(method=1)

anovalator two-way interaction for book#computer at(method=1) 
chi2(1) = 2.4510638   p-value = .11744525
scaled as F-ratio = 2.4510638   

anovalator book computer, 2way fratio at(method=2)

anovalator two-way interaction for book#computer at(method=2) 
chi2(1) = 3.456383   p-value = .063008
scaled as F-ratio = 3.456383   

anovalator book computer, 2way fratio at(method=3)

anovalator two-way interaction for book#computer at(method=3) 
chi2(1) = 1.1585106   p-value = .28177464
scaled as F-ratio = 1.1585106

twoway (line cmean book if computer==0 & method==1)(line cmean book if computer==0 & method==2)(line cmean book if computer==0 & method==3)



twoway (line cmean book if computer==1 & method==1)(line cmean book if computer==1 & method==2)(line cmean book if computer==1 & method==3)



anovalator method book, 2way fratio at(computer=0)

anovalator two-way interaction for method#book at(computer=0) 
chi2(2) = 1.1617021   p-value = .55942206
scaled as F-ratio = .58085106

anovalator method book, 2way fratio at(computer=1)

anovalator two-way interaction for method#book at(computer=1) 
chi2(2) = 7.3531915   p-value = .02530899
scaled as F-ratio = 3.6765957


Linear Statistical Models Course

Phil Ender, 24sep10, 10apr06, 27apr01