Ed230B/C

CRF-322 Example


use http://www.gseis.ucla.edu/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)




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.00    11  1199.45455       7.66     0.0000
                         |
                  method |     3675.00     2     1837.50      11.73     0.0000
                    book |     2048.00     1     2048.00      13.07     0.0006
                computer |     5202.00     1     5202.00      33.20     0.0000
             method*book |      259.00     2      129.50       0.83     0.4425
         method*computer |      903.00     2      451.50       2.88     0.0638
           book*computer |       32.00     1       32.00       0.20     0.6529
    method*book*computer |     1075.00     2      537.50       3.43     0.0388
                         |
                Residual |     9400.00    60  156.666667   
    ---------------------+----------------------------------------------------
                   Total |    22594.00    71  318.225352   

predict cmean

local ssr=e(rss)

local dfr=e(df_r)

omega2 meth*book*com

 omega squared for meth*book*com = 0.0633
 effect size   = 0.2599

omega2 method

 omega squared for method = 0.2296
 effect size   = 0.5459

omega2 book

 omega squared for book = 0.1436
 effect size   = 0.4095

omega2 computer

 omega squared for computer = 0.3090
 effect size   = 0.6688

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)



anova test book computer book*computer if method==1

                           Number of obs =      24     R-squared     =  0.3779
                           Root MSE      =  11.265     Adj R-squared =  0.2846

                  Source |  Partial SS    df       MS           F     Prob > F
           --------------+----------------------------------------------------
                   Model |     1542.00     3      514.00       4.05     0.0211
                         |
                    book |      864.00     1      864.00       6.81     0.0168
                computer |      294.00     1      294.00       2.32     0.1436
           book*computer |      384.00     1      384.00       3.03     0.0973
                         |
                Residual |     2538.00    20      126.90   
           --------------+----------------------------------------------------
                   Total |     4080.00    23  177.391304   

test5 book*computer, sse(`ssr') dfe(`dfr')
/* net from http://www.ats.ucla.edu/stat/stata/ado/   */
/* net install test5                                  */

           Source  Partial SS    df       MS         F    Prob > F
    book*computer      384.00     1     384.00      2.45    0.1227
         Residual     9400.00    60     156.67

anova test book computer book*computer if method==2

                           Number of obs =      24     R-squared     =  0.5653
                           Root MSE      =  12.025     Adj R-squared =  0.5001

                  Source |  Partial SS    df       MS           F     Prob > F
           --------------+----------------------------------------------------
                   Model |     3760.50     3     1253.50       8.67     0.0007
                         |
                    book |      181.50     1      181.50       1.26     0.2758
                computer |     3037.50     1     3037.50      21.01     0.0002
           book*computer |      541.50     1      541.50       3.74     0.0672
                         |
                Residual |     2892.00    20      144.60   
           --------------+----------------------------------------------------
                   Total |     6652.50    23   289.23913   

test5 book*computer, sse(`ssr') dfe(`dfr')

           Source  Partial SS    df       MS         F    Prob > F
    book*computer      541.50     1     541.50      3.46    0.0679
         Residual     9400.00    60     156.67

anova test book computer book*computer if method==3

                           Number of obs =      24     R-squared     =  0.5151
                           Root MSE      =  14.089     Adj R-squared =  0.4423

                  Source |  Partial SS    df       MS           F     Prob > F
           --------------+----------------------------------------------------
                   Model |     4216.50     3     1405.50       7.08     0.0020
                         |
                    book |     1261.50     1     1261.50       6.36     0.0203
                computer |     2773.50     1     2773.50      13.97     0.0013
           book*computer |      181.50     1      181.50       0.91     0.3504
                         |
                Residual |     3970.00    20      198.50   
           --------------+----------------------------------------------------
                   Total |     8186.50    23  355.934783   

test5 book*computer, sse(`ssr') dfe(`dfr')

           Source  Partial SS    df       MS         F    Prob > F
    book*computer      181.50     1     181.50      1.16    0.2861
         Residual     9400.00    60     156.67

cmeans test method book if computer==0, label
 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)




cmeans test method book if computer==1, label
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)



anova test method book method*book if computer==0

                           Number of obs =      36     R-squared     =  0.2136
                           Root MSE      = 13.2941     Adj R-squared =  0.0825

                  Source |  Partial SS    df       MS           F     Prob > F
             ------------+----------------------------------------------------
                   Model |     1440.00     5      288.00       1.63     0.1825
                         |
                  method |      474.00     2      237.00       1.34     0.2768
                    book |      784.00     1      784.00       4.44     0.0437
             method*book |      182.00     2       91.00       0.51     0.6027
                         |
                Residual |     5302.00    30  176.733333   
             ------------+----------------------------------------------------
                   Total |     6742.00    35  192.628571   

test5 method*book, sse(`ssr') dfe(`dfr')

           Source  Partial SS    df       MS         F    Prob > F
      method*book      182.00     2      91.00      0.58    0.5625
         Residual     9400.00    60     156.67

anova test method book method*book if computer==1

                           Number of obs =      36     R-squared     =  0.6152
                           Root MSE      = 11.6876     Adj R-squared =  0.5511

                  Source |  Partial SS    df       MS           F     Prob > F
             ------------+----------------------------------------------------
                   Model |     6552.00     5     1310.40       9.59     0.0000
                         |
                  method |     4104.00     2     2052.00      15.02     0.0000
                    book |     1296.00     1     1296.00       9.49     0.0044
             method*book |     1152.00     2      576.00       4.22     0.0243
                         |
                Residual |     4098.00    30      136.60   
             ------------+----------------------------------------------------
                   Total |    10650.00    35  304.285714   

test5 method*book, sse(`ssr') dfe(`dfr')

           Source  Partial SS    df       MS         F    Prob > F
      method*book     1152.00     2     576.00      3.68    0.0312
         Residual     9400.00    60     156.67


Linear Statistical Models Course

Phil Ender, 10apr06, 27apr01