Macro

The Macro module contains classes that contain parameters common to all households, generate stochastic processes for returns and wages and other prices.

class CPR.macro.CommonParameters(nsim, non_stochastic, extra_params)

This class sets and contains the parameters common to all households.

Parameters
  • nsim (int) – number of simulations

  • non_stochastic (bool) – True if non stochastic simulation, False otherwise

  • extra_params (dict) – dictionary of extra parameters

set_limits(name)

Set contributions limits for RRSP and TFSA.

Parameters

name (str) – RRSP or TFSA

prepare_ympe()

” Pre-reform ympe used to adjust DB benefits for CPP

prepare_cpp()

Set percentages for cpp/qpp benefits.

class CPR.macro.Prices(common, extra_params)

This class computes the times series for asset returns, interest rates on debt, deterministic wage profiles, housing price growth rate and price/rent ratio.

Parameters
  • common (Common) – instance of the class Common

  • extra_params (dict) – dictionary of extra parameters

simulate_ret(asset, common)

Simulate N series of length T nominal returns distributed lognormally with autocorrelation rho.

Parameters
  • asset (str) – type of asset

  • common (Common) – instance of the class Common

Returns

Array of nominal returns

Return type

numpy.array

compute_params_process(mu, rho, sigma)

Convert arithmetic mean mu and volatility sigma of the returns and autocorrelation rho of the log returns into \(\alpha\), \(\rho\) and \(\sigma_{\epsilon}\) of the process:

\(\ln(1+r_t) = \alpha + \rho * \ln(1+r_{t-1}) + \epsilon\), where \(\epsilon \sim N(0, \sigma_{\epsilon})\).

Parameters
  • mu (float) – arithmetic mean

  • rho (float) – autocorrelation :math:

  • sigma (float) – standard deviation

Returns

  • float – AR(1) coefficient (\(\alpha\))

  • float – Standard deviation of error term (\(\sigma_{\epsilon}\))

simulate_housing(common)

Simulate series of nominal housing price growth (in \(\ln(1+r)\) form) and price-rent ratio.

Parameters

common (Common) – instance of the class Common

Returns

  • numpy.array – Array of nominal housing price growth

  • numpy.array – Array of price-rent ratios

prepare_inflation_factors(common)

Compute inflation factors with base year 2018.

Parameters

common (Common) – instance of the class Common

Returns

Dictionary of inflation factors for each year

Return type

dict

simulate_interest_debt()

Creates N series of yearly nominal interest rate of length T for each type of debt

Returns

Dictionary of interest rates by type of debt and year

Return type

dict

attach_diff_log_wages()

Creates a dictionary of differences in log wages by education and age.

Returns

Dictionary of difference in log wages by education and age

Return type

dict

initialize_factors()

This function creates an instance of life.table by gender and province.

Returns

dictionary of annuity factors by gender and provinces

Return type

dict