Add scenarios to a sfcr model.

sfcr_scenario(
  baseline,
  scenario,
  periods,
  max_iter = 350,
  tol = 1e-10,
  method = "Broyden",
  ...
)

Arguments

baseline

A model generated with the sfcr_baseline() function.

scenario

Either a shock created with sfcr_shock(), a list of shocks, or NULL. If scenario = NULL, the model will just extend the baseline model.

periods

A number specifying the total number of periods of the model to be simulated.

max_iter

Maximum iterations allowed per period.

tol

Tolerance accepted to determine convergence.

method

The method to use to find a solution. Defaults to "Broyden".

...

Extra arguments to pass to rootSolve::multiroot() function if "Newton" method is selected.

Details

Add scenario(s) to a model generated with sfcr_baseline() functions.

This function inherits the block structure from the steady state model. See sfcr_baseline for further details on the algorithms.

See also

Author

João Macalós, joaomacalos@gmail.com

Examples

eqs <- sfcr_set( TX_s ~ TX_d, YD ~ W * N_s - TX_s, C_d ~ alpha1 * YD + alpha2 * H_h[-1], H_h ~ YD - C_d + H_h[-1], N_s ~ N_d, N_d ~ Y / W, C_s ~ C_d, G_s ~ G_d, Y ~ C_s + G_s, TX_d ~ theta * W * N_s, H_s ~ G_d - TX_d + H_s[-1] ) external <- sfcr_set(G_d ~ 20, W ~ 1, alpha1 ~ 0.6, alpha2 ~ 0.4, theta ~ 0.2) # t is set to 10 to run faster. A usual model should run at least 50 periods to find a steady state steady_state <- sfcr_baseline(eqs, external, periods = 10) # Increase G_d from 20 to 30 between periods 5 and 10 shock1 <- sfcr_shock(sfcr_set(G_d ~ 30), 5, 10) sfcr_scenario(steady_state, scenario = list(shock1), 10)
#> # A tibble: 10 × 17 #> period TX_s YD C_d H_h N_s N_d C_s G_s Y TX_d H_s #> * <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 1 16.8 67.1 63.8 62.2 83.8 83.8 63.8 20 83.8 16.8 62.2 #> 2 2 17.3 69.1 66.3 64.9 86.3 86.3 66.3 20 86.3 17.3 64.9 #> 3 3 17.7 70.7 68.4 67.3 88.4 88.4 68.4 20 88.4 17.7 67.3 #> 4 4 18.0 72.2 70.2 69.2 90.2 90.2 70.2 20 90.2 18.0 69.2 #> 5 5 22.2 88.8 80.9 77.0 111. 111. 80.9 30 111. 22.2 77.0 #> 6 6 23.4 93.6 87.0 83.6 117. 117. 87.0 30 117. 23.4 83.6 #> 7 7 24.4 97.6 92.0 89.2 122. 122. 92.0 30 122. 24.4 89.2 #> 8 8 25.3 101. 96.3 94.0 126. 126. 96.3 30 126. 25.3 94.0 #> 9 9 26.0 104. 100. 98.0 130. 130. 100. 30 130. 26.0 98.0 #> 10 10 26.6 106. 103. 101. 133. 133. 103. 30 133. 26.6 101. #> # … with 5 more variables: G_d <dbl>, W <dbl>, alpha1 <dbl>, alpha2 <dbl>, #> # theta <dbl>
# Increase W to 2, alpha2 to 0.5, and decrease theta to 0.15 shock2 <- sfcr_shock( variables = sfcr_set( W ~ 2, alpha2 ~ 0.5, theta ~ 0.15 ), start = 5, end = 10) sfcr_scenario(steady_state, list(shock2), 10)
#> # A tibble: 10 × 17 #> period TX_s YD C_d H_h N_s N_d C_s G_s Y TX_d H_s #> * <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 1 16.8 67.1 63.8 62.2 83.8 83.8 63.8 20 83.8 16.8 62.2 #> 2 2 17.3 69.1 66.3 64.9 86.3 86.3 66.3 20 86.3 17.3 64.9 #> 3 3 17.7 70.7 68.4 67.3 88.4 88.4 68.4 20 88.4 17.7 67.3 #> 4 4 18.0 72.2 70.2 69.2 90.2 90.2 70.2 20 90.2 18.0 69.2 #> 5 5 16.7 94.7 91.5 72.5 55.7 55.7 91.5 20 111. 16.7 72.5 #> 6 6 17.2 97.6 94.8 75.3 57.4 57.4 94.8 20 115. 17.2 75.3 #> 7 7 17.6 100. 97.6 77.6 58.8 58.8 97.6 20 118. 17.6 77.6 #> 8 8 18.0 102. 100. 79.6 60.0 60.0 100. 20 120. 18.0 79.6 #> 9 9 18.3 104. 102. 81.3 61.0 61.0 102. 20 122. 18.3 81.3 #> 10 10 18.6 105. 104. 82.8 61.9 61.9 104. 20 124. 18.6 82.8 #> # … with 5 more variables: G_d <dbl>, W <dbl>, alpha1 <dbl>, alpha2 <dbl>, #> # theta <dbl>