OpenBI Docs Buy

SURVIVAL.COX.ZPH.SMOOTH OpenBI

The smoothed effect over time and its band, as R's plot.cox.zph draws it.

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

Syntax

SURVIVAL.COX.ZPH.SMOOTH ( <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: those of SURVIVAL.COX.ZPH, and df (the smooth's degrees of freedom, 2 to 10, 4 when left out) and points (how many points it is drawn at, 2 to 1,000, 40 when left out).
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 a point and term. The columns: Variable; Transformed time and Time; Beta(t), its Std error, Lower and Upper; Coefficient; PH p-value; and Transform.

Remarks

  • The line R's plot.cox.zph draws through the points of SURVIVAL.COX.ZPH: a natural spline fitted to Beta(t) against the transformed time, at points spread evenly over the events' transformed times.
  • Lower and Upper are two standard errors either side. A band that a flat line at Coefficient fits inside is an effect that holds over time.
  • Time is the transformed time turned back into the duration's own unit, for the axis labels.
  • 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, smoothed

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.SMOOTH ( Customers, [Months], [Left], "points=5", "Plan", [Plan] ),
        "Variable", [Variable],
        "Time", [Time],
        "Beta(t)", [Beta(t)],
        "Lower", [Lower],
        "Upper", [Upper]
    )
VariableTimeBeta(t)LowerUpper
Plan2-1.04082645488219-6.445986974140924.36433406437653
Plan4.5-0.125421945481238-4.561827777975894.31098388701341
Plan6.77777777777778-2.33247068783199-5.927890465342411.26294908967844
Plan11.1666666666667-3.37055102213472-7.876517687417871.13541564314843
Plan12-1.0296794117063-6.68318701579084.62382819237819

An effect that fades

Among 24 customers, spend protects early on, and less later: its PH p-value is below 0.05.

EVALUATE
VAR Customers =
    DATATABLE (
        "Plan", STRING, "Months", INTEGER, "Left", INTEGER, "Spend", INTEGER, "Tickets", INTEGER,
        {
            { "Basic", 3, 1, 20, 4 }, { "Basic", 5, 1, 25, 3 }, { "Basic", 6, 0, 40, 1 }, { "Basic", 8, 1, 30, 5 },
            { "Plus", 9, 1, 35, 2 }, { "Basic", 10, 0, 45, 0 }, { "Basic", 12, 1, 28, 3 }, { "Plus", 14, 0, 60, 1 },
            { "Plus", 15, 1, 38, 4 }, { "Basic", 16, 0, 50, 1 }, { "Plus", 18, 1, 42, 2 }, { "Plus", 20, 0, 55, 0 },
            { "Basic", 22, 1, 33, 2 }, { "Plus", 24, 0, 65, 1 }, { "Plus", 25, 1, 48, 3 }, { "Basic", 27, 0, 36, 0 },
            { "Plus", 30, 1, 52, 1 }, { "Plus", 32, 0, 70, 0 }, { "Basic", 34, 0, 44, 2 }, { "Plus", 36, 0, 58, 1 },
            { "Basic", 4, 1, 22, 2 }, { "Plus", 7, 1, 30, 3 }, { "Basic", 13, 1, 26, 1 }, { "Plus", 28, 0, 62, 2 }
        }
    )
RETURN
    SELECTCOLUMNS (
        SURVIVAL.COX.ZPH.SMOOTH ( Customers, [Months], [Left], "points=4", "Spend", [Spend], "Tickets", [Tickets] ),
        "Variable", [Variable],
        "Transformed time", [Transformed time],
        "Beta(t)", [Beta(t)],
        "Std error", [Std error],
        "PH p-value", [PH p-value]
    )
VariableTransformed timeBeta(t)Std errorPH p-value
Spend0-0.4512062125187230.1781760119431170.0198057592095955
Spend0.194638694638695-0.1990423238844250.1169893457217090.0198057592095955
Spend0.389277389277389-0.2376157669706010.1246215338607350.0198057592095955
Spend0.5839160839160840.1901801116802420.1970381198956610.0198057592095955
Tickets00.7144182391581150.7538374826967280.375903924630139
Tickets0.1946386946386950.4744723517881810.4949653599236770.375903924630139
Tickets0.3892773892773891.141147669122850.5272560674742990.375903924630139
Tickets0.5839160839160840.03955059837660920.8336403911928450.375903924630139

SURVIVAL.COX.ZPH, SURVIVAL.COX.

Last updated · OpenBI Studio 0.3.74