
Simulate a scenario of household lifetime finances
Source:R/simulate_scenario.R
simulate_scenario.Rd
The function simulates a scenario of household lifetime finances
and returns a tibble
with nested columns.
By default no Monte Carlo samples are generated, and only
single sample based on portfolio expected returns are returned with
column sample
=0
.
If the additional Monte Carlo samples are generated, they have
consecutive IDs starting from 1 in the sample
column.
Usage
simulate_scenario(
household,
portfolio,
scenario_id = "default",
current_date = get_current_date(),
monte_carlo_samples = NULL,
seeds = NULL,
use_cache = FALSE,
debug = FALSE,
...
)
Arguments
- household
An R6 object of class
Household
.- portfolio
A nested
tibble
of classPortfolio
.- scenario_id
A character. ID of the scenario.
- current_date
A character. Current date in the format
YYYY-MM-DD
. By default, it is the output ofget_current_date()
.- monte_carlo_samples
An integer. Number of Monte Carlo samples. If
NULL
(default), no Monte Carlo samples are generated.- seeds
An integer vector. Seeds for the random number generator used to generate random portfolio returns for each Monte Carlo sample. If
NULL
(default), random seed is generated automatically.- use_cache
A logical. If
TRUE
, the function uses memoised functions to speed up the simulation. The results are cached in the folder set byset_cache()
.- debug
A logical. If
TRUE
, additional information is printed during the simulation.- ...
Additional arguments passed simulation functions.
Value
A tibble
with nested columns including:
scenario_id
- (character) ID of the scenariosample
- (integer) ID of the Monte Carlo sampleindex
- (integer) year index starting from 0years_left
- (integer) years left to the end of the household lifespandate
- (date) date afterindex
years from the current dateyear
- (integer) calendar yearsurvival_prob
- (double) survival probability of the householdmembers
- (nested tibble) data of each member in the householdincome
- (nested tibble) income streamstotal_income
- (double) total income of the household from all income streamsspending
- (nested tibble) non-discretionary spending streamsnondiscretionary_spending
- (double) total non-discretionary spending of the household from all non-discretionary spending streamshuman_capital
- (double) human capital of the householdliabilities
- (double) liabilities of the householdportfolio
- (nested tibble) state of investment portfoliofinancial_wealth
- (double) financial wealth of the household at the beginning of the yearnet_worth
- (double) net worth of the householddiscretionary_spending
- (double) optimal discretionary spending of the householdtotal_spending
- (double) total spending of the household (discretionary + non-discretionary)financial_wealth_end
- (double) financial wealth of the household at the end of the yearrisk_tolerance
- (double) risk tolerance of the householdsmooth_consumption_preference
- (double) smooth consumption preference of the householdconsumption_impatience_preference
- (double) consumption impatience preference of the householdtime_value_discount
- (double) time value discount based on consumption impatience of the householddiscretionary_spending_utility
- (double) discretionary spending utility of the household based on the smooth consumption preferencediscretionary_spending_utility_weighted
- (double) discretionary spending utility of the household weighted by survival probability and time value discount.
Examples
if (FALSE) { # interactive()
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(
"members$older$age <= 65 ~ 7000 * 12"
)
)
household$expected_spending <- list(
"spending" = c(
"TRUE ~ 5000 * 12"
)
)
portfolio <- create_portfolio_template()
portfolio$accounts$taxable <- c(10000, 30000)
portfolio <-
portfolio |>
calc_effective_tax_rate(
tax_rate_ltcg = 0.20,
tax_rate_ordinary_income = 0.40
)
scenario <-
simulate_scenario(
household = household,
portfolio = portfolio,
current_date = "2020-07-15"
)
names(scenario)
}