AnalysisType: VarianceAnalysisType;
The AnalysisType property determines the type of variance analysis.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
VA: ISmVarianceAnalysis;
res: Integer;
m: Array[5, 3] Of Double;
SS: IVarianceAnalysisSumSquared;
DF: IVarianceAnalysisDegreeOfFreedom;
UE: IVarianceAnalysisUnbiasedEstimation;
FS, FC, P: IVarianceAnalysisStatistics;
Begin
VA := New SmVarianceAnalysis.Create;
m[0, 0] := 1; m[0, 1] := 4; m[0, 2] := 1;
m[1, 0] := 2; m[1, 1] := 3; m[1, 2] := 2;
m[2, 0] := 3; m[2, 1] := 3; m[2, 2] := 1;
m[3, 0] := 4; m[3, 1] := 1; m[3, 2] := 2;
m[4, 0] := 5; m[4, 1] := 1; m[4, 2] := 1;
VA.Data := m;
VA.AnalysisType := VarianceAnalysisType.SingleFactor; //single-factor analysis
VA.ConfidenceLevel := 0.05;
res := VA.Execute;
If res <> 0 Then
Debug.WriteLine(VA.Errors);
Else
Debug.WriteLine("Results: ");
Debug.WriteLine("Sum of deviation squares");
SS := VA.SumSquared;
Debug.Indent;
Debug.WriteLine("between groups: " + SS.BetweenGroup.ToString);
Debug.WriteLine("within a group: " + SS.WithinGroup.ToString);
Debug.WriteLine("total: " + SS.Total.ToString);
Debug.Unindent;
Debug.WriteLine("Number of degrees of freedom");
DF := VA.DegreeOfFreedom;
Debug.Indent;
Debug.WriteLine("between groups: " + DF.BetweenGroup.ToString);
Debug.WriteLine("within a group: " + DF.WithinGroup.ToString);
Debug.WriteLine("total: " + DF.Total.ToString);
Debug.Unindent;
Debug.WriteLine("Unbiased estimate of sum of deviation squares");
UE := VA.UnbiasedEstimation;
Debug.Indent;
Debug.WriteLine("between groups: " + UE.BetweenGroup.ToString);
Debug.WriteLine("within groups: " + UE.WithinGroup.ToString);
Debug.Unindent;
Debug.WriteLine("Value of Fisher statistics ");
FS := VA.FisherStatistics;
Debug.WriteLine(FS.OneFactorAnalysis.ToString);
Debug.WriteLine("Critical value of Fisher statistics ");
FC := VA.FisherCritical;
Debug.WriteLine(FC.OneFactorAnalysis.ToString);
Debug.WriteLine("Probability ");
P := VA.Probability;
Debug.WriteLine(P.OneFactorAnalysis.ToString);
If VA.VarianceEqualByRows Then
Debug.WriteLine("Fstat < Fcrit. Hypothesis on equal group averages is accepted");
Else
Debug.WriteLine("Fstat > Fcrit. Hypothesis on equal group averages is rejected");
End If;
End If;
End Sub UserProc;
Executing the example displays the results of the variance analysis in the console window:
Sum of deviation squares
between groups: 0,266666666666667
within groups: 24,6666666666667
sum: 24,9333333333333
Number of degrees of freedom
between groups: 4
within groups: 10
sum: 14
Unbiased estimated sum of deviation squares
between groups: 0,0666666666666667
within groups: 2,46666666666667
Fisher statistics value: 0,027027027027027
Fisher statistics critical value: 3,47804969076512
Probability: 0,99833254475293
Fstat < Fcrit. Hypothesis on the equality of group means is accepted.
See also: