Navigate to the folder containing sample data.

Load the sample data.

The matrix `Y`

contains response data for 16
individuals. The response is the blood level of a drug measured at
five time points (time = 0, 2, 4, 6, and 8). Each row of `Y`

corresponds
to an individual, and each column corresponds to a time point. The
first eight subjects are female, and the second eight subjects are
male. This is simulated data.

Define a variable that stores gender information.

Store the data in a proper table array format to do repeated
measures analysis.

Define the within-subjects variable.

Fit a repeated measures model, where blood levels are
the responses and gender is the predictor variable.

Perform analysis of variance.

anovatbl =
Within Between SumSq DF MeanSq F pValue
________ ________ ______ __ ______ ______ __________
Constant constant 54702 1 54702 1079.2 1.1897e-14
Constant Gender 2251.7 1 2251.7 44.425 1.0693e-05
Constant Error 709.6 14 50.685

There are 2 genders and 16 observations, so the degrees of freedom
for gender is (2 –1) = 1 and for error it is (16 – 2)*(2
– 1) = 14. The small *p*-value of 1.0693e-05
indicates that there is a significant effect of gender on blood pressure.

Repeat analysis of variance using orthogonal contrasts.

anovatbl =
Within Between SumSq DF MeanSq F pValue
________ ________ __________ __ __________ __________ __________
Constant constant 54702 1 54702 1079.2 1.1897e-14
Constant Gender 2251.7 1 2251.7 44.425 1.0693e-05
Constant Error 709.6 14 50.685
Time constant 310.83 1 310.83 31.023 6.9065e-05
Time Gender 13.341 1 13.341 1.3315 0.26785
Time Error 140.27 14 10.019
Time^2 constant 565.42 1 565.42 98.901 1.0003e-07
Time^2 Gender 1.4076 1 1.4076 0.24621 0.62746
Time^2 Error 80.039 14 5.7171
Time^3 constant 2.6127 1 2.6127 1.4318 0.25134
Time^3 Gender 7.8853e-06 1 7.8853e-06 4.3214e-06 0.99837
Time^3 Error 25.546 14 1.8247
Time^4 constant 2.8404 1 2.8404 0.47924 0.50009
Time^4 Gender 2.9016 1 2.9016 0.48956 0.49559
Time^4 Error 82.977 14 5.9269