knitr::opts_chunk$set(echo = TRUE)
library(SmaRP)
library(ggplot2)
library(googleVis)
library(dplyr)
library(knitr)
library(pander)
library(reshape2)
library(shiny)
library(lubridate)

show_text <- TRUE


if(params$P2purchase + params$P3purchase > 0){
  show_tax = TRUE
} else {
  show_tax = FALSE
}

options(warn = -1)

DOV <- format(round(params$DOV, 2), nsmall = 0)
Verheiratet<- format(round(params$Verheiratet, 2), nsmall = 0)
VersicherungsV <- format(round(params$VersicherungsV, 2), nsmall = 0)
VersicherungsL <- format(round(params$VersicherungsL, 2), nsmall = 0)
ALV <- format(round(params$ALV, 2), nsmall = 0)
AHL <- format(round(params$AHL, 2), nsmall = 0)
Kinder <- format(round(params$Kinder, 2), nsmall = 0)

\def\SmaRPVersion{r get_SmaRP_version()}

\newpage \pagenumbering{gobble} \vspace*{7cm} \begin{center} \huge{SmaRP: Smart Retirement Planning} \end{center} \begin{center} \LARGE{Mirai Solutions GmbH} \end{center} \begin{center} \today \end{center} \newpage

\tableofcontents

\newpage \pagenumbering{arabic}

Introduction

Smart Retirement Planning (SmaRP) is a Mirai Solutions initiative designed to guide people working in Switzerland towards a strategic decision-making process for their retirement.

It is implemented as an R Shiny pension calculator web app, in the form of an R package. The source code is available on GitHub and the app itself online at https://mirai-solutions.ch/gallery/smarp.

SmaRP is based on the three pillars pension system and reflects the complexity of its legal framework. The bulk of the retirement income are the second and third pillar, which employees can actively manage and make decisions impacting their total pension fund at retirement. The first pillar is not considered as it is a pay-as-you-go universal system whose benefits depend on the income earned during the working life and the number of years contributed. In addition, since non-mandatory contributions are tax favored, SmaRP incorporates an additional fund -the Tax benefits- to outline the effects of those tax reliefs on the long run.

SmaRP is based on assumptions and includes some simplifications. Thus, it is advisable to use the app to perform different "what-if" scenarios and assess their feasibility. Any outcome should consider some degree of uncertainty.

The main drivers of the retirement fund are:

Note that SmaRP does not make any consideration about the usage of the retirement funds.

The main outcome is displayed in the "Results" section with a more detailed drill down in Appendix 2; formulas used to obtain these results are explained in Appendix 1. In addition, a list of assumptions and limitations is provided in a separate section as well as a brief explanation of the Swiss retirement system.


\newpage

Results

Road2Retirement_to_print <- params$Road2Retirement %>%
  select(Calendar, ExpectedSalaryPath, BVGcontributionrates, BVGContributions, BVGpurchase, DirectP2, ReturnP2, TotalP2, P3ContributionPath, P3purchase, DirectP3, ReturnP3, TotalP3, DirectTax, ReturnTax, TotalTax, Total) %>%
  rename(P2ContributionPath = BVGContributions) %>%
  rename(P2contriburionrates = BVGcontributionrates) %>%
  rename(P2purchase = BVGpurchase) %>%
  mutate(Y = year(Calendar)/5) %>%
  filter(Y %in% unique(c(Y[1], Y[!Y%%1], Y[length(Y)]))) 

Based on the information inserted in the three pillars, the total retirement fund as of r format(params$retirementdate, "%d-%m-%Y") is calculated to be r printCurrency(params$retirementfund) CHF, which is r params$percentageLastSalary.[^1]

The two plots below represent the time evolution of the different funds and their contribution to the total retirement fund at retirement, respectively.

tserieGraphData.columns <- setdiff(names(params$TserieGraphData), "Calendar")

tserieGraphData.long <- melt(params$TserieGraphData,
                             id = "Calendar",
                             measure = tserieGraphData.columns)
tserieGraphData.long$variable <- factor(tserieGraphData.long$variable,
                                        levels = sort(unique(tserieGraphData.long$variable),
                                                      decreasing = TRUE))

ggplot(tserieGraphData.long, aes(x = Calendar, y = value, fill = variable)) +
  scale_fill_manual(NULL, values = c("2nd Pillar" = "#008cc3", "3rd Pillar" = "#FF9966", "Tax Benefits" = "#13991c")) +
  scale_y_continuous(labels = scales::comma) +
  labs(x = "Year", y = "Return [CHF]") +
  geom_area(alpha = 0.6) +
  theme(
    axis.text = element_text(size = 10),
    axis.title = element_text(color="grey80"),
    aspect.ratio = 0.6,
    panel.background = element_rect(fill = NA),
    panel.grid.major = element_line(colour = "grey"),
    panel.ontop = FALSE,
    legend.position = "right"
  )


barGraphData.columns <- setdiff(names(params$BarGraphData), "contribution")
barGraphData.columns <- grep("annotation$", barGraphData.columns,
                             value = TRUE, invert = TRUE)
barGraphData.long <- melt(params$BarGraphData,
                          id = "contribution",
                          measure = barGraphData.columns)
barGraphData.long$variable <- factor(barGraphData.long$variable,
                                     levels = sort(barGraphData.long$variable,
                                                   decreasing = TRUE))

ggplot(data = barGraphData.long, aes(x = contribution, y = value, fill = variable, label = value)) +
  geom_bar(stat = "identity", alpha = 0.6) +
  geom_text(aes(label = sprintf("%1.0f%%", 100 * value)), size = 3, position = position_stack(vjust = 0.5)) +
  scale_x_discrete(breaks = NULL) +
  scale_y_continuous(labels = scales::percent) +
  coord_flip() +
  scale_fill_manual(NULL, values = c("2nd Pillar" = "#008cc3", "3rd Pillar" = "#FF9966", "Tax Benefits" = "#13991c")) +
  labs(x = NULL, y = "% Contribution of each fund at retirement") +
  theme(
    axis.text = element_text(size = 10),
    axis.title = element_text(color = "grey"),
    aspect.ratio = 0.1,
    panel.background = element_rect(fill = NA),
    panel.grid.major = element_line(colour = NA),
    panel.ontop = FALSE,
    legend.position = "none"
  )


Corresponding formulas are in Appendix 1 of this document and a more detailed break down of the amounts can be found in Appendix 2. A comprehensive set of values calculated can de downloaded as well from the Table tab.


Parameters

TypePurchase <- ifelse(params$TypePurchase == "SingleP2", "single purchase", "annual purchase")

The results shown above are based on the following inputs set by the user on the left hand side panels of SmaRP.

SalaryGrowthRate <-  params$SalaryGrowthRate * 100
if(is.null(params$P2purchase) || params$P2purchase == 0){
  msgP2 <- "No voluntary contribution to the second Pillar is made."
} else {
  msgP2 <- paste0("The voluntary contribution to the second Pillar is of ", params$P2purchase, " CHF and is made as a ", TypePurchase, ".")
}
if(params$rate_group == "A"){
  maritallabel <- "Single"
} else if(params$rate_group == "B"){
  maritallabel <- "Married"
} else {
  maritallabel <- "Married double-income"
}
if (params$churchtax == "N"){
  churchaffiliation <- "No"
} else {
  churchaffiliation <- "A"
}


Assumptions and limitations

SmaRP is valid for employees only, i.e. persons whose main income is a salary. Self-employed people do not belong to this category.

SmaRP takes into account only the occupational (2nd Pillar) and the private (3rd Pillar) funds. The state-run pay-as-you-earn system (1st Pillar) is law and salary dependent only, meaning there is no active decision-making from the employee's side. Therefore, it is not explicitly considered.

When calculating contributions to the Occupational Fund (2nd Pillar) any salary above minimum threshold is taken into account to generate the retirement benefits.

SmaRP considers the tax saving generated by the voluntary retirement contributions, assuming that all generated tax benefits are 100% reinvested as an additional fund. The return from these tax benefits is set to be the same as those of the private fund.

In case of married couples with double-income, SmaRP assumes that all monetary amounts are split 50% and both members have the same age. For more information, please refer to Appendix 3.

A proxy of the taxable income is used to calculate tax savings.[^3] The taxable income is computed by detracting the following deductions from the gross salary:[^4]

[^1]: SmaRP does not make any consideration about the usage of the retirement funds. For the Occupational fund, the Swiss pension law allows retirees to take the full amount as a lump sum or receive their pension in the form of a life annuity, or a mix of both. In that case, the minimum conversion rate is 6.8% (since 2017) and can vary depending on the retirement age. The Private fund, however, gets always paid as a lump sum. [^2]: Church taxes differ based on the type (Evangelische or Roeman-katolische Kirche) and canton of residence. SmaRP does not make such distinction and always assumes the highest of the values. Moreover, when the church-tax depends on the cantonal tax rate (instead of being a fixed factor), an approximation is made and treated as the maximum possible factor (relevant for cantons: VS, BS, BL). [^3]: Taxes on assets are not considered. [^4]: Although most of those parameters can vary a bit depending on the canton, we use the federal values as proxy.

\newpage

The basics of the Swiss retirement system

The Swiss social retirement system is based on a three-pillar regime.

\vspace{12pt}

\begin{center} \includegraphics[width=0.4\textwidth]{www/SwissRetirementSystem.png} \end{center}

\vspace{12pt}

First Pillar is a state-run pay-as-you-earn system with minimum benefits[^5]. It aims at providing a subsistence level of income to all retirees. The annuity at retirement depends on the amount of income earned and the number of years contributed. Since all parameters are law dependent, it is not explicitly considered in SmaRP.

Second Pillar is a compulsory, tax-deductible company occupational pension insurance fund[^6]. Its goal is to maintain pre-retirement living standards. Voluntary additional buy-ins are regulated, but allow for benefits enhancements at retirement age while reducing the tax burden during the working career. The pensionable salary is defined as part of the AHV with a range between 7/8 and 3 times the AHV salary (between 24.675 and 84.600 as of 01-01-2018). The amount within this range is called the "Mandatory Component" and all employers are required by law to insure at least this compulsory share. However, they are free to offer coverage for the salary above the upper threshold, which the vast majority provides as this extra coverage has become a de facto "must have" to attract employees.

Third Pillar is a voluntary contribution; it is a privately-run, tax-deductible insurance fund. The private fund is modeled as an asset of a given amount ("Current assets"), to which contributions can be added annually ("Annual contribution"). The annual expected return of this asset is given as an input and assumed constant until the retirement date.

Tax benefits are always a key factor towards a smart retirement project. SmaRP takes them into consideration and implements them as an additional fund.

\vspace{12pt}

\begin{center} \includegraphics[width=0.6\textwidth]{www/TaxBenefits.png} \end{center}

\vspace{12pt}

Taxation is municipality-dependent. It can be either provided as an input or inferred from the user's inputs. If inferred, it is computed in two parts: federal tax (same for all cantons) and cantonal tax (different in each canton). A third tax is calculated by multiplying the cantonal tax with a municipality-specific percentage rate. An additional contribution to the cantonal tax is given by the optional affiliation to a church.

Retirement age can be either explicitly provided as an input or inferred from the gender. In the latter case, age is set at 65 for male and 64 for females.

Disclaimer

While SmaRP was developed under the utmost care and diligence, Mirai Solutions does not guarantee for its accuracy and correctness. In addition, SmaRP is based on assumptions and projections and as such computed figures should be understood as general references and do not hold any legal value.

[^5]: For more information regarding the first pillar, check the official site here [^6]: All details of current legislation on the second Pillar can be found in German, French or Italian here

\newpage

Appendix 1: Methodology

2nd Pillar

The savings process for retirement benefits starts on January 1st following the year in which the person turns 24.

$$ PeS(t) = max(S(t) - \frac{7}{8} S_{AHV}(t), 0) $$ where

Contribution rates under the second Pillar are defined by law.[^8] \begin{center} \begin{tabular}{c | c | c | c | c } \hline & & & & \ Age & 25-34 & 35-44 & 45-54 & 55-64/65 \ \hline & & & & \ Contribution & 7\% & 10\% & 15\% & 18\% \ & & & & \ \hline \end{tabular} \end{center}

$$ MCon(t) = PeS(t) \cdot ConR(t) $$ where

$$ r = 1\% $$

$$ P_2 = \sum_{t=t_0}^T(MCon + VCon) * \exp^{r*(T - t)} $$ where

3rd Pillar

The private fund ($P_3$) at year $t$ is calculated as:

$$ P_3 (t)= \sum_{t=t_0}^TVCon * e^{r(T - t)} $$

where

Tax Benefit

Granted that the marginal tax rate is provided as an input, the tax benefits ($TBe$) at year $t$ is calculated as:

$$ TBe(t) = \sum_{t=t_0}^TVCon(t) * TR(t) * e^{r(T - t)} $$

where

The tax benefits are computed as[^10]:

$$ TBe(t) = Tax_{S}(t) - Tax_{inc}(t) $$ where

Taxable income ($I$) at time $t$ is computed as:

$$ I(t) = \max(S(t) - \min(TotalCon, MaxConTax), 0) $$

where

The TaxPaid function

The amount of taxes paid is the sum of the federal and cantonal taxes. Generally speaking, it is based on the taxable income at certain year $I(t)$ plus other personal factors.

Federal tax at year $t$ is computed as:

$$ FedTax(t) = \sum_{t=t_0}^T(I(t) \cdot FedTR) - 251 \cdot NC $$

where

Cantonal tax at year $t$ is computed as:

$$ KanTax(t) = \sum_{t=t_0}^T(I(t) \cdot KanTR) \cdot (F_{kanton} + F_{municipality} + F_{church}) $$

where

fkanton <- params$PLZGemeinden[params$PLZGemeinden$PLZ == params$postalcode, "FactorKanton"]
gemeinde_name <- params$PLZGemeinden[params$PLZGemeinden$PLZ == params$postalcode, "GDENAME"]
fgemeinde <- params$PLZGemeinden[params$PLZGemeinden$PLZ == params$postalcode, "FactorGemeinde"]
fkirche <- params$PLZGemeinden[params$PLZGemeinden$PLZ == params$postalcode, "FactorKirche"]

The canton-dependent multiplication factor for canton r params$Kanton is r fkanton.

The municipality-dependent multiplication factor for r gemeinde_name is r fgemeinde.

The church affiliation dependent multiplication factor for r gemeinde_name is r fkirche. In case of no church affiliation, this factor is 0.

[^7]: AHV salary as of 01.01.2018: 2350 month, 28200 year. Find official information here [^8]: 831.40. Bundesgesetz über die berufliche Alters-, Hinterlassenen- und Invalidenvorsorge (Art.16). [^9]: Minimum interest rate on the retirement assets since 01.01.2017. [^10]: The taxable income is calculated by subtracting the gross salary from social insurance contributions and other deductions. [^11]: Click here for more official information.

\newpage

Appendix 2: Tabular Results

Tabular results from calculations are shown in the following tables.

moncols <- c("Salary", "Occupational Fund", "Private Fund", "Tax Benefits") 
set.caption('Total Pension Fund')
Road2Retirement_to_print_Summarized <- Road2Retirement_to_print %>%
  mutate(`Tax Benefits` = TotalTax) %>%
  mutate(`Occupational Fund` = DirectP2 + ReturnP2) %>%
  mutate(`Private Fund` = DirectP3 + ReturnP3) %>%
  rename(`Salary` = ExpectedSalaryPath) %>%
  select(Calendar, `Salary`, `Occupational Fund`, `Private Fund`, `Tax Benefits`) %>%
  makeTable(moncols)
pander(Road2Retirement_to_print_Summarized)
if (show_text){
  moncols <- c("Direct Contribution", "Total Contribution", "Return", "Occupational Fund") 
  set.caption('Occupational Fund - 2nd Pillar')
  Road2Retirement_to_print_Pillar2 <- Road2Retirement_to_print %>%
    mutate(`Direct Contribution` = P2ContributionPath + P2purchase) %>% 
    rename(`Total Contribution` = DirectP2) %>%
    rename(`Return` = ReturnP2) %>%
    rename(`Occupational Fund` = TotalP2) %>%
    select(Calendar, `Direct Contribution`, `Total Contribution`, `Return`, `Occupational Fund`) %>%
    makeTable(moncols)
  pander(Road2Retirement_to_print_Pillar2)
}
moncols <- c("Direct Contribution", "Total Contribution", "Return", "Private Fund") 
set.caption('Private Fund - 3rd Pillar')
Road2Retirement_to_print_Pillar3 <- Road2Retirement_to_print %>%
  mutate(`Direct Contribution` = P3ContributionPath + P3purchase) %>% 
  rename(`Total Contribution` = DirectP3) %>%
  rename(`Return` = ReturnP3) %>%
  rename(`Private Fund` = TotalP3) %>%
  select(Calendar, `Direct Contribution`, `Total Contribution`, `Return`, `Private Fund`) %>%
  makeTable(moncols)
pander(Road2Retirement_to_print_Pillar3)
moncols <- c("Direct Tax", "Return Tax", "Total Tax") 
set.caption('Tax Benefits')
Road2Retirement_to_print_TaxBenefit <- Road2Retirement_to_print %>%
  rename(`Direct Tax` = DirectTax) %>%
  rename(`Return Tax` = ReturnTax) %>%
  rename(`Total Tax` = TotalTax) %>%
  select(Calendar, `Direct Tax`, `Return Tax`, `Total Tax`)%>%
  makeTable(moncols)
pander(Road2Retirement_to_print_TaxBenefit)

\newpage

Appendix 3: Notes on "Married double income"

In case of married couples with double income, the following considerations should be taken into account. Pension funds are individual (not familiar). However, the tax rates are familiar, i.e. number of children and marital status are considered. That implies that the user can perform two calculations, both with some level of inaccuracy.

  1. The user can simply enter all the information individually, without taking into account his partner. It that case, most likely, the tax rate will be underestimated and as a consequence the tax benefits generated.

  2. The user can enter the combined amount of all variables (salary, current assets and purchases). In this case, however, note that two simplifications have been taken into account.

  3. A 50% split of all monetary variables is assumed.

  4. Both members of the couple are the same age and will retire together.

Since these results vary on a case-by-case basis, it is appropriate to run SmaRP with respect to both options to achieve a more accurate understanding and assessment. However, assumptions in Option 2 belong to a very specific scenario and thus it is advisable for users with double income to accept results from Option 1.



miraisolutions/SmaRP documentation built on March 23, 2022, 6:46 a.m.