. do "C:\Users\hstryhn\AppData\Local\Temp\STDf14_000000.tmp"

. * do-file for extra lecture 2, May 2018
. * note: interpretation of output after each command
. version 15 /* works also with versions 13-14 */

. set more off

. cd "r:\data"
r:\data

.
. import delimited orthwide.csv, clear
(7 vars, 27 obs)

. manova dist08-dist14 = sex

                       Number of obs =         27

                       W = Wilks' lambda      L = Lawley-Hotelling trace
                       P = Pillai's trace     R = Roy's largest root

              Source | Statistic        df    F(df1,     df2) =   F   Prob>F
          -----------+-------------------------------------------------------
                 sex |W   0.6023         1      4.0     22.0     3.63 0.0203 e
                     |P   0.3977                4.0     22.0     3.63 0.0203 e
                     |L   0.6603                4.0     22.0     3.63 0.0203 e
                     |R   0.6603                4.0     22.0     3.63 0.0203 e
                     +-------------------------------------------------------
            Residual |                  25
          -----------+-------------------------------------------------------
               Total |                  26
          -----------+-------------------------------------------------------
                       e = exact, a = approximate, u = upper bound on F

. * test of equality between groups (no parallelism)
. mvreg

Equation             Obs   Parms        RMSE    "R-sq"          F        P
--------------------------------------------------------------------------
dist08                27       2    2.327113    0.1213   3.450811   0.0750
dist10                27       2    2.045672    0.1354   3.914354   0.0590
dist12                27       2    2.540815    0.2181   6.972702   0.0141
dist14                27       2    2.232877    0.3737   14.91756   0.0007

-------------+----------------------------------------------------------------
             |      Coef.    Std. Err.       t    P>|t|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
dist08       |
       1.sex |   -1.693182    .9114713     -1.86    0.075     -3.570392     .1840285
       _cons |      22.875    .5817782     39.32    0.000      21.67681     24.07319
-------------+----------------------------------------------------------------
dist10       |
       1.sex |   -1.585227    .8012379     -1.98    0.059     -3.235408     .0649531
       _cons |     23.8125    .5114179     46.56    0.000      22.75922     24.86578
-------------+----------------------------------------------------------------
dist12       |
       1.sex |   -2.627841    .9951728     -2.64    0.014     -4.677438    -.5782441
       _cons |    25.71875    .6352036     40.49    0.000      24.41052     27.02698
-------------+----------------------------------------------------------------
dist14       |
       1.sex |   -3.377841    .8745614     -3.86    0.001     -5.179034    -1.576648
       _cons |    27.46875    .5582192     49.21    0.000      26.31908     28.61842
-------------+----------------------------------------------------------------

. manova dist08-dist14 = ibn.sex, nocons

                       Number of obs =         27

                       W = Wilks' lambda      L = Lawley-Hotelling trace
                       P = Pillai's trace     R = Roy's largest root

              Source | Statistic        df    F(df1,     df2) =   F   Prob>F
          -----------+-------------------------------------------------------
                 sex |W   0.0046         2      8.0     44.0    76.02 0.0000 e
                     |P   1.1932                8.0     46.0     8.50 0.0000 a
                     |L 175.2362                8.0     42.0   459.99 0.0000 a
                     |R 174.9879                4.0     23.0  1006.18 0.0000 u
                     +-------------------------------------------------------
            Residual |                  25
          -----------+-------------------------------------------------------
               Total |                  27
          -----------+-------------------------------------------------------
                       e = exact, a = approximate, u = upper bound on F

. mvreg

Equation             Obs   Parms        RMSE    "R-sq"          F        P
--------------------------------------------------------------------------
dist08                27       2    2.327113    0.9899    1228.67   0.0000
dist10                27       2    2.045672    0.9928   1733.324   0.0000
dist12                27       2    2.540815    0.9903   1273.933   0.0000
dist14                27       2    2.232877    0.9933    1850.94   0.0000

-------------+----------------------------------------------------------------
             |      Coef.    Std. Err.       t    P>|t|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
dist08       |
         sex |
          0  |      22.875    .5817782     39.32    0.000      21.67681     24.07319
          1  |    21.18182    .7016509     30.19    0.000      19.73674      22.6269
-------------+----------------------------------------------------------------
dist10       |
         sex |
          0  |     23.8125    .5114179     46.56    0.000      22.75922     24.86578
          1  |    22.22727    .6167932     36.04    0.000      20.95696     23.49758
-------------+----------------------------------------------------------------
dist12       |
         sex |
          0  |    25.71875    .6352036     40.49    0.000      24.41052     27.02698
          1  |    23.09091    .7660844     30.14    0.000      21.51313     24.66869
-------------+----------------------------------------------------------------
dist14       |
         sex |
          0  |    27.46875    .5582192     49.21    0.000      26.31908     28.61842
          1  |    24.09091    .6732377     35.78    0.000      22.70435     25.47747
-------------+----------------------------------------------------------------

. * means
. matrix define error=e(E)

. matrix cov=error/25

. matrix list cov

symmetric cov[4,4]
           dist08     dist10     dist12     dist14
dist08  5.4154545
dist10  2.7168182  4.1847727
dist12  3.9102273  2.9271591  6.4557386
dist14  2.7102273  3.3171591  4.1307386  4.9857386

. * covariance matrix
.
. manova dist08-dist14 = sex

                       Number of obs =         27

                       W = Wilks' lambda      L = Lawley-Hotelling trace
                       P = Pillai's trace     R = Roy's largest root

              Source | Statistic        df    F(df1,     df2) =   F   Prob>F
          -----------+-------------------------------------------------------
                 sex |W   0.6023         1      4.0     22.0     3.63 0.0203 e
                     |P   0.3977                4.0     22.0     3.63 0.0203 e
                     |L   0.6603                4.0     22.0     3.63 0.0203 e
                     |R   0.6603                4.0     22.0     3.63 0.0203 e
                     +-------------------------------------------------------
            Residual |                  25
          -----------+-------------------------------------------------------
               Total |                  26
          -----------+-------------------------------------------------------
                       e = exact, a = approximate, u = upper bound on F

. mat timediff=(1,-1,0,0\1,0,-1,0\1,0,0,-1)

. manovatest sex, ytransf(timediff)

 Transformations of the dependent variables


(1)    dist08 - dist10


(2)    dist08 - dist12


(3)    dist08 - dist14


                       W = Wilks' lambda      L = Lawley-Hotelling trace
                       P = Pillai's trace     R = Roy's largest root

              Source | Statistic        df    F(df1,     df2) =   F   Prob>F
          -----------+-------------------------------------------------------
                 sex |W   0.7399         1      3.0     23.0     2.70 0.0696 e
                     |P   0.2601                3.0     23.0     2.70 0.0696 e
                     |L   0.3516                3.0     23.0     2.70 0.0696 e
                     |R   0.3516                3.0     23.0     2.70 0.0696 e
                     +-------------------------------------------------------
            Residual |                  25
          -----------+-------------------------------------------------------
                       e = exact, a = approximate, u = upper bound on F

. * test of parallelism
. mat boygirl=(1,0,1\0,1,1)

. manovatest , test(boygirl) ytransf(timediff)

 Transformations of the dependent variables


(1)    dist08 - dist10


(2)    dist08 - dist12


(3)    dist08 - dist14


 Test constraints


(1)    0.sex + _cons = 0


(2)    1.sex + _cons = 0


                       W = Wilks' lambda      L = Lawley-Hotelling trace
                       P = Pillai's trace     R = Roy's largest root

              Source | Statistic        df    F(df1,     df2) =   F   Prob>F
          -----------+-------------------------------------------------------
          manovatest |W   0.1606         2      6.0     46.0    11.46 0.0000 e
                     |P   0.8622                6.0     48.0     6.06 0.0001 a
                     |L   5.0844                6.0     44.0    18.64 0.0000 a
                     |R   5.0563                3.0     24.0    40.45 0.0000 u
                     +-------------------------------------------------------
            Residual |                  25
          -----------+-------------------------------------------------------
                       e = exact, a = approximate, u = upper bound on F

. * test of no time differences
. mat boy=(1,0,1)

. mat girl=(0,1,1)

. manovatest , test(boy) ytransf(timediff)

 Transformations of the dependent variables


(1)    dist08 - dist10


(2)    dist08 - dist12


(3)    dist08 - dist14


 Test constraint


(1)    0.sex + _cons = 0


                       W = Wilks' lambda      L = Lawley-Hotelling trace
                       P = Pillai's trace     R = Roy's largest root

              Source | Statistic        df    F(df1,     df2) =   F   Prob>F
          -----------+-------------------------------------------------------
          manovatest |W   0.1938         1      3.0     23.0    31.89 0.0000 e
                     |P   0.8062                3.0     23.0    31.89 0.0000 e
                     |L   4.1602                3.0     23.0    31.89 0.0000 e
                     |R   4.1602                3.0     23.0    31.89 0.0000 e
                     +-------------------------------------------------------
            Residual |                  25
          -----------+-------------------------------------------------------
                       e = exact, a = approximate, u = upper bound on F

. manovatest , test(girl) ytransf(timediff)

 Transformations of the dependent variables


(1)    dist08 - dist10


(2)    dist08 - dist12


(3)    dist08 - dist14


 Test constraint


(1)    1.sex + _cons = 0


                       W = Wilks' lambda      L = Lawley-Hotelling trace
                       P = Pillai's trace     R = Roy's largest root

              Source | Statistic        df    F(df1,     df2) =   F   Prob>F
          -----------+-------------------------------------------------------
          manovatest |W   0.5197         1      3.0     23.0     7.09 0.0015 e
                     |P   0.4803                3.0     23.0     7.09 0.0015 e
                     |L   0.9242                3.0     23.0     7.09 0.0015 e
                     |R   0.9242                3.0     23.0     7.09 0.0015 e
                     +-------------------------------------------------------
            Residual |                  25
          -----------+-------------------------------------------------------
                       e = exact, a = approximate, u = upper bound on F

. * separate tests of no time differences for boys and girls
. lincom [dist08]0.sex-[dist08]1.sex+[dist10]0.sex-[dist10]1.sex+[dist12]0.sex-[dist12]1.sex+[dist14]0.sex-[dist14]1.sex


 ( 1)  [dist08]0b.sex - [dist08]1.sex + [dist10]0b.sex - [dist10]1.sex + [dist12]0b.sex - [dist12]1.sex + [dist14]0b.sex - [dist14]1.sex = 0


-------------+----------------------------------------------------------------
             |      Coef.    Std. Err.       t    P>|t|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
         (1) |    9.284091    3.045667      3.05    0.005      3.011421     15.55676
-------------+----------------------------------------------------------------

. * no group differences, assuming parallelism
. mat boyvgirl=(0,1,0)

. manovatest , test(boyvgirl) ytransf(timediff)

 Transformations of the dependent variables


(1)    dist08 - dist10


(2)    dist08 - dist12


(3)    dist08 - dist14


 Test constraint


(1)    1.sex = 0


                       W = Wilks' lambda      L = Lawley-Hotelling trace
                       P = Pillai's trace     R = Roy's largest root

              Source | Statistic        df    F(df1,     df2) =   F   Prob>F
          -----------+-------------------------------------------------------
          manovatest |W   0.7399         1      3.0     23.0     2.70 0.0696 e
                     |P   0.2601                3.0     23.0     2.70 0.0696 e
                     |L   0.3516                3.0     23.0     2.70 0.0696 e
                     |R   0.3516                3.0     23.0     2.70 0.0696 e
                     +-------------------------------------------------------
            Residual |                  25
          -----------+-------------------------------------------------------
                       e = exact, a = approximate, u = upper bound on F

. * test of parallism (same as in manova command
. tab sex

        sex |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |         16       59.26       59.26
          1 |         11       40.74      100.00
------------+-----------------------------------
      Total |         27      100.00

. manova dist08-dist14 = ibn.sex, nocons

                       Number of obs =         27

                       W = Wilks' lambda      L = Lawley-Hotelling trace
                       P = Pillai's trace     R = Roy's largest root

              Source | Statistic        df    F(df1,     df2) =   F   Prob>F
          -----------+-------------------------------------------------------
                 sex |W   0.0046         2      8.0     44.0    76.02 0.0000 e
                     |P   1.1932                8.0     46.0     8.50 0.0000 a
                     |L 175.2362                8.0     42.0   459.99 0.0000 a
                     |R 174.9879                4.0     23.0  1006.18 0.0000 u
                     +-------------------------------------------------------
            Residual |                  25
          -----------+-------------------------------------------------------
               Total |                  27
          -----------+-------------------------------------------------------
                       e = exact, a = approximate, u = upper bound on F

. mvreg

Equation             Obs   Parms        RMSE    "R-sq"          F        P
--------------------------------------------------------------------------
dist08                27       2    2.327113    0.9899    1228.67   0.0000
dist10                27       2    2.045672    0.9928   1733.324   0.0000
dist12                27       2    2.540815    0.9903   1273.933   0.0000
dist14                27       2    2.232877    0.9933    1850.94   0.0000

-------------+----------------------------------------------------------------
             |      Coef.    Std. Err.       t    P>|t|      [95% Con f. Interval]
-------------+----------------------------------------------------------------
dist08       |
         sex |
          0  |      22.875    .5817782     39.32    0.000      21.67681     24.07319
          1  |    21.18182    .7016509     30.19    0.000      19.73674      22.6269
-------------+----------------------------------------------------------------
dist10       |
         sex |
          0  |     23.8125    .5114179     46.56    0.000      22.75922     24.86578
          1  |    22.22727    .6167932     36.04    0.000      20.95696     23.49758
-------------+----------------------------------------------------------------
dist12       |
         sex |
          0  |    25.71875    .6352036     40.49    0.000      24.41052     27.02698
          1  |    23.09091    .7660844     30.14    0.000      21.51313     24.66869
-------------+----------------------------------------------------------------
dist14       |
         sex |
          0  |    27.46875    .5582192     49.21    0.000      26.31908     28.61842
          1  |    24.09091    .6732377     35.78    0.000      22.70435     25.47747
-------------+----------------------------------------------------------------

. mat paraltime=(.5926,.4074,-.5926,-.4074,0,0,0,0\.5926,.4074,0,0,-.5926,-.4074,0,0\.5926,.4074,0,0,0,0,-.5926,-.4074)

. test ,test(paraltime)


 ( 1)  .5926*[dist08]0bn.sex + .4074*[dist08]1.sex - .5926*[dist10]0bn.sex - .4074*[dist10]1.sex = 0


 ( 2)  .5926*[dist08]0bn.sex + .4074*[dist08]1.sex - .5926*[dist12]0bn.sex - .4074*[dist12]1.sex = 0


 ( 3)  .5926*[dist08]0bn.sex + .4074*[dist08]1.sex - .5926*[dist14]0bn.sex - .4074*[dist14]1.sex = 0


       F(  3,    25) =   39.44
            Prob > F =    0.0000


. * test for no time differences, assuming parallism
. * not quite the same as in lecture
.
end of do-file

. exit, clear