ISmVarianceAnalysis.DegreeOfFreedom

Syntax

DegreeOfFreedom: IVarianceAnalysisDegreeOfFreedom;

Description

The DegreeOfFreedom property returns the number of degrees of freedom.

Example

Sub Main;

Var

VA: SmVarianceAnalysis;

res: Integer;

m: Array Of Double;

SS: IVarianceAnalysisSumSquared;

DF: IVarianceAnalysisDegreeOfFreedom;

UE: IVarianceAnalysisUnbiasedEstimation;

FS, FC, P: IVarianceAnalysisStatistics;

Begin

VA := New SmVarianceAnalysis.Create;

m := New Double[5, 3];

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.TwoFactor; // two-factor analysis

VA.ConfidenceLevel := 0.05;

res := VA.Execute;

If res <> 0 Then

Debug.WriteLine(VA.Errors);

Else

Debug.AssertMsg(False,"Results: ");

Debug.WriteLine("Sum of deviation squares");

SS := VA.SumSquared;

Debug.WriteLine("rows : " + SS.Rows.ToString);

Debug.WriteLine("columns : " + SS.Columns.ToString);

Debug.WriteLine("accuracy : " + SS.Accuracy.ToString);

Debug.WriteLine("Total: " + SS.Total.ToString);

Debug.WriteLine("=================================");

Debug.WriteLine("Number of degrees of freedom");

DF := VA.DegreeOfFreedom;

Debug.WriteLine("rows : " + DF.Rows.ToString);

Debug.WriteLine("columns : " + DF.Columns.ToString);

Debug.WriteLine("accuracy : " + DF.Accuracy.ToString);

Debug.WriteLine("total: " + DF.Total.ToString);

Debug.WriteLine("=================================");

Debug.WriteLine("Unbiased estimated sum of deviation squares");

UE := VA.UnbiasedEstimation;

Debug.WriteLine("rows : " + UE.Rows.ToString);

Debug.WriteLine("columns : " + UE.Columns.ToString);

Debug.WriteLine("accuracy : " + UE.Accuracy.ToString);

Debug.WriteLine("=================================");

Debug.WriteLine("Fisher statistics value");

FS := VA.FisherStatistics;

Debug.WriteLine("rows : " + FS.Rows.ToString);

Debug.WriteLine("columns : " + FS.Columns.ToString);

Debug.AssertMsg(False,"=================================");

Debug.WriteLine("Fisher statistics critical value");

FC := VA.FisherCritical;

Debug.WriteLine("rows : " + FC.Rows.ToString);

Debug.WriteLine("columns : " + FC.Columns.ToString);

Debug.WriteLine("=================================");

Debug.WriteLine("Probability");

P := VA.Probability;

Debug.WriteLine("rows : " + P.Rows.ToString);

Debug.WriteLine("columns : " + P.Columns.ToString);

If VA.VarianceEqualByRows Then

Debug.WriteLine("Fstat < Fcrit. Hypothesis on the equality of A factor variances (for rows) is accepted. Variance difference is insignificant");

Else

Debug.WriteLine("Fstat > Fcrit. Hypothesis on the equality of A factor variances (by rows) is rejected. The variance difference is significant");

End If;

If VA.VarianceEqualByColumns Then

Debug.WriteLine("Fstat < Fcrit. Hypothesis on the equality of B factor variances (for columns) is accepted. Variance difference is insignificant");

Else

Debug.WriteLine("Fstat > Fcrit. The hypothesis on the equality of B factor variances (by columns) has been rejected. The variance difference is significant");

End If;

End If;

End Sub Main;

Executing the example displays the results of the variance analysis in the console window:

Module execution started

Results:

Sum of deviation squares

Rows: 0.26666666666666694

Columns: 6.5333333333333341

Error: 18.133333333333297

Total: 24.933333333333326

=================================

Number of degrees of freedom

Rows: 4

Columns: 2

Error: 8

Total: 14

=================================

Unbiased estimated sum of deviation squares

Rows: 0.066666666666666735

Columns: 3.2666666666666671

Error: 2.2666666666666622

=================================

Fisher statistics value

Rows: 0.029411764705882443

Columns: 1.4411764705882384

=================================

Fisher statistics critical value

Rows: 3.837853326929805

Columns: 4.4589684100858102

=================================

Probability

Rows: 0.99691358024691357

Columns: 0.44880624426078908

Fstat < Fcrit. Hypothesis on the equality of A factor variances (for rows) is accepted. The variance difference is insignificant

Fstat < Fcrit. Hypothesis on the equality of B factor variances (for columns) is accepted. The variance difference is insignificant

Module execution finished

See also:

ISmVarianceAnalysis