OpenBI Docs Buy

PCA.COMPONENTS OpenBI

Principal components: each one's variance and its share.

Group: Many variables at once. OpenBI’s own: DAX has no function of this name.

Syntax

PCA.COMPONENTS ( <table>, <name1>, <expression1>, <name2>, <expression2> [, <name3>, <expression3>] … )
ParameterTypeDescription
tableTableThe rows to analyse: a table of the model or any table expression.
name1TextThe first variable's name, a text in quotes.
expression1Expression
evaluated for each row
The first variable's number for each row.
name2Text
repeatable
The next variable's name; two or more variables in all.
expression2Expression
repeatable, evaluated for each row
The next variable's number for each row.

Returns

Table. A row a component, the strongest first: Component (1, 2 …), Name (PC1, PC2 …), Eigenvalue, Std deviation, Share (the part of the total variation it carries) and Cumulative share.

Remarks

  • Principal components are new variables, each a weighted sum of the old ones, that take up as much of the variation as they can in turn. Cumulative share says how many of them tell most of the story.
  • Pick the columns you want with SELECTCOLUMNS, as the examples do.
  • Every variable is first put on one scale: how many standard deviations each row lies above or below that variable's mean. Liters and kroner then weigh alike, and a change of units changes nothing. The analysis is then of the correlations, as R's prcomp with scale = TRUE.
  • The eigenvalues add up to the number of variables. A component with an eigenvalue above 1 carries more than a single variable would.
  • A row where any variable is blank is left out. A variable must be a number on every row (text is an error, even text that reads as a number), and one that is the same on every row is an error too.
  • Each variable is a name in quotes followed by its expression; two variables may not share a name.
  • PCA.COMPONENTS, PCA.LOADINGS and PCA.SCORES with the same table and variables describe the same components.

Compared with DAX

An OpenBI function: DAX has none like it, so a measure or query that uses it works in OpenBI only, not in Power BI or Analysis Services.

Examples

Six beers, three variables

Strength, bitterness and price rise together, so one component takes up 92 % of the variation.

EVALUATE
VAR Beers =
    DATATABLE (
        "Beer", STRING, "Strength", DOUBLE, "Bitterness", INTEGER, "Price", INTEGER,
        {
            { "Lettøl", 2.5, 15, 30 }, { "Pils", 4.7, 25, 38 }, { "Lager", 5.0, 22, 40 },
            { "Pale ale", 5.5, 40, 55 }, { "IPA", 6.5, 65, 64 }, { "Stout", 7.0, 45, 70 }
        }
    )
RETURN
    SELECTCOLUMNS (
        PCA.COMPONENTS ( Beers, "Strength", [Strength], "Bitterness", [Bitterness], "Price", [Price] ),
        "Name", [Name], "Eigenvalue", [Eigenvalue], "Share", [Share],
        "Cumulative share", [Cumulative share]
    )
NameEigenvalueShareCumulative share
PC12.761489988416190.9204966628053980.920496662805398
PC20.1834634472203680.06115448240678930.981651145212187
PC30.05504656436343840.01834885478781281

Countries by population, GDP and GDP per person

GDP per person is a measure, worked out for each country.

EVALUATE
SELECTCOLUMNS (
    PCA.COMPONENTS ( Countries, "People", Countries[People], "GDP", Countries[GDP], "GDP per person", [GDP per person] ),
    "Name", [Name], "Eigenvalue", [Eigenvalue], "Share", [Share], "Cumulative share", [Cumulative share]
)
NameEigenvalueShareCumulative share
PC11.599979809160190.5333266030533960.533326603053396
PC21.033916612038740.3446388706795790.877965473732975
PC30.3661035788010740.1220345262670251

PCA.LOADINGS, PCA.SCORES, KMEANS, CORREL.

Last updated · OpenBI Studio 0.3.74