BalancedSample: Boolean;
BalancedSample: boolean;
The BalancedSample property determines, which observations are used to estimate correlation coefficients.
This property is relevant if the following method of missing data treatment is used: MissingDataMethod.Casewise. The method of missing data treatment is selected in the ISmPairCorrelation.MissingData property.
Available Values of BalancedSample:
True. Default value. All the observations that contain missing data in at least one variable are excluded from calculation.
False. Correlation coefficients are estimated using all available data.
Add a link to the Stat system assembly.
Sub UserProc;
Var
pc: SmPairCorrelation;
m: Array[4, 4] Of Double;
w: Array[4] Of Double;
res, i, j: Integer;
PairCorr: Array Of Double;
Begin
pc := New SmPairCorrelation.Create;
// Set initial data
m[0, 0] := 10; m[0, 1] := 1; m[0, 2] := 62; m[0, 3] := -3;
m[1, 0] := 30; m[1, 1] := 2; m[1, 2] := 32; m[1, 3] := Double.Nan;
m[2, 0] := 3; m[2, 1] := 3; m[2, 2] := 22; m[2, 3] := -3;
m[3, 0] := 77; m[3, 1] := 4; m[3, 2] := 21; m[3, 3] := 3;
pc.Data := m;
// Set missing data treatment method
pc.MissingData.Method := MissingDataMethod.Casewise;
// Set weights vector
w[0] := 1; w[1] := 2; w[2] := 2.2; w[3] := 0.5;
pc.Weights := w;
// Determine data that will be used to estimate correlation
pc.BalancedSample := False;
// Run calculation and show results
res := pc.Execute;
If res <> 0 Then
Debug.Write(pc.Errors);
Else
Debug.WriteLine("Matrix of paired correlation coefficients:");
Debug.Indent;
For i := 0 To pc.PairCorrelationMatrix.GetUpperBound(1) Do
For j := 0 To pc.PairCorrelationMatrix.GetUpperBound(2) Do
PairCorr := pc.PairCorrelationMatrix;
Debug.Write(PairCorr[i, j].ToString + ", ");
End For;
Debug.WriteLine(" ");
End For;
Debug.Unindent;
End If;
End Sub UserProc;
After executing the example the console window displays matrix of paired correlation coefficients.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Stat;
…
Public Shared Sub Main(Params: StartParams);
Var
pc: SmPairCorrelation;
m: Array[4, 4] Of Double;
w: Array[4] Of Double;
res, i, j: Integer;
PairCorr: Array;
Begin
pc := New SmPairCorrelation.Create();
// Set initial data
m[0, 0] := 10; m[1, 0] := 1; m[2, 0] := 62; m[3, 0] := -3;
m[0, 1] := 30; m[1, 1] := 2; m[2, 1] := 32; m[3, 1] := Double.Nan;
m[0, 2] := 3; m[1, 2] := 3; m[2, 2] := 22; m[3, 2] := -3;
m[0, 3] := 77; m[1, 3] := 4; m[2, 3] := 21; m[3, 3] := 3;
pc.Data := m;
// Set missing data treatment method
pc.MissingData.Method := MissingDataMethod.mdmCasewise;
// Set weights vector
w[0] := 1; w[1] := 2; w[2] := 2.2; w[3] := 0.5;
pc.Weights := w;
// Determine data that will be used to estimate correlation
pc.BalancedSample := False;
// Run calculation and show results
res := pc.Execute();
If res <> 0 Then
System.Diagnostics.Debug.Write(pc.Errors);
Else
System.Diagnostics.Debug.WriteLine("Matrix of paired correlation coefficients: ");
System.Diagnostics.Debug.Indent();
For i := 0 To pc.PairCorrelationMatrix.GetUpperBound(1) Do
For j := 0 To pc.PairCorrelationMatrix.GetUpperBound(0) Do
PairCorr := pc.PairCorrelationMatrix;
System.Diagnostics.Debug.Write(PairCorr[j, i].ToString() + ", ");
End For;
System.Diagnostics.Debug.WriteLine(" ");
End For;
System.Diagnostics.Debug.Unindent();
End If;
End Sub;
After executing the example the console window displays paired correlation coefficients.
See also: