OpenBI Docs Buy

SURVIVAL.COX.CURVE OpenBI

Survival curves adjusted by a Cox model, for each value of one covariate.

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

Syntax

SURVIVAL.COX.CURVE ( <table>, <duration>, <event>, <by> [, <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).
byTextThe covariate whose values each get a curve, by its name in quotes; BLANK () for one curve only, the typical row's.
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. The columns of SURVIVAL.CURVE: Group (unless by is blank) and Time; At risk, Events and Censored; Survival with its Std error, Lower and Upper; and Cumulative hazard.

Remarks

  • The model's survival curves (R's survfit on a coxph fit): one for each level of a factor, for each value of a number with five values or fewer, else for its quartiles. Group holds that value.
  • The other covariates are held at a typical row's: a number at its mean, a factor at its most common level.
  • At risk, Events and Censored are those of all the rows fitted, the same for every curve; Survival, its interval and Cumulative hazard are the model's for that value.
  • Unlike Kaplan-Meier curves split by group, the curves share one model: they never cross, and each uses all the rows.
  • A row is fitted when its duration, its event and every covariate (and the entry, when given) have a value; rows with a 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

The model's curve for each plan

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.CURVE ( Customers, [Months], [Left], "Plan", "Plan", [Plan] ),
        "Group", [Group],
        "Time", [Time],
        "Survival", [Survival],
        "Lower", [Lower],
        "Upper", [Upper]
    )
GroupTimeSurvivalLowerUpper
Basic0111
Basic20.849451400236550.6125047194001581
Basic30.849451400236550.6125047194001581
Basic40.6667322671562330.3612170058457571
Basic50.5160362902804460.2228302539040611
Basic70.3656618215105720.1123150851383051
Basic80.3656618215105720.1123150851383051
Basic90.3656618215105720.1123150851383051
Basic110.08352880482777720.0005577275938225481
Basic120.009119504476886412.62788963952969e-071
Basic150.009119504476886412.62788963952969e-071
Plus0111
Plus20.9638347206797080.8725786776940321
Plus30.9638347206797080.8725786776940321
Plus40.9125484008266550.7435601236773251
Plus50.8612628405084340.6305713899937841
Plus70.7968239927616680.5101979249280631
Plus80.7968239927616680.5101979249280631
Plus90.7968239927616680.5101979249280631
Plus110.5709493398301570.2588770286650391
Plus120.3462982797496780.09829277260447821
Plus150.3462982797496780.09829277260447821

By spend, at its quartiles

Spend has nine values, so the curves are for its quartiles: 30, 37.5 and 48.75. At a few times only.

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 (
        FILTER (
            SURVIVAL.COX.CURVE ( Customers, [Months], [Left], "Spend", "Spend", [Spend] ),
            [Time] IN { 0, 5, 11 }
        ),
        "Group", [Group],
        "Time", [Time],
        "Survival", [Survival]
    )
GroupTimeSurvival
3001
3050.578930364344334
30110.137538826551757
37.501
37.550.848007610386557
37.5110.549691174868414
48.7501
48.7550.97305761771041
48.75110.905623213253024

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

Last updated · OpenBI Studio 0.3.74