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.
To execute the example, 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.
See also: