Download Help (Windows Only) |

Statistics Class Example See Also

Note: This topic applies to the following Measurement Studio editions: Enterprise. |

Performs a three-way analysis of variance.

**Namespace:**
NationalInstruments.Analysis.Math

**Assembly:**
NationalInstruments.Analysis.Enterprise (in NationalInstruments.Analysis.Enterprise.dll) Version: 12.0.40.318

Visual Basic (Declaration) |
---|

<SecurityPermissionAttribute(SecurityAction.Demand, Flags := SecurityPermissionFlag.UnmanagedCode)> _ Public Shared Function Anova3Way ( _ observations As Double(), _ levelAData As Integer(), _ levelBData As Integer(), _ levelCData As Integer(), _ observationsPerCell As Integer, _ numberOfLevelsInA As Integer, _ levelAEffect As AnovaModel, _ numberOfLevelsInB As Integer, _ levelBEffect As AnovaModel, _ numberOfLevelsInC As Integer, _ levelCEffect As AnovaModel _ ) As Statistics.Anova3WayOutput |

C# |
---|

[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] public static Statistics.Anova3WayOutput Anova3Way( double[] observations, int[] levelAData, int[] levelBData, int[] levelCData, int observationsPerCell, int numberOfLevelsInA, AnovaModel levelAEffect, int numberOfLevelsInB, AnovaModel levelBEffect, int numberOfLevelsInC, AnovaModel levelCEffect ) |

*observations*- Type:
System.Double
[]

The experimental observations.

*levelAData*- Type:
System.Int32
[]

The level of factor A to which the corresponding observation belongs.

*levelBData*- Type:
System.Int32
[]

The level of factor B to which the corresponding observation belongs.

*levelCData*- Type:
System.Int32
[]

The level of factor C to which the corresponding observation belongs.

*observationsPerCell*- Type: System.Int32

The total number of observations per cell.

*numberOfLevelsInA*- Type: System.Int32

The number of levels in factor A.

*levelAEffect*- Type: NationalInstruments.Analysis.Math.AnovaModel

The anova model used for factor A. This is a value from the AnovaModel enumeration.

*numberOfLevelsInB*- Type: System.Int32

The number of levels in factor B.

*levelBEffect*- Type: NationalInstruments.Analysis.Math.AnovaModel

The anova model used for factor B. This is a value from the AnovaModel enumeration.

*numberOfLevelsInC*- Type: System.Int32

The number of levels in factor C.

*levelCEffect*- Type: NationalInstruments.Analysis.Math.AnovaModel

The anova model used for factor C. This is a value from the AnovaModel enumeration.

The output of the three-way analysis of variance. This is specified using Statistics.Anova3WayOutput.

Exception | Condition |
---|---|

ArgumentException | The number of samples in levelAData is less than or equal to one. -or- The number of samples in levelBData is less than or equal to one. -or- The number of samples in levelCData is less than or equal to one. -or- The number of samples in observations is equal to zero. -or- The total number of data points is invalid. -or- The input data is unbalanced. |

ArgumentNullException | observations is null (Nothing in Visual Basic). -or- levelAData is null (Nothing in Visual Basic). -or- levelBData is null (Nothing in Visual Basic). -or- levelCData is null (Nothing in Visual Basic). |

DllNotFoundException | The analysis library cannot be found. |

EntryPointNotFoundException | A required operation in the analysis library cannot be found. |

InvalidOperationException | Level of factor is outside the allowable range. |

OutOfMemoryException | There is not enough memory to carry out this operation. |

Anova3Way takes an array of experimental observations made at various levels of three factors and performs a three-way analysis of variance.

In any ANOVA, you look for evidence that the factors or interactions among factors have a significant effect on experimental outcomes. What varies with each model is the method used to do this.

Refer to Random and Fixed Effects, General Method, Statistical Model, Assumptions, Hypothesis, Testing the Hypothesis, and Formulas for more information.

`sitUps `

represents how many sit-ups an individual performs in a
given time limit. The `age`

, `weight`

,
and `height `

arrays represent an individualâ€™s age, weight, and height.
The output of the two-way analysis of variance is stored in the variable, `output`

.
If `output.SignificanceA `

, `output.SignificanceB `

,
or `output.SignificanceC `

is larger than a threshold assigned
by the user, we should reject the hypothesis. This means `age `

, `weight `

,
or `height `

affect the number of situps an individual can do within a given time limit. If
`output.SignificanceAB `

,
`output.SignificanceAC `

, or
`output.SignificanceBC `

is larger than a threshold assigned
by the user, the hypothesis should be rejected.
This means that the interaction between age and weight, or the interaction between age and height, or the interaction between weight and height do affect the number of situps an individual can do in given time limit.
If `output.SignificanceABC `

is larger than a threshold assigned by the user, the hypothesis should be rejected. This means that the interaction among age, weight, and height do affect the number of situps an individual can do in a given time limit.

In order to use the Anova3Way method, at least two observation data are needed per cell, otherwise the function will return an error.

VB.NET

Dim numSamples As Integer = 16 Dim sitUps() As Double = {10, 15, 20, 25, 17, 4, 11, 12, 14, 25, 22, 20, 10, 8, 12, 14} Dim weight() As Double = {30, 40, 76, 60, 51, 80, 30, 42, 32, 45, 75, 65, 55, 75, 45, 40} Dim height() As Double = {1.32, 1.55, 1.75, 1.4, 1.62, 1.45, 1.52, 1.45, 1.35, 1.6, 1.7, 1.48, 1.52, 1.48, 1.51, 1.49} Dim age() As Integer = {8, 12, 15, 14, 9, 10, 10, 11, 9, 12, 14, 15, 8, 9, 9, 12} Dim ageLevel(numSamples) As Integer Dim weightLevel(numSamples) As Integer Dim heightLevel(numSamples) As Integer Dim maxAgeLevel, maxWeightLevel, maxHeightLevel As Integer Dim output As Statistics.Anova3WayOutput ' For age, we have the following levels: ' Level 0 - 6 years old to 10 years old ' Level 1 - 11 years old to 15 years old ' We are assuming all the data are between 6 and 15 years old. For i As Integer = 1 To age.Length - 1 If (age(i) <= 10) Then ageLevel(i) = 0 Else ageLevel(i) = 1 End If Next maxAgeLevel = 0 For i As Integer = 1 To ageLevel.Length - 1 If (maxAgeLevel < ageLevel(i)) Then maxAgeLevel = ageLevel(i) End If Next maxAgeLevel = maxAgeLevel + 1 ' For weight, we have the following levels: ' Level 0 - less that 50 kg ' Level 1 - greater than 50 kg For i As Integer = 1 To weight.Length - 1 If (weight(i) < 50.0) Then weightLevel(i) = 0 Else weightLevel(i) = 1 End If Next maxWeightLevel = 0 For i As Integer = 1 To weightLevel.Length - 1 If (maxWeightLevel < weightLevel(i)) Then maxWeightLevel = weightLevel(i) End If Next maxWeightLevel = maxWeightLevel + 1 ' For height, we have the following levels: ' Level 0 - less that 1.5m ' Level 1 - greater than 1.5m For i As Integer = 1 To weight.Length - 1 If (height(i) < 1.5) Then heightLevel(i) = 0 Else heightLevel(i) = 1 End If Next maxHeightLevel = 0 For i As Integer = 1 To heightLevel.Length - 1 If (maxHeightLevel < heightLevel(i)) Then maxHeightLevel = heightLevel(i) End If Next maxHeightLevel = maxHeightLevel + 1 ' Perform a three-way analysis of variance on an array, sitUps. The array consists of experimental observations made at various levels of three factors, ageLevel, weightLevel, and heightLevel. output = Statistics.Anova3Way(sitUps, ageLevel, weightLevel, heightLevel, 2, maxAgeLevel, AnovaModel.RandomEffect, maxWeightLevel, AnovaModel.RandomEffect, maxHeightLevel, AnovaModel.RandomEffect)

C#

int samples = 16; double[] sitUps = new double[] { 10, 15, 20, 25, 17, 4, 11, 12, 14, 25, 22, 20, 10, 8, 12, 14 }; double[] weight = new double[] { 30, 40, 76, 60, 51, 80, 30, 42, 32, 45, 75, 65, 55, 75, 45, 40 }; double[] height = new double[] { 1.32, 1.55, 1.75, 1.40, 1.62, 1.45, 1.52, 1.45, 1.35, 1.60, 1.70, 1.48, 1.52, 1.48, 1.51, 1.49 }; int[] age = new int[] { 8, 12, 15, 14, 9, 10, 10, 11, 9, 12, 14, 15, 8, 9, 9, 12 }; int[] ageLevel = new int[samples]; int[] weightLevel = new int[samples]; int[] heightLevel = new int[samples]; int maxAgeLevel, maxWeightLevel, maxHeightLevel; Statistics.Anova3WayOutput output = new Statistics.Anova3WayOutput(); // For age, we have the following levels: // Level 0 - 6 years old to 10 years old // Level 1 - 11 years old to 15 years old // We are assuming all the data are between 6 and 15 years old. for (int i = 0; i < age.Length; i++) { if (age[i] <= 10) ageLevel[i] = 0; else ageLevel[i] = 1; } maxAgeLevel = 0; for (int i = 0; i < ageLevel.Length; i++) { if (maxAgeLevel < ageLevel[i]) maxAgeLevel = ageLevel[i]; } maxAgeLevel++; // For weight, we have the following levels: // Level 0 - less that 50 kg // Level 1 - greater than 50 kg for (int i = 0; i < weight.Length; i++) { if (weight[i] < 50.0) weightLevel[i] = 0; else weightLevel[i] = 1; } maxWeightLevel = 0; for (int i = 0; i < weightLevel.Length; i++) { if (maxWeightLevel < weightLevel[i]) maxWeightLevel = weightLevel[i]; } maxWeightLevel++; // For height, we have the following levels: // Level 0 - less that 1.5m // Level 1 - greater than 1.5m for (int i = 0; i < heightLevel.Length; i++) if (height[i] < 1.5) heightLevel[i] = 0; else heightLevel[i] = 1; maxHeightLevel = 0; for (int i = 0; i < heightLevel.Length; i++) { if (maxHeightLevel < heightLevel[i]) maxHeightLevel = heightLevel[i]; } maxHeightLevel++; // Perform a three-way analysis of variance on an array, sitUps. The array consists of experimental observations made at various levels of three factors, ageLevel, weightLevel and heightLevel. output = Statistics.Anova3Way(sitUps, ageLevel, weightLevel, heightLevel, 2, maxAgeLevel, AnovaModel.RandomEffect, maxWeightLevel, AnovaModel.RandomEffect, maxHeightLevel, AnovaModel.RandomEffect);

- SecurityPermission for the ability to access unmanaged code.

Helpful

Not Helpful