OpenBI Docs Buy

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>] … )
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).
optionsText
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).
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 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]
    )
VariableTimeTransformed timeBeta(t)Coefficient
Plan20-2.97952352932328-1.48829848252704
Plan40.14.39480475569963-1.48829848252704
Plan50.2125-3.36159249626764-1.48829848252704
Plan70.325-4.00688266021688-1.48829848252704
Plan110.4375-1.48829848252704-1.48829848252704
Plan120.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]
    )
VariableTimeTransformed timePH p-valueTransform
Plan210.692968573042893rank
Plan430.692968573042893rank
Plan540.692968573042893rank
Plan750.692968573042893rank
Plan1180.692968573042893rank
Plan1290.692968573042893rank

SURVIVAL.COX.ZPH.SMOOTH, SURVIVAL.COX, SURVIVAL.COX.CURVE.

Last updated · OpenBI Studio 0.3.74