SURVIVAL.COX.ZPH OpenBI
Whether each term's effect holds over time (scaled Schoenfeld residuals, as R's cox.zph).
Group: Survival analysis. OpenBI’s own: DAX has no function of this name.
Syntax
SURVIVAL.COX.ZPH ( <table>, <duration>, <event> [, <options>] [, <entry>], <name>, <covariate> [, <name>, <covariate>] … )
| 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). |
options | Text optional | Settings in one text, name=value with commas between: transform (km, rank, identity or log; km when left out), ties (efron or breslow) and terms (true, or false to test each level of a factor on its own). |
entry | Number 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. |
name | Text repeatable | A covariate's name, in quotes: the result calls it so. |
covariate | Expression 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 an event and term. The columns: Variable and Reference; Time and Transformed time; Beta(t) and Coefficient; PH p-value with its PH chi-square and PH df, and PH global p-value; and Transform.
Remarks
- These are the points R draws with plot(cox.zph(fit)): at each event, Beta(t) is the scaled Schoenfeld residual, an estimate of the term's coefficient at that time. When the effect holds over time, they scatter evenly around Coefficient.
- Transformed time is the scale the effect is followed on: 1 − Kaplan-Meier just before the event (km, the default), the times' ranks, the times themselves, or their logarithm.
- The PH columns are the test of
SURVIVAL.COX, for that scale: a small PH p-value says the effect changes over time. - A factor of three levels or more is one term, as in R: its Beta(t) is a multiple of the levels' coefficients, around a Coefficient of 1. With terms=false each level is a term of its own.
- 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 plan's effect at each departure
The points scatter widely around the coefficient, with no clear trend.
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.ZPH ( Customers, [Months], [Left], "Plan", [Plan] ),
"Variable", [Variable],
"Time", [Time],
"Transformed time", [Transformed time],
"Beta(t)", [Beta(t)],
"Coefficient", [Coefficient]
)
| Variable | Time | Transformed time | Beta(t) | Coefficient |
|---|---|---|---|---|
| Plan | 2 | 0 | -2.97952352932328 | -1.48829848252704 |
| Plan | 4 | 0.1 | 4.39480475569963 | -1.48829848252704 |
| Plan | 5 | 0.2125 | -3.36159249626764 | -1.48829848252704 |
| Plan | 7 | 0.325 | -4.00688266021688 | -1.48829848252704 |
| Plan | 11 | 0.4375 | -1.48829848252704 | -1.48829848252704 |
| Plan | 12 | 0.625 | -1.48829848252704 | -1.48829848252704 |
On the scale of the ranks
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.ZPH ( Customers, [Months], [Left], "transform=rank", "Plan", [Plan] ),
"Variable", [Variable],
"Time", [Time],
"Transformed time", [Transformed time],
"PH p-value", [PH p-value],
"Transform", [Transform]
)
| Variable | Time | Transformed time | PH p-value | Transform |
|---|---|---|---|---|
| Plan | 2 | 1 | 0.692968573042893 | rank |
| Plan | 4 | 3 | 0.692968573042893 | rank |
| Plan | 5 | 4 | 0.692968573042893 | rank |
| Plan | 7 | 5 | 0.692968573042893 | rank |
| Plan | 11 | 8 | 0.692968573042893 | rank |
| Plan | 12 | 9 | 0.692968573042893 | rank |