Follow ______ on twitter.

9.1.2 Calculating hazard rates for risk assessment

Code

Vega-Lite Chart

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "Survival Functions and Hazard Rates for Credit and Operational Risks",
  "hconcat": [
    {
      "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: Credit Risk",
            "fontSize": 14
          }
        },
        {
          "width": 200,
          "height": 200,
          "data": {
            "sequence": {
              "start": 0,
              "stop": 60,
              "step": 1,
              "as": "time"
            }
          },
          "transform": [
            {
              "calculate": "0.00427 * exp(-0.00427 * datum.time) / exp(-0.00427 * datum.time)",
              "as": "hazardRate"
            }
          ],
          "mark": {
            "type": "line",
            "point": true
          },
          "encoding": {
            "x": {
              "field": "time",
              "type": "quantitative",
              "title": "Time (months)",
              "axis": {
                "tickCount": 6
              }
            },
            "y": {
              "field": "hazardRate",
              "type": "quantitative",
              "title": "Hazard Rate",
              "axis": {
                "format": ".2f"
              },
              "scale": {
                "zero": false
              }
            },
            "tooltip": [
              {
                "field": "time",
                "type": "quantitative",
                "title": "Time (months)"
              },
              {
                "field": "hazardRate",
                "type": "quantitative",
                "title": "Hazard Rate",
                "format": ".2f"
              }
            ]
          },
          "title": {
            "text": "Hazard Rate: Credit Risk",
            "fontSize": 14
          }
        }
      ]
    },
    {
      "hconcat": [
        {
          "width": 200,
          "height": 200,
          "data": {
            "sequence": {
              "start": 0,
              "stop": 60,
              "step": 1,
              "as": "time"
            }
          },
          "transform": [
            {
              "calculate": "exp(-0.002 * 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: Operational Risk",
            "fontSize": 14
          }
        },
        {
          "width": 200,
          "height": 200,
          "data": {
            "sequence": {
              "start": 0,
              "stop": 60,
              "step": 1,
              "as": "time"
            }
          },
          "transform": [
            {
              "calculate": "0.002 * exp(-0.002 * datum.time) / exp(-0.002 * datum.time)",
              "as": "hazardRate"
            }
          ],
          "mark": {
            "type": "line",
            "point": true
          },
          "encoding": {
            "x": {
              "field": "time",
              "type": "quantitative",
              "title": "Time (months)",
              "axis": {
                "tickCount": 6
              }
            },
            "y": {
              "field": "hazardRate",
              "type": "quantitative",
              "title": "Hazard Rate",
              "axis": {
                "format": ".2f"
              },
              "scale": {
                "zero": false
              }
            },
            "tooltip": [
              {
                "field": "time",
                "type": "quantitative",
                "title": "Time (months)"
              },
              {
                "field": "hazardRate",
                "type": "quantitative",
                "title": "Hazard Rate",
                "format": ".2f"
              }
            ]
          },
          "title": {
            "text": "Hazard Rate: Operational Risk",
            "fontSize": 14
          }
        }
      ]
    }
  ]
}