sfcr_scenario: Add scenarios to a 'sfcr' model.

Description Usage Arguments Details Author(s) See Also Examples

View source: R/sfcr_scenario.R

Description

Add scenarios to a sfcr model.

Usage

1
2
3
4
5
6
7
8
9
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.

Author(s)

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

See Also

sfcr_baseline

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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)

# 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)

sfcr documentation built on Oct. 11, 2021, 9:09 a.m.