plot_scenarios {R4GoodPersonalFinances}R Documentation

Plot scenarios metrics

Description

The plot allows to compare metrics for multiple scenarios.

If scenarios are simulated without Monte Carlo samples, so they are based only on expected returns of portfolio, two metrics are available for each scenario:

If scenarios are simulated with additional Monte Carlo samples, there are four more metrics available per scenario:

Usage

plot_scenarios(scenarios, period = c("yearly", "monthly"))

Arguments

scenarios

A tibble with nested columns - the result of simulate_scenarios().

period

A character. The amounts can be shown as yearly values (default) or averaged per month values.

Value

A ggplot2::ggplot() object.

Examples


older_member <- HouseholdMember$new(
  name       = "older",  
  birth_date = "1980-02-15",
  mode       = 80,
  dispersion = 10
)  
household <- Household$new()
household$add_member(older_member)  

household$expected_income <- list(
  "income" = c(
    "is_not_on('older', 'retirement') ~ 7000 * 12"
  )
)
household$expected_spending <- list(
  "spending" = c(
    "TRUE ~ 4000 * 12"
  )
)

portfolio <- create_portfolio_template() 
portfolio$accounts$taxable <- c(100000, 300000)
portfolio <- 
  portfolio |> 
  calc_effective_tax_rate(
    tax_rate_ltcg = 0.20, 
    tax_rate_ordinary_income = 0.40
  )

start_ages <- c(60, 65, 75)
scenarios_parameters <- 
  tibble::tibble(
    member    = "older",
    event      = "retirement",
    start_age = start_ages,
    years     = Inf,
    end_age   = Inf
   ) |> 
  dplyr::mutate(scenario_id = start_age) |> 
  tidyr::nest(events = -scenario_id)

scenarios <- 
  simulate_scenarios(
    scenarios_parameters = scenarios_parameters,
    household            = household,
    portfolio            = portfolio,
    maxeval              = 100,
    current_date         = "2020-07-15"
  )

plot_scenarios(scenarios, "monthly")


[Package R4GoodPersonalFinances version 1.0.0 Index]