OpenBI Docs Buy

SURVIVAL.HAZARD OpenBI

The hazard rate over time, smoothed, with its band.

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

Syntax

SURVIVAL.HAZARD ( <table>, <duration>, <event> [, <group>] [, <bandwidth>] )
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).
groupExpression
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.
bandwidthNumber
optional
How far each event's weight spreads in time, above 0; larger is smoother. Left out, Silverman's rule of thumb on the times of the events.

Returns

Table. 101 rows a group, at even steps from 0 to the longest duration. The columns: Group (when grouped), Time, Hazard, Lower, Upper and Bandwidth.

Remarks

  • The hazard is the rate of the event among the rows still at risk: events per row per unit of time. A hazard of 0.05 a month is about one in twenty of those left, each month.
  • It is the Nelson-Aalen estimate smoothed with the Epanechnikov kernel (Ramlau-Hansen's estimator), corrected near 0 and near the longest duration, where the kernel would reach outside the data.
  • Lower and Upper are a 95 % band on the log scale; blank where the hazard is 0.
  • Without a bandwidth, at least two events are needed. Every group uses the same bandwidth and the same times.
  • 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

The rate of leaving, month by month

At whole months only. The default bandwidth here is about 2.5 months.

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
    FILTER (
        SURVIVAL.HAZARD ( Customers, [Months], [Left] ),
        ROUND ( [Time], 4 ) = ROUND ( [Time], 0 )
    )
TimeHazardLowerUpperBandwidth
00.02154165271326610.00303443246973330.1529257303457962.49736604361386
30.07212387849246730.0222969212879850.2332991977506452.49736604361386
60.09151440998966470.02701602953517710.3099969677206512.49736604361386
90.05385413178316520.01249599542941470.232095756316582.49736604361386
120.2342129947268440.05548906277058380.9885862935857132.49736604361386
150(blank)(blank)2.49736604361386

By plan, with a bandwidth of 4 months

Basic customers leave early, Plus customers late; after month 8 no Basic customer is left to leave.

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
    FILTER (
        SURVIVAL.HAZARD ( Customers, [Months], [Left], [Plan], 4 ),
        ROUND ( [Time], 4 ) = ROUND ( [Time], 0 )
    )
GroupTimeHazardLowerUpperBandwidth
Basic00.056250.007923571542743480.3993227653630134
Basic30.08571428571428570.02113742638381010.347579626871584
Basic60.1464843750.03564356546180040.6020068935622344
Basic90.07031250.009904464428429350.4991534567037664
Basic120(blank)(blank)4
Basic150(blank)(blank)4
Plus00(blank)(blank)4
Plus30.0367346938775510.005174577334036560.260782214114624
Plus60.0281250.003961785771371740.1996613826815064
Plus90.0878906250.0219137204997820.3525080080750084
Plus120.1591836734693880.03838745725625170.6600969095206734
Plus150.082031250.01155520849983420.5823456994877274

SURVIVAL.CURVE, SURVIVAL.LIFETABLE, SURVIVAL.COX.

Last updated · OpenBI Studio 0.3.74