Description Usage Arguments Details Value
TODO: CLEAN THIS UP
calc_cf
is a wrapper function for the cpp function that calculates the
model counterfactual described in the paper for a given set of data and a
shock.
1 2 3 4 5 6 7 8 9 10 |
data |
a list of model variables possibly derived from
|
shock |
a list containing a shock with values
|
tol |
tolerance for algorithm to stop |
zeta |
dampening factor |
maxiter |
maximum number of iterations |
method |
either matrix or RHS |
nthreads |
number of threads to use in parallel. This relies on OpenMP and thus has no effect on MacOS. |
The main purpose of this function is twofold. Firstly to do some basic checks and input manipulations (e.g. from character to numeric) before calling the cpp code. Secondly, the main set of market clearing equations of the model can be solved as a linear equation system at each step of the iterative counterfactual solution algorithm or one can directly use right hand side values of R. The former converges much faster and is more stable in converging but problematic when the simulation involves shocks with infinitely high trade barriers (preventing a matrix inversion to sole the linear system). Therefore this function also decides which cpp algorithm to pick based upon the shock.
Returns a list of R_hat, P_hat, multres, multres_tmp, R_div, P_hat_div, C_hat, Q_hat, D_prime, L_prime, L_tilde_hat, c_hat, pi_hat
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.