Skip to content

Instantly share code, notes, and snippets.

@iwanbolzern
Created November 7, 2025 21:12
Show Gist options
  • Select an option

  • Save iwanbolzern/83ee3493f770e5e1aa4d2709753e7693 to your computer and use it in GitHub Desktop.

Select an option

Save iwanbolzern/83ee3493f770e5e1aa4d2709753e7693 to your computer and use it in GitHub Desktop.
This notebook serves as a calculator and visual guide for a crucial financial decision that married couples in Switzerland face upon retirement: choosing the level of the survivor's pension (widow's/widower's pension) from the occupational pension fund (2nd pillar, PKG).

Pension Fund (PKG) Options Calculator (Switzerland)

This notebook serves as a calculator and visual guide for a crucial financial decision that married couples in Switzerland face upon retirement: choosing the level of the survivor's pension (widow's/widower's pension) from the occupational pension fund (2nd pillar, PKG).

The Financial Context (Research)

In Switzerland, the level of the widow's or widower's pension from the pension fund (PKG) is regulated by law. The minimum legal requirement (BVG/LPP compulsory benefits) states that the surviving spouse receives a pension equivalent to 60% of the deceased partner's retirement pension.

However, many pension funds offer flexible models (in the non-compulsory/extra-mandatory part). Insured individuals can voluntarily choose to reduce their own retirement pension. In return, the future survivor's pension for their spouse is increased, for example, to 80% or 100% of the (now reduced) retirement pension.

The Dilemma (Trade-off):

  1. Standard Option (e.g., 60%): You receive a higher personal retirement pension as long as both partners are alive. However, if the primary insured person (the husband, in this code) dies, the widow receives only the lower 60% pension.
  2. Reduced Option (e.g., 100%): You receive a lower personal retirement pension. In return, the surviving partner is maximally secured in the event of death and receives a pension of the same amount (100%).

The "best" option depends on many factors, especially the life expectancy of both partners.

How the Notebook Works

This calculator simulates the financial outcomes of this decision by calculating the total pension benefits paid out to a couple over their entire lifespan.

It compares three specific scenarios (based on the predefined pension amounts in the code):

  • guthaben_60 (60% Option): High pension for the husband (63,766.80), low widow's pension (40,260.20).
  • guthaben_80 (80% Option): Medium pension for the husband (61,707), medium widow's pension (45,365.60).
  • guthaben_100 (100% Option): Low pension for the husband (49,883.60), high widow's pension (49,883.60).

The alters_guthaben (total_assets) function calculates the total capital as follows:

  1. Husband's Assets: The sum of his pensions (years from retirement until death).
  2. Wife's Assets: The sum of her widow's pensions (years she lives after the husband's death).
  3. Total Sum: The sum of 1 and 2. (If the wife dies first, her assets are 0).

The script tests all possible combinations for the age of death for the husband (75-92) and wife (75-92).

## The Result: The Heatmap

The notebook generates a heatmap that serves as a visual decision-making guide:

  • X-Axis: Age of husband at death.
  • Y-Axis: Age of wife at death.
  • Color: Shows the best option (60, 80, or 100) that results in the highest total assets for the couple at that specific age-pair.
  • Annotations (Numbers): Show the calculated total assets for all three options (e.g., "60% / 80% / 100%").

How to read the map:

  • "Best Option 60%" Region (e.g., top-right): If both partners live to a very old age, or if the wife dies early, the 60% option is best, as the couple benefits longest from the husband's high retirement pension.
  • "Best Option 100%" Region (e.g., bottom-left): If the husband dies early and the wife outlives him by many years, the 100% option is best, as the high widow's pension more than compensates for the lower retirement pension.
  • "Best Option 80%" Region: Represents the compromise for the scenarios in between.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment