RBC model with Monopolistic Competition

library(gEcon)
RBCModel = make_model("rbc_RCBModel.gcn")
model parsed in 0.04s
model loaded in 0.07s

Set Free Parameter

RBCModel = set_free_par(RBCModel, c(beta = 0.99))
RBCModel = initval_var(RBCModel, list(L_s = 0.1))

RBCModel = steady_state(RBCModel, calibration = TRUE)
Steady state has been FOUND
get_ss_values(RBCModel, to_tex = FALSE)
Steady-state values:

      Steady-state value
pi                0.0619
pi_ps             0.0652
C                 0.5638
I                 0.1532
K                 6.1285
L_s               0.2492
P                 0.9091
P_MON             1.0000
PI                6.1904
PI_PS             0.0652
U              -145.1440
W                 1.7524
Y                 0.7171
Z                 1.0000

Estimate Perturbation Solution

RBCModel = solve_pert(RBCModel, loglin = TRUE)
Model has been SOLVED
get_pert_solution(RBCModel, to_tex = FALSE)

Matrix P:

    K[-1]  Z[-1]
K[] 0.958 0.0744
Z[] 0.000 0.9500


Matrix Q:

  epsilon_Z
K    0.0783
Z    1.0000


Matrix R:

          K[-1]   Z[-1]
pi[]     2.4086 -4.1777
pi_ps[]  0.2085  0.9179
C[]      0.4500  0.3585
I[]     -0.6804  2.9768
L_s[]   -0.1813  0.4200
P[]      0.0000  0.0000
P_MON[]  0.0000  0.0000
PI[]     0.9725  0.0319
PI_PS[]  0.2085  0.9179
U[]      0.0343  0.0442
W[]      0.3898  0.4979
Y[]      0.2085  0.9179


Matrix S:

      epsilon_Z
pi      -4.3976
pi_ps    0.9662
C        0.3773
I        3.1334
L_s      0.4421
P        0.0000
P_MON    0.0000
PI       0.0336
PI_PS    0.9662
U        0.0465
W        0.5241
Y        0.9662

Set Shock Distribution

RBCModel = set_shock_cov_mat(RBCModel, matrix(c(1), 1, 1), shock_order = "epsilon_Z")
RBCModel = compute_model_stats(RBCModel)
get_model_stats(RBCModel, variables = c("C", "I", "K", "L_s", "U", "W", "Y", "Z"),
    var_dec = FALSE, to_tex = FALSE)
Basic statistics:

    Steady-state value Std. dev. Variance Loglin
C               0.5638    0.5188   0.2691   Y   
I               0.1532    4.0905  16.7320   Y   
K               6.1285    0.3617   0.1308   Y   
L_s             0.2492    0.5797   0.3360   Y   
U            -145.1440    0.0619   0.0038   Y   
W               1.7524    0.6982   0.4875   Y   
Y               0.7171    1.2620   1.5927   Y   
Z               1.0000    1.3034   1.6990   Y   

Correlation matrix:

    C     I     K   L_s     U     W     Y     Z
C   1 0.929 0.573 0.908 0.993 0.993 0.967 0.950
I         1 0.229 0.999 0.966 0.965 0.993 0.998
K               1 0.177 0.473 0.474 0.344 0.287
L_s                   1 0.951  0.95 0.985 0.994
U                           1     1  0.99 0.980
W                                 1  0.99 0.979
Y                                       1 0.998
Z                                         1.000

Autocorrelations:

    Lag 1 Lag 2 Lag 3 Lag 4  Lag 5
C   0.760 0.545 0.357 0.196  0.063
I   0.710 0.465 0.264 0.103 -0.022
K   0.959 0.861 0.725 0.568  0.403
L_s 0.708 0.463 0.261 0.100 -0.025
U   0.738 0.510 0.316 0.156  0.026
W   0.738 0.510 0.317 0.156  0.026
Y   0.719 0.480 0.281 0.120 -0.007
Z   0.713 0.471 0.271 0.110 -0.016

Compute Correlations

RBCModel_non_hp = compute_model_stats(RBCModel, lambda = 0)
get_model_stats(RBCModel_non_hp, variables = c("C", "I", "K", "L_s", "U", "W", "Y",
    "Z"), var_dec = FALSE, to_tex = FALSE)
Basic statistics:

    Steady-state value Std. dev. Variance Loglin
C               0.5638    2.7633   7.6358   Y   
I               0.1532    8.4869  72.0273   Y   
K               6.1285    4.0317  16.2550   Y   
L_s             0.2492    1.0854   1.1781   Y   
U            -145.1440    0.2617   0.0685   Y   
W               1.7524    2.9592   8.7567   Y   
Y               0.7171    3.7017  13.7022   Y   
Z               1.0000    3.2026  10.2564   Y   

Correlation matrix:

    C     I     K   L_s     U     W     Y     Z
C   1 0.722 0.959 0.498 0.994 0.994 0.941 0.869
I         1 0.495 0.959 0.792 0.791 0.914 0.970
K               1  0.23 0.922 0.923 0.805 0.692
L_s                   1 0.588 0.586 0.762 0.862
U                           1     1 0.972 0.917
W                                 1 0.971 0.916
Y                                       1 0.985
Z                                         1.000

Autocorrelations:

    Lag 1 Lag 2 Lag 3 Lag 4 Lag 5
C   0.990 0.980 0.968 0.955 0.941
I   0.929 0.863 0.801 0.743 0.688
K   0.999 0.996 0.991 0.984 0.976
L_s 0.913 0.832 0.756 0.686 0.620
U   0.984 0.967 0.950 0.933 0.915
W   0.984 0.968 0.951 0.933 0.915
Y   0.965 0.932 0.899 0.868 0.837
Z   0.950 0.903 0.857 0.815 0.774

Compute IRFs

irfplot = compute_irf(RBCModel, variables = c("C", "Z", "Y", "L_s", "W", "K"))
# plot_simulation(irfplot, to_eps = TRUE)

Simulation

simplot = random_path(RBCModel, sim_length = 100, variables = c("C", "Z", "Y", "L_s",
    "W", "K"))
# plot_simulation(simplot, to_eps = TRUE)

Summary

summary(RBCModel)

Steady state:
                 
pi       0.061904
pi_ps    0.065187
C        0.563842
I        0.153212
K        6.128497
L_s      0.249233
P        0.909091
P_MON    1.000000
PI       6.190401
PI_PS    0.065187
U     -145.143972
W        1.752384
Y        0.717055
Z        1.000000

----------------------------------------------------------

Parameter values:
            
alpha  0.330
beta   0.990
delta  0.025
eta    2.000
mu     0.300
phi    0.950
rho   11.000

----------------------------------------------------------

Linearisation:
x_t = P x_{t-1} + Q epsilon_t
y_t = R x_{t-1} + S epsilon_t

P:
       K[-1]    Z[-1]
K[] 0.957989 0.074419
Z[] 0.000000 0.950000

Q:
  epsilon_Z
K  0.078336
Z  1.000000

R:
            K[-1]     Z[-1]
pi[]     2.408598 -4.177725
pi_ps[]  0.208498  0.917910
C[]      0.450046  0.358462
I[]     -0.680431  2.976752
L_s[]   -0.181346  0.420015
P[]      0.000000  0.000000
P_MON[]  0.000000  0.000000
PI[]     0.972495  0.031897
PI_PS[]  0.208498  0.917910
U[]      0.034339  0.044189
W[]      0.389844  0.497895
Y[]      0.208498  0.917910

S:
      epsilon_Z
pi    -4.397605
pi_ps  0.966221
C      0.377329
I      3.133423
L_s    0.442121
P      0.000000
P_MON  0.000000
PI     0.033576
PI_PS  0.966221
U      0.046515
W      0.524100
Y      0.966221

----------------------------------------------------------

Shock covariance matrix:

          epsilon_Z
epsilon_Z         1

Basic statistics:

      Steady-state value Std. dev.  Variance Loglin
pi                0.0619    5.7938   33.5676   Y   
pi_ps             0.0652     1.262    1.5927   Y   
C                 0.5638    0.5188    0.2691   Y   
I                 0.1532    4.0905    16.732   Y   
K                 6.1285    0.3617    0.1308   Y   
L_s               0.2492    0.5797     0.336   Y   
P                 0.9091         0         0   Y   
P_MON                  1         0         0   Y   
PI                6.1904    0.3547    0.1258   Y   
PI_PS             0.0652     1.262    1.5927   Y   
U               -145.144    0.0619    0.0038   Y   
W                 1.7524    0.6982    0.4875   Y   
Y                 0.7171     1.262    1.5927   Y   
Z                      1    1.3034     1.699   Y   

Correlation matrix:

      pi  pi_ps      C      I     K    L_s    PI  PI_PS      U      W      Y
pi     1 -0.978 -0.892 -0.996 -0.14 -0.999 0.022 -0.978 -0.938 -0.938 -0.978
pi_ps         1  0.967  0.993 0.344  0.985 0.187      1   0.99   0.99      1
C                    1  0.929 0.573  0.908 0.433  0.967  0.993  0.993  0.967
I                           1 0.229  0.999 0.068  0.993  0.966  0.965  0.993
K                                 1  0.177 0.987  0.344  0.473  0.474  0.344
L_s                                      1 0.015  0.985  0.951   0.95  0.985
PI                                             1  0.187  0.324  0.326  0.187
           Z
pi    -0.989
pi_ps  0.998
C       0.95
I      0.998
K      0.287
L_s    0.994
PI     0.128
 [ reached 'max' / getOption("max.print") -- omitted 5 rows ]

Autocorrelations:

      Lag 1 Lag 2 Lag 3 Lag 4  Lag 5
pi    0.708 0.462 0.261 0.099 -0.026
pi_ps 0.719 0.480 0.281 0.120 -0.007
C     0.760 0.545 0.357 0.196  0.063
I     0.710 0.465 0.264 0.103 -0.022
K     0.959 0.861 0.725 0.568  0.403
L_s   0.708 0.463 0.261 0.100 -0.025
PI    0.964 0.869 0.735 0.578  0.412
PI_PS 0.719 0.480 0.281 0.120 -0.007
U     0.738 0.510 0.316 0.156  0.026
W     0.738 0.510 0.317 0.156  0.026
Y     0.719 0.480 0.281 0.120 -0.007
Z     0.713 0.471 0.271 0.110 -0.016

Variance decomposition:

      epsilon_Z
pi            1
pi_ps         1
C             1
I             1
K             1
L_s           1
PI            1
PI_PS         1
U             1
W             1
Y             1
Z             1