OpenBI Docs Buy

SURVIVAL.COX.PREDICT OpenBI

A Cox model's prediction for each row: risk, survival to a horizon, median, and survival from now.

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

Syntax

SURVIVAL.COX.PREDICT ( <table>, <duration>, <event>, <id>, <horizon> [, <entry>], <name>, <covariate> [, <name>, <covariate>] … )
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).
idExpression
evaluated for each row
What names each row in the result, such as the customer's number.
horizonNumberThe time ahead each row's survival is worked out to: 0 or more.
entryNumber
optional, evaluated for each row
When each row came under observation: it is at risk from just after its entry to the end of its duration. An expression, not a text, given right before the first name.
nameText
repeatable
A covariate's name, in quotes: the result calls it so.
covariateExpression
repeatable, evaluated for each row
The covariate's value on each row: a number, or a text for a factor whose levels are each compared with the first.

Returns

Table. A row for each row of the table. The columns: Key (the id); Linear predictor and Risk; Survival with its Lower and Upper; Median; and Survival from now.

Remarks

  • The model is fitted as SURVIVAL.COX fits it (Efron's ties), on the rows with a duration, an event and every covariate. Then every row of the table is scored, also those without a duration or an event: new customers, say.
  • Linear predictor and Risk compare the row with a reference row, as R's predict does: numbers at their mean, a factor at its first level (and a column of only 0 and 1 at 0). Risk is exp(Linear predictor): 2 is twice the reference's rate.
  • Survival is the row's chance of lasting to the horizon, from time 0, with a 95 % interval; Median is its median time on the model's curve, blank when the curve never gets to a half.
  • Survival from now is for a row still without the event (event 0): its chance of lasting the horizon more, given it has lasted its duration. It is blank for a row that has had the event. This is the figure to rank current customers by.
  • A row with a blank covariate, or a level the fit never saw, gets blanks.
  • A covariate of text is a factor: it gets a term for each level but the first in sorted order, the reference, and is named like Plan: Plus.

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

Each customer, six months ahead

Basic customers have the reference risk 1, Plus customers about a fifth of it. Of those still here, c05 is the likeliest to go within six months.

EVALUATE
VAR Customers =
    DATATABLE (
        "Id", STRING, "Plan", STRING, "Joined", INTEGER, "Months", INTEGER, "Left", INTEGER, "Spend", INTEGER,
        {
            { "c01", "Basic", 0, 2, 1, 20 }, { "c02", "Basic", 1, 3, 0, 35 }, { "c03", "Basic", 0, 5, 1, 25 },
            { "c04", "Basic", 3, 7, 1, 30 }, { "c05", "Basic", 0, 8, 0, 50 }, { "c06", "Plus", 2, 4, 1, 40 },
            { "c07", "Plus", 0, 9, 0, 45 }, { "c08", "Plus", 4, 11, 1, 30 }, { "c09", "Plus", 0, 12, 1, 55 },
            { "c10", "Plus", 6, 15, 0, 60 }
        }
    )
RETURN
    SELECTCOLUMNS (
        SURVIVAL.COX.PREDICT ( Customers, [Months], [Left], [Id], 6, "Plan", [Plan] ),
        "Key", [Key],
        "Risk", [Risk],
        "Survival", [Survival],
        "Median", [Median],
        "Survival from now", [Survival from now]
    )
KeyRiskSurvivalMedianSurvival from now
c0110.5160362902804467(blank)
c0210.51603629028044670.430468207373306
c0310.5160362902804467(blank)
c0410.5160362902804467(blank)
c0510.51603629028044670.0249397228269913
c060.2257564574810250.86126284050843412(blank)
c070.2257564574810250.861262840508434120.434598208507078
c080.2257564574810250.86126284050843412(blank)
c090.2257564574810250.86126284050843412(blank)
c100.2257564574810250.861262840508434121

SURVIVAL.COX, SURVIVAL.COX.CURVE, PREDICT, TOPN.

Last updated · OpenBI Studio 0.3.74