OpenBI Docs Buy

SURVIVAL.TEST OpenBI

The log-rank test between groups' survival curves.

Group: Survival analysis. OpenBI’s own: DAX has no function of this name.

Syntax

SURVIVAL.TEST ( <table>, <duration>, <event>, <group> )
ParameterTypeDescription
tableTableThe rows to follow, one a subject such as a customer, a policy or a machine: a table of the model or a table expression, as the filters leave it.
durationNumber
evaluated for each row
How long each row was followed: until its event, or until we stopped seeing it. In any unit (days, months, years), the same for every row.
eventNumber
evaluated for each row
1 or TRUE when the row's duration ended in the event (the customer left); 0 or FALSE when it did not, so all we know is that it lasted at least that long (censored).
groupExpression
evaluated for each row
The groups whose curves are compared, such as plans: two or more different values.

Returns

Table. A row a group. The columns: Group, Observations and Events; Expected; and the test's Chi-square, Degrees of freedom and P-value, the same on every row.

Remarks

  • The log-rank test, as R's survdiff: do the groups' survival curves differ by more than chance?
  • Expected is how many events the group would have had if every group shared one curve. A group with more events than expected fares worse.
  • Degrees of freedom is the number of groups less one. A small P-value (below 0.05, say) means the curves differ; a large one only that the data can't tell them apart.
  • The test weighs every event alike, early or late.
  • Rows with a blank duration or a blank event are left out. An event other than 0, 1, TRUE or FALSE is an error.
  • The groups come in sorted order; rows whose group is blank are left out.

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

Basic against Plus

Basic has 3 events where 1.6 were expected, but with ten customers the difference could be chance.

EVALUATE
VAR Customers =
    DATATABLE (
        "Plan", STRING, "Months", INTEGER, "Left", INTEGER,
        {
            { "Basic", 2, 1 }, { "Basic", 3, 0 }, { "Basic", 5, 1 }, { "Basic", 7, 1 }, { "Basic", 8, 0 },
            { "Plus", 4, 1 }, { "Plus", 9, 0 }, { "Plus", 11, 1 }, { "Plus", 12, 1 }, { "Plus", 15, 0 }
        }
    )
RETURN
    SELECTCOLUMNS (
        SURVIVAL.TEST ( Customers, [Months], [Left], [Plan] ),
        "Group", [Group],
        "Observations", [Observations],
        "Events", [Events],
        "Expected", [Expected],
        "P-value", [P-value],
        "Chi-square", [Chi-square],
        "Degrees of freedom", [Degrees of freedom]
    )
GroupObservationsEventsExpectedP-valueChi-squareDegrees of freedom
Basic531.636904761904760.1622912254369961.952746229752371
Plus534.363095238095240.1622912254369961.952746229752371

Three plans

EVALUATE
VAR Customers =
    DATATABLE (
        "Plan", STRING, "Months", INTEGER, "Left", INTEGER,
        {
            { "Basic", 2, 1 }, { "Basic", 3, 0 }, { "Basic", 5, 1 }, { "Basic", 7, 1 }, { "Basic", 8, 0 },
            { "Plus", 4, 1 }, { "Plus", 9, 0 }, { "Plus", 11, 1 }, { "Plus", 12, 1 }, { "Plus", 15, 0 },
            { "Pro", 6, 1 }, { "Pro", 10, 1 }, { "Pro", 13, 0 }
        }
    )
RETURN
    SELECTCOLUMNS (
        SURVIVAL.TEST ( Customers, [Months], [Left], [Plan] ),
        "Group", [Group],
        "Events", [Events],
        "Expected", [Expected],
        "P-value", [P-value],
        "Degrees of freedom", [Degrees of freedom]
    )
GroupEventsExpectedP-valueDegrees of freedom
Basic31.429564879564880.2877710596300342
Plus34.200271950271950.2877710596300342
Pro22.370163170163170.2877710596300342

SURVIVAL.CURVE, SURVIVAL.SUMMARY, SURVIVAL.COX.

Last updated · OpenBI Studio 0.3.74