Follow ______ on twitter.

9.1.5 Applications of hazard rates in Risk Management

Code

Vega-Lite Chart

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "Credit Risk Analysis: Survival and Hazard Rates",
  "hconcat": [
    {
      "width": 200,
      "height": 200,
      "data": {
        "sequence": {
          "start": 0,
          "stop": 60,
          "step": 1,
          "as": "time"
        }
      },
      "transform": [
        {
          "calculate": "exp(-0.00427 * datum.time)",
          "as": "survivalRate"
        }
      ],
      "mark": {
        "type": "line",
        "point": true
      },
      "encoding": {
        "x": {
          "field": "time",
          "type": "quantitative",
          "title": "Time (months)",
          "axis": {
            "tickCount": 6
          }
        },
        "y": {
          "field": "survivalRate",
          "type": "quantitative",
          "title": "Survival Rate",
          "axis": {
            "format": ".0%"
          },
          "scale": {
            "zero": false
          }
        },
        "tooltip": [
          {
            "field": "time",
            "type": "quantitative",
            "title": "Time (months)"
          },
          {
            "field": "survivalRate",
            "type": "quantitative",
            "title": "Survival Rate",
            "format": ".2%"
          }
        ]
      },
      "title": {
        "text": "Survival Function",
        "fontSize": 14
      }
    },
    {
      "width": 200,
      "height": 200,
      "data": {
        "sequence": {
          "start": 0,
          "stop": 60,
          "step": 1,
          "as": "time"
        }
      },
      "transform": [
        {
          "calculate": "1 - exp(-0.00427 * datum.time)",
          "as": "cumulativeHazardRate"
        }
      ],
      "mark": {
        "type": "line",
        "point": true
      },
      "encoding": {
        "x": {
          "field": "time",
          "type": "quantitative",
          "title": "Time (months)",
          "axis": {
            "tickCount": 6
          }
        },
        "y": {
          "field": "cumulativeHazardRate",
          "type": "quantitative",
          "title": "Cumulative Hazard Rate",
          "axis": {
            "format": ".2f"
          },
          "scale": {
            "zero": false
          }
        },
        "tooltip": [
          {
            "field": "time",
            "type": "quantitative",
            "title": "Time (months)"
          },
          {
            "field": "cumulativeHazardRate",
            "type": "quantitative",
            "title": "Cumulative Hazard Rate",
            "format": ".2f"
          }
        ]
      },
      "title": {
        "text": "Cumulative Hazard Rate",
        "fontSize": 14
      }
    },
    {
      "width": 200,
      "height": 200,
      "data": {
        "sequence": {
          "start": 0,
          "stop": 60,
          "step": 1,
          "as": "time"
        }
      },
      "transform": [
        {
          "calculate": "0.00427",
          "as": "conditionalHazardRate"
        }
      ],
      "mark": {
        "type": "line",
        "point": true
      },
      "encoding": {
        "x": {
          "field": "time",
          "type": "quantitative",
          "title": "Time (months)",
          "axis": {
            "tickCount": 6
          }
        },
        "y": {
          "field": "conditionalHazardRate",
          "type": "quantitative",
          "title": "Conditional Hazard Rate",
          "axis": {
            "format": ".2%"
          },
          "scale": {
            "zero": false
          }
        },
        "tooltip": [
          {
            "field": "time",
            "type": "quantitative",
            "title": "Time (months)"
          },
          {
            "field": "conditionalHazardRate",
            "type": "quantitative",
            "title": "Conditional Hazard Rate",
            "format": ".2%"
          }
        ]
      },
      "title": {
        "text": "Conditional Hazard Rate",
        "fontSize": 14
      }
    },
    {
      "width": 200,
      "height": 200,
      "data": {
        "sequence": {
          "start": 1,
          "stop": 60,
          "step": 1,
          "as": "time"
        }
      },
      "transform": [
        {
          "calculate": "exp(-0.00427 * datum.time)",
          "as": "survivalRate"
        },
        {
          "calculate": "(1 - exp(-0.00427 * datum.time)) - (datum.time == 0 ? 0 : (1 - exp(-0.00427 * (datum.time - 1))))",
          "as": "unconditionalHazardRate"
        }
      ],
      "mark": {
        "type": "line",
        "point": true
      },
      "encoding": {
        "x": {
          "field": "time",
          "type": "quantitative",
          "title": "Time (months)",
          "axis": {
            "tickCount": 6
          }
        },
        "y": {
          "field": "unconditionalHazardRate",
          "type": "quantitative",
          "title": "Unconditional Hazard Rate",
          "axis": {
            "format": ".2%"
          },
          "scale": {
            "zero": false
          }
        },
        "tooltip": [
          {
            "field": "time",
            "type": "quantitative",
            "title": "Time (months)"
          },
          {
            "field": "unconditionalHazardRate",
            "type": "quantitative",
            "title": "Unconditional Hazard Rate",
            "format": ".2%"
          }
        ]
      },
      "title": {
        "text": "Unconditional Hazard Rate",
        "fontSize": 14
      }
    }
  ]
}