Click or drag to resize
Accord.NET (logo)

TwoWayAnova Class

Two-way Analysis of Variance.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.TestingTwoWayAnova

Namespace:  Accord.Statistics.Testing
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class TwoWayAnova : IAnova
Request Example View Source

The TwoWayAnova type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyFirstFactorSamples
Gets the number of samples presenting the first factor.
Public propertyModelType
Gets or sets the type of the model.
Public propertyObservations
Gets the number of observations in the sample.
Public propertyReplications
Gets the number of replications of each factor.
Public propertySecondFactorSamples
Gets the number of samples presenting the second factor.
Public propertySources
Gets or sets the variation sources obtained in the analysis.
Public propertyTable
Gets the ANOVA results in the form of a table.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

The two-way ANOVA is an extension of the one-way ANOVA for two independent variables. There are three classes of models which can also be used in the analysis, each of which determining the interpretation of the independent variables in the analysis.

References:

Examples
// Example by J. Jones, Professor of Mathematics in Richland Community 
// College: https://people.richland.edu/james/lecture/m170/ch13-2wy.html

// In this example, we collected the number of successfully grown corn plants 
// given the use of 4 types of fertilizer, and 3 different types of seed.

double[,,] samples =
{
//                    Fert I        Fert II       Fert III        Fert IV        Fert V
/* Seed A-402 */ { { 106, 110 },  { 95, 100 },  { 94,  107 },  { 103, 104 },  { 100, 102 } },
/* Seed B-894 */ { { 110, 112 },  { 98,  99 },  { 100, 101 },  { 108, 112 },  { 105, 107 } },
/* Seed C-952 */ { { 94,  97  },  { 86,  87 },  { 98,   99 },  {  99, 101 },  {  94,  98 } },
};

// There are always three hypothesis in a 2-way ANOVA:
// - There is no difference between population means for the first factor;
// - There is no difference between population means for the second factor;
// - There is no interaction between the two different factors

// Let's create a mixed-effect effects ANOVA model (ANOVA model 3)
var twoWayAnova = new TwoWayAnova(samples, TwoWayAnovaModel.Mixed);

// Now, we can obtain the test summary table by using:
TwoWayAnovaVariationSources sources = twoWayAnova.Sources;

// Seed source of variation
double seedSS = sources.FactorA.SumOfSquares;                               // 512.86666666666713
double seedDF = sources.FactorA.DegreesOfFreedom;                           // 2
double seedMS = sources.FactorA.MeanSquares;                                // 256.43333333333356
double seedF = sources.FactorA.Statistic.Value;                             // 28.283088235294144
double seedPValue = sources.FactorA.Significance.PValue;                    // 8.1353422904297046E-06
double seedCrit = sources.FactorA.Significance.CriticalValue;               // 3.6823203436732341
bool seedSignificant = sources.FactorA.Significance.Significant;            // true

// Fertilizer source of variation                                           
double fertilizerSS = sources.FactorB.SumOfSquares;                         // 449.46666666666607
double fertilizerDF = sources.FactorB.DegreesOfFreedom;                     // 4
double fertilizerMS = sources.FactorB.MeanSquares;                          // 112.36666666666652
double fertilizerF = sources.FactorB.Statistic.Value;                       // 12.39338235294116
double fertilizerPValue = sources.FactorB.Significance.PValue;              // 0.00011887234971294213
double fertilizerCrit = sources.FactorB.Significance.CriticalValue;         // 3.0555682759065936
bool fertilizerSignificant = sources.FactorB.Significance.Significant;      // true

// Interaction source of variation
double interactionSS = sources.Interaction.SumOfSquares;                    // 143.1333333333335
double interactionDF = sources.Interaction.DegreesOfFreedom;                // 8
double interactionMS = sources.Interaction.MeanSquares;                     // 17.891666666666687
double interactionF = sources.Interaction.Statistic.Value;                  // 1.9733455882352964
double interactionPValue = sources.Interaction.Significance.PValue;         // 0.12208995001760085
double interactionCrit = sources.Interaction.Significance.CriticalValue;    // 2.6407968829069017
bool interactionSignificant = sources.Interaction.Significance.Significant; // false

// Within-variance source of variation
double withinSS = sources.Error.SumOfSquares;                               // 136
double withinDF = sources.Error.DegreesOfFreedom;                           // 15
double withinMS = sources.Error.MeanSquares;                                // 9.0666666666666664
See Also