SURVIVAL.SUMMARY OpenBI
A survival curve's median and expected lifetime to a horizon.
Group: Survival analysis. OpenBI’s own: DAX has no function of this name.
Syntax
SURVIVAL.SUMMARY ( <table>, <duration>, <event> [, <group>] [, <horizon>] )
| Parameter | Type | Description |
|---|---|---|
table | Table | The 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. |
duration | Number 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. |
event | Number 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). |
group | Expression 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. |
horizon | Number optional | The time the restricted mean runs to. Left out, the longest duration of all the rows, the same for every group. |
Returns
Table. A row a group. The columns: Group (when grouped); Observations and Events; Median, Median lower and Median upper; Restricted mean and its Std error; Horizon and Survival at horizon.
Remarks
- Median is the earliest time at which the Kaplan-Meier curve has fallen to a half or lower (midway to the next drop when it sits at exactly a half); blank when the curve never gets that low.
- Median lower and Median upper are where the curve's 95 % bounds reach a half: an interval for the median, blank when a bound never gets there.
- Restricted mean is how long a row lasts on average up to the horizon, such as a customer's expected months in the first year: the area under the curve between 0 and the horizon. It is a fair figure even when many rows are censored.
- Survival at horizon is the curve's value there.
- 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
Two plans side by side
Both lose three of five, but Plus customers stay longer: their curve stays higher, so its area to month 15 is larger.
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.SUMMARY ( Customers, [Months], [Left], [Plan] ),
"Group", [Group],
"Observations", [Observations],
"Events", [Events],
"Median", [Median],
"Restricted mean", [Restricted mean],
"Std error", [Std error],
"Survival at horizon", [Survival at horizon]
)
| Group | Observations | Events | Median | Restricted mean | Std error | Survival at horizon |
|---|---|---|---|---|---|---|
| Basic | 5 | 3 | 7 | 7.6 | 2.35589096144584 | 0.266666666666667 |
| Plus | 5 | 3 | 12 | 10.9333333333333 | 1.73777209433569 | 0.266666666666667 |
The first year
Within the first 12 months a customer stays 8.6 months on average.
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.SUMMARY ( Customers, [Months], [Left], , 12 ),
"Observations", [Observations],
"Events", [Events],
"Median", [Median],
"Median lower", [Median lower],
"Restricted mean", [Restricted mean],
"Horizon", [Horizon],
"Survival at horizon", [Survival at horizon]
)
| Observations | Events | Median | Median lower | Restricted mean | Horizon | Survival at horizon |
|---|---|---|---|---|---|---|
| 10 | 6 | 11 | 5 | 8.5625 | 12 | 0.1875 |
Related functions
SURVIVAL.CURVE, SURVIVAL.MEDIAN, SURVIVAL.AT, SURVIVAL.TEST.