OpenBI Docs Buy

SURVIVAL.LIFETABLE OpenBI

An actuarial life table, in intervals of a width.

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

Syntax

SURVIVAL.LIFETABLE ( <table>, <duration>, <event>, <width> [, <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).
widthNumberHow long each interval is, such as 1 year or 30 days; above 0.
groupExpression
optional, evaluated for each row
Splits the rows into groups, such as plans or regions, each with its own result. Left out, all the rows are one group.

Returns

Table. A row an interval, per group. The columns: Group (when grouped); Start and End; Entered, Withdrawn and Events; Exposed; Probability; Survival and its Std error; Density; and Hazard.

Remarks

  • The actuarial life table, as R's KMsurv computes it: intervals from 0 of the width given, each from its Start up to, not including, its End. A duration that falls on an End counts in the next interval.
  • Entered counts the rows still followed at the interval's start; Withdrawn those censored in it, Events those that had the event in it.
  • Exposed is Entered less half the withdrawn, who are taken to leave halfway. Probability is Events over Exposed: the chance of the event within the interval for a row that reached it.
  • Survival is the share still without the event at the interval's start, with Greenwood's Std error. Density is the share that has the event in the interval, per unit of time; Hazard the events per unit of time over those at risk in it.
  • Every group gets the same intervals, up to the longest duration; in an interval nobody entered, the rates are blank.
  • Rows with a blank duration or a blank event are left out. An event other than 0, 1, TRUE or FALSE is an error.

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

Five-month intervals

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.LIFETABLE ( Customers, [Months], [Left], 5 ),
        "Start", [Start],
        "End", [End],
        "Entered", [Entered],
        "Events", [Events],
        "Withdrawn", [Withdrawn],
        "Exposed", [Exposed],
        "Probability", [Probability],
        "Survival", [Survival],
        "Hazard", [Hazard]
    )
StartEndEnteredEventsWithdrawnExposedProbabilitySurvivalHazard
0510219.50.21052631578947410.0470588235294118
51072260.3333333333333330.7894736842105260.08
101532030.6666666666666670.5263157894736840.2
15201010.500.1754385964912280

Half-years, by plan

No Basic customer is left after month 12, so that interval's rates are blank.

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.LIFETABLE ( Customers, [Months], [Left], 6, [Plan] ),
        "Group", [Group],
        "Start", [Start],
        "Entered", [Entered],
        "Events", [Events],
        "Probability", [Probability],
        "Survival", [Survival],
        "Density", [Density]
    )
GroupStartEnteredEventsProbabilitySurvivalDensity
Basic0520.44444444444444410.0740740740740741
Basic6210.6666666666666670.5555555555555560.0617283950617284
Basic1200(blank)0.185185185185185(blank)
Plus0510.210.0333333333333333
Plus6410.2857142857142860.80.0380952380952381
Plus12210.6666666666666670.5714285714285720.0634920634920635

SURVIVAL.CURVE, SURVIVAL.HAZARD, SURVIVAL.SUMMARY.

Last updated · OpenBI Studio 0.3.74