**44.2****
****One-Way Repeated Measures ANOVA** (.NET, C#, CSharp, VB, Visual Basic, F#)

Class **OneWayRanova** calculates and
summarizes the information of a one-way repeated measures analysis of variance
(RANOVA).

**Creating One-Way RANOVA Objects**

A **OneWayRanova**
instance is constructed from numeric data for multiple treatments applied
to each experimental subject. For example, this code constructs a **OneWayRanova** from a **DoubleMatrix**:

Code Example – C# RANOVA

var data = new DoubleMatrix( "8x4 [ 180 200 160 200

230 250 200 220

280 310 260 270

180 200 160 200

190 210 170 210

140 160 120 110

270 300 250 260

110 130 100 100 ]" );

var ranova = new OneWayRanova( data );

Code Example – VB RANOVA

Dim Data As New DoubleMatrix("8x4 [ 180 200 160 200

230 250 200 220

280 310 260 270

180 200 160 200

190 210 170 210

140 160 120 110

270 300 250 260

110 130 100 100 ]")

Dim Ranova As New OneWayRanova(Data)

Each row of the matrix contains the data for an individual subject. There should be one column for each treatment. The example above shows 4 different measurements for each of 8 subjects.

**NOTE—****Data
rows containing missing values (NaNs) are ignored by class OneWayRanova.**

Similarly, you can also construct a **OneWayRanova** from a **DataFrame**:

Code Example – C# RANOVA

var ranova = new OneWayRanova( df );

Code Example – VB RANOVA

Dim Ranova As New OneWayRanova(DF)

Each row in the **DataFrame**
contains the data for an individual subject. There should be one column
for each treatment.

Note that all numeric columns in the given **DataFrame** are interpreted as treatments;
only non-numeric columns are ignored. If you have numeric columns in
the data frame that you also wish to ignore, apply the appropriate **Subset** first. For instance:

Code Example – C# RANOVA

var colIndices = new Subset( new int[] { 3, 14, 5, 8, 4 } );

var ranova = new OneWayRanova( df.GetColumns( colIndices ) );

Code Example – VB RANOVA

Dim ColIndices As New Subset(New Integer() {3, 14, 5, 8, 4})

Dim Ranova As New OneWayRanova(DF.GetColumns(ColIndices))

Once you've constructed a **OneWayRanova**,
you can display the complete RANOVA table:

Code Example – C# RANOVA

Console.WriteLine( ranova );

Code Example – VB RANOVA

Console.WriteLine(Ranova)

For example:

Source Deg of Freedom Sum Of Sq Mean Square F P

Subjects 9 102822.5000 11424.7222 . .

Treatment 3 9247.5000 3082.5000 31.6755 0.0000

Error 27 2627.5000 97.3148 . .

Total 39 114697.5000 2940.9615 . .

Class **OneWayRanovaTable** is provided
for summarizing the information in a traditional one-way RANOVA table.
Class **OneWayRanovaTable** derives
from **DataFrame**. An instance of
**OneWayRanovaTable** can be obtained
from a **OneWayRanova** object using
the RanovaTable property. For example:

Code Example – C# RANOVA

OneWayRanovaTable myTable = ranova.RanovaTable;

Code Example – VB RANOVA

Dim MyTable As OneWayRanovaTable = Ranova.RanovaTable

Class **OneWayRanovaTable**
provides the following read-only properties for accessing individual
elements in the RANOVA table:

● DegreesOfFreedomTreatment gets the treatment degrees of freedom.

● DegreesOfFreedomWithinSubject gets the within-subject degrees of freedom.

● DegreesOfFreedomError gets the error degrees of freedom.

● DegreesOfFreedomTotal gets the total degrees of freedom.

● SumOfSquaresTreatment gets the treatment sum of squares.

● SumOfSquaresWithinSubject gets the within-subject sum of squares.

● SumOfSquaresTotal gets the total sum of squares.

● SumOfSquaresError gets the error sum of squares.

● MeanSquareTreatment gets the treatment mean square.

● MeanSquareWithinSubject gets the within-subject mean square.

● MeanSquareError gets the error mean square.

● MeanSquareTotal gets the total mean square.

● FStatistic gets the F statistic for the RANOVA.

● FStatisticPValue gets the p-value for the F statistic.

**Grand Mean, Subject Means, and Treatment Means**

Class **OneWayRanova**
provides properties for retrieving the grand mean, subject means, and treatment means:

● GrandMean gets the grand mean of the data. The grand mean is the mean of all of the data.

● SubjectMeans gets a vector of means for each subject.

● TreatmentMeans gets a vector of means for each treatment.

**Critical Value of the F Statistic**

Class **OneWayRanova**
provides the convenience function FStatisticCriticalValue()
which computes the critical value for the RANOVA F statistic at a
given significance level. Thus:

Code Example – C# RANOVA

double alpha = 0.01;

double critVal = ranova.FStatisticCriticalValue( alpha );

Code Example – VB RANOVA

Dim Alpha As Double = 0.01

Dim CritVal As Double = Ranova.FStatisticCriticalValue(Alpha)

**Updating One-Way RANOVA Objects**

Method SetData() updates an entire repeated measures analysis of variance object with new data. As with the class constructors (see above), you can supply data as a matrix or as a data frame. For instance, this code updates a RANOVA with data from matrix A:

Code Example – C# RANOVA

ranova.SetData( A );

Code Example – VB RANOVA

Ranova.SetData(A)