Download Help (Windows Only) |
Statistics Class Example See Also
Note: This topic applies to the following Measurement Studio editions: Enterprise. |
Performs a two-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 Anova2Way ( _ observations As Double(), _ levelAData As Integer(), _ levelBData As Integer(), _ observationsPerCell As Integer, _ numberOfLevelsInA As Integer, _ levelAEffect As AnovaModel, _ numberOfLevelsInB As Integer, _ levelBEffect As AnovaModel _ ) As Statistics.Anova2WayOutput |
C# |
---|
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] public static Statistics.Anova2WayOutput Anova2Way( double[] observations, int[] levelAData, int[] levelBData, int observationsPerCell, int numberOfLevelsInA, AnovaModel levelAEffect, int numberOfLevelsInB, AnovaModel levelBEffect ) |
The output of the two-way analysis of variance. This is specified using Statistics.Anova2WayOutput.
Exception | Condition |
---|---|
AnalysisException | The random effect model was requested when the fixed effect model is required. |
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 observations is equal to zero. -or- The input data is unbalanced. -or- Random effect model was requested when the fixed effect model is required. |
ArgumentNullException |
observations is null (Nothing in Visual Basic). -or- levelAData is null (Nothing in Visual Basic). -or- levelBData 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. |
Refer to Factors, Levels, and Cells, 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.
The age
and weight
arrays represent an individualâ€™s age and weight.
The output of the two-way analysis of variance is stored in the variable, output
.
If output.SignificanceA
or output.SignificanceB
is larger than a threshold assigned by the user,
we should reject the hypothesis. This means age or weight do affect the number of situps an individual can do in a given time limit.
Dim sitUps() As Double = {10, 15, 20, 25, 17, 4} Dim weight() As Double = {30.0, 40.0, 76.0, 60.0, 51.0, 80.0} Dim age() As Integer = {8, 12, 15, 14, 9, 10} Dim ageLevel(5) As Integer Dim weightLevel(5) As Integer Dim maxAgeLevel, maxWeightLevel As Integer Dim output As Statistics.Anova2WayOutput ' 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 - between 50 kg and 75 kg ' Level 2 - more than 75 kg For i As Integer = 1 To weight.Length - 1 If (weight(i) < 50.0) Then weightLevel(i) = 0 ElseIf (weight(i) <entity value="gt" />= 50.0 And weight(i) <= 75.0) Then weightLevel(i) = 1 Else weightLevel(i) = 2 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 ' Perform a two-way analysis of variance on an array, sitUps. The array consists of experimental observations made at various levels of two factors, ageLevel and weightLevel. output = Statistics.Anova2Way(sitUps, ageLevel, weightLevel, 1, maxAgeLevel, AnovaModel.FixedEffect, maxWeightLevel, AnovaModel.FixedEffect)
double[] sitUps = new double[] { 10, 15, 20, 25, 17, 4 }; double[] weight = new double[] { 30.0, 40.0, 76.0, 60.0, 51.0, 80.0 }; int[] age = new int[] { 8, 12, 15, 14, 9, 10 }; int[] ageLevel = new int[6]; int[] weightLevel = new int[6]; int maxAgeLevel, maxWeightLevel; Statistics.Anova2WayOutput output = new Statistics.Anova2WayOutput(); // 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 - between 50 kg and 75 kg // Level 2 - more than 75 kg for (int i = 0; i < weight.Length; i++) { if (weight[i] < 50.0) weightLevel[i] = 0; else if (weight[i] <entity value="gt" />= 50.0 <entity value="amp" /><entity value="amp" /> weight[i] <= 75.0) weightLevel[i] = 1; else weightLevel[i] = 2; } maxWeightLevel = 0; for (int i = 0; i < weightLevel.Length; i++) { if (maxWeightLevel < weightLevel[i]) maxWeightLevel = weightLevel[i]; } maxWeightLevel++; // Perform a two-way analysis of variance on an array, sitUps. The array consists of experimental observations made at various levels of two factors, ageLevel and weightLevel. output = Statistics.Anova2Way(sitUps, ageLevel, weightLevel, 1, maxAgeLevel, AnovaModel.FixedEffect, maxWeightLevel, AnovaModel.FixedEffect);
Helpful
Not Helpful