Load the sample data.

The column vector `species`

consists of iris
flowers of three different species: setosa, versicolor, and virginica.
The double matrix `meas`

consists of four types of
measurements on the flowers: the length and width of sepals and petals
in centimeters, respectively.

Store the data in a table array.

Fit a repeated measures model where the measurements are
the responses and the species is the predictor variable.

Perform analysis of variance.

ans =
Within Between SumSq DF MeanSq F pValue
________ ________ ______ ___ _______ ______ ___________
Constant constant 7201.7 1 7201.7 19650 2.0735e-158
Constant species 309.61 2 154.8 422.39 1.1517e-61
Constant Error 53.875 147 0.36649

There are 150 observations and 3 species. The degrees of freedom
for species is 3 – 1 = 2, and for error it is 150 –
3 = 147. The small *p*-value of 1.1517e-61 indicates
that the measurements differ significantly according to species.

Navigate to the folder containing sample data.

Load the sample panel data.

The dataset array, `panelData`

, contains yearly
observations on eight cities for 6 years. The first variable, `Growth`

,
measures economic growth (the response variable). The second and third
variables are city and year indicators, respectively. The last variable, `Employ`

,
measures employment (the predictor variable). This is simulated data.

Store the data in a table array and define city as a nominal
variable.

Convert the data in a proper format to do repeated measures
analysis.

Add the mean employment level over the years as a predictor
variable to the table `t`

.

Define the within-subjects variable.

Fit a repeated measures model, where the growth figures
over the 6 years are the responses and the mean employment is the
predictor variable.

Perform analysis of variance.

anovatbl =
Within Between SumSq DF MeanSq F pValue
_________ __________ __________ __ __________ ________ _________
Contrast1 constant 588.17 1 588.17 0.038495 0.85093
Contrast1 meanEmploy 3.7064e+05 1 3.7064e+05 24.258 0.0026428
Contrast1 Error 91675 6 15279

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