ISmPrincipalComponentAnalysis.VAdj

Syntax

VAdj: Array;

Description

The VAdj property returns the principal component values calculated as linear combinations of source series and eigenvectors.

Example

Sub Main;

Var

pc: SmPrincipalComponentAnalysis;

Obj: ISlSeries;

d0, d1, d2: Double;

i, res: Integer;

ar1,ar2,ar3: Array Of Double;

Begin

pc := New SmPrincipalComponentAnalysis.Create;

pc.MissingData.Method := MissingDataMethod.AnyValue;

ar1 := New Double[10];

ar2 := New Double[10];

ar3 := New Double[10];

// values ar1, ar2, ar3

ar1[0] := 7.0000; ar2[0] := 4.0000; ar3[0] := 3.0000;

ar1[1] := 4.0000; ar2[1] := 1.0000; ar3[1] := 8.0000;

ar1[2] := 6.0000; ar2[2] := 3.0000; ar3[2] := 5.0000;

ar1[3] := 8.0000; ar2[3] := 6.0000; ar3[3] := 1.0000;

ar1[4] := 8.0000; ar2[4] := 5.0000; ar3[4] := 7.0000;

ar1[5] := 7.0000; ar2[5] := 2.0000; ar3[5] := 9.0000;

ar1[6] := 5.0000; ar2[6] := 3.0000; ar3[6] := 3.0000;

ar1[7] := 9.0000; ar2[7] := 5.0000; ar3[7] := 8.0000;

ar1[8] := 7.0000; ar2[8] := 4.0000; ar3[8] := 5.0000;

ar1[9] := 8.0000; ar2[9] := 2.0000; ar3[9] := 2.0000;

Obj := pc.Objects;

Obj.Add.Value := ar1;

Obj.Add.Value := ar2;

Obj.Add.Value := ar3;

pc.Analysis.Type := AnalysisType.Correlation;

pc.ScoreType := PCAScoreType.Stand;

res := pc.Execute;

If res <> 0 Then

Debug.WriteLine(pc.Errors);

Else

Debug.WriteLine("Eigenvectors: ");

For i := 1 To 3 Do

d0 := pc.P[0, i - 1];

d1 := pc.P[1, i - 1];

d2 := pc.P[2, i - 1];

Debug.AssertMsg(False, "Principal component №" + i.ToString + ": " + d0.ToString + " " + d1.ToString + " " + d2.ToString);

End For;

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

Debug.WriteLine("Principal component values: ");

Debug.WriteLine(" = V = ");

Debug.AssertMsg(False, "Principal component №1, №2, №3");

For i := 1 To pc.v.GetUpperBound(1) + 1 Do

d0 := pc.V[i - 1, 0];

d1 := pc.V[i - 1, 1];

d2 := pc.V[i - 1, 2];

Debug.AssertMsg(False, "Observation №" + i.ToString + ": " + d0.ToString + " " + d1.ToString + " " + d2.ToString);

End For;

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

Debug.WriteLine("Principal component №1, №2, №3");

For i := 1 To pc.v.GetUpperBound(1) + 1 Do

d0 := pc.VAdj[i - 1, 0];

d1 := pc.Vadj[i - 1, 1];

d2 := pc.Vadj[i - 1, 2];

Debug.WriteLine("Observation №" + i.ToString + ": " + d0.ToString + " " + d1.ToString + " " + d2.ToString);

End For;

End If;

End Sub Main;

After executing the example the console window displays eigenvectors and values of principal components:

Module execution started

Eigenvectors:

Principal component №1: 0.64200457634989416 0.68636164136057776 -0.34166916924798257

Principal component №2: 0.38467229168844341 0.097130330134305665 0.91792860668744924

Principal component №3: -0.66321742434359598 0.72074502858973277 0.20166618906061454

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

Principal component values:

= V =

Principal component №1, №2, №3

Observation 1: 0.12903035852981545 -0.21839226959071706 0.02025485072666143

Observation 2: -0.66669301100579936 0.0217442534129067 0.19999666028421142

Observation 3: -0.14638086480259591 -0.10060632857139759 0.094644662986802838

Observation 4: 0.51324074516097307 -0.31491122407391198 0.22138084765686122

Observation 5: 0.22137977909251411 0.34314958971596865 0.20643080180376572

Observation 6: -0.27162977083739037 0.41840155766303921 -0.27021100431677547

Observation 7: -0.19095172298978533 -0.41443860123329074 0.27083977554578842

Observation 8: 0.29646093774132237 0.54376056232352743 -0.01319193797809412

Observation 9: 0.068009757606577848 0.0080503305179512527 0.10711010517240993

Observation 10: 0.047533791504367734 -0.28675787016407545 -0.83725476188162995

= V adj =

Principal component №1, №2, №3

Observation 1: 6.2144710921476225 5.8350131824186739 -1.1545432888643969

Observation 2: 0.52102659277629382 8.9792483503876728 -0.31879515629973487

Observation 3: 4.2027665359411852 7.189067773970824 -0.80873851498930494

Observation 4: 8.9125372897146384 4.5780889210008304 -0.77960303414975674

Observation 5: 6.1761606328661642 9.9885302309912198 -0.29035092837580234

Observation 6: 2.7917327939385714 11.148324162274758 -1.3860362116801752

Observation 7: 4.2441002980872566 4.9685382689074817 -0.54885346876693819

Observation 8: 6.476496039968076 11.291131129367113 -0.75190216365878393

Observation 9: 5.5311327536516579 7.6708703957935729 -0.75121091074316793

Observation 10: 5.8254215550243433 5.1074962071510566 -3.4609169594480731

Module execution finished

See also:

ISmPrincipalComponentAnalysis