1 Small Test Grid Search Solution

This is the example vignette for function: snw_vfi_main_grid_search from the PrjOptiSNW Package. This function solves for policy function using grid search. Small Solution Analysis. Small Solution Analysis, husband 5 shocks, wife 1 shocks.

1.1 Test SNW_VFI_MAIN_GRID_SEARCH Defaults Small

Call the function with defaults parameters.

mp_param = snw_mp_param('default_small');
[V_VFI,ap_VFI,cons_VFI,mp_valpol_more] = snw_vfi_main_grid_search(mp_param);

SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:18 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:17 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:16 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:15 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:14 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:13 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:12 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:11 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:10 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:9 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:8 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:7 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:6 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:5 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:4 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:3 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:2 of 18
SNW_VFI_MAIN_GRID_SEARCH: Finished Age Group:1 of 18
Elapsed time is 6.771761 seconds.
Completed SNW_VFI_MAIN_GRID_SEARCH;SNW_MP_PARAM=default_small;SNW_MP_CONTROL=default_base

1.2 Small Param Results Define Frames

Define the matrix dimensions names and dimension vector values. Policy and Value Functions share the same ND dimensional structure.

% Grids:
age_grid = [19, 22:5:97, 100];
agrid = mp_param('agrid')';
eta_H_grid = mp_param('eta_H_grid')';
eta_S_grid = mp_param('eta_S_grid')';
ar_st_eta_HS_grid = string(cellstr([num2str(eta_H_grid', 'hz=%3.2f;'), num2str(eta_S_grid', 'wz=%3.2f')]));
edu_grid = [0,1];
marry_grid = [0,1];
kids_grid = (1:1:mp_param('n_kidsgrid'))';
% NaN(n_jgrid,n_agrid,n_etagrid,n_educgrid,n_marriedgrid,n_kidsgrid);
cl_mp_datasetdesc = {};
cl_mp_datasetdesc{1} = containers.Map({'name', 'labval'}, {'age', age_grid});
cl_mp_datasetdesc{2} = containers.Map({'name', 'labval'}, {'savings', agrid});
cl_mp_datasetdesc{3} = containers.Map({'name', 'labval'}, {'Hshock', eta_H_grid});
cl_mp_datasetdesc{4} = containers.Map({'name', 'labval'}, {'edu', edu_grid});
cl_mp_datasetdesc{5} = containers.Map({'name', 'labval'}, {'marry', marry_grid});
cl_mp_datasetdesc{6} = containers.Map({'name', 'labval'}, {'kids', kids_grid});

1.3 Analyze Savings and Shocks

First, analyze Savings Levels and Shocks, Aggregate Over All Others, and do various other calculations.

% Generate some Data
mp_support_graph = containers.Map('KeyType', 'char', 'ValueType', 'any');
mp_support_graph('cl_st_xtitle') = {'Savings States, a'};
mp_support_graph('st_legend_loc') = 'best';
mp_support_graph('bl_graph_logy') = true; % do not log

MEAN(VAL(A,Z)), MEAN(AP(A,Z)), MEAN(C(A,Z))

Tabulate value and policies along savings and shocks:

% Set
% NaN(n_jgrid,n_agrid,n_etagrid,n_educgrid,n_marriedgrid,n_kidsgrid);
ar_permute = [1,4,5,6,3,2];
% Value Function
tb_az_v = ff_summ_nd_array("MEAN(VAL(A,Z))", V_VFI, true, ["mean"], 4, 1, cl_mp_datasetdesc, ar_permute);

xxx  MEAN(VAL(A,Z))  xxxxxxxxxxxxxxxxxxxxxxxxxxx
    group     savings     mean_Hshock__1_8395    mean_Hshock__0_91976    mean_Hshock_0    mean_Hshock_0_91976    mean_Hshock_1_8395
    _____    _________    ___________________    ____________________    _____________    ___________________    __________________

      1              0          -17.723                 -9.4806             -4.7079             -1.8282                -0.2506     
      2      0.0097656          -17.287                 -9.3335             -4.6223             -1.7575               -0.18381     
      3       0.078125          -15.289                 -8.5102             -4.1607             -1.3897                0.15884     
      4        0.26367          -12.169                 -7.0906             -3.3823            -0.82837                0.65605     
      5          0.625          -8.7667                 -5.3975             -2.4071            -0.24676                 1.1271     
      6         1.2207          -5.7445                 -3.6744             -1.4216             0.29453                 1.5213     
      7         2.1094          -3.3257                  -2.112            -0.53821             0.80697                 1.8359     
      8         3.3496          -1.5195                -0.81731             0.22515              1.2742                 2.0887     
      9              5         -0.20516                 0.20391             0.87016              1.6615                 2.3015     
     10         7.1191          0.74607                 0.98431              1.4069              1.9813                 2.4914     
     11         9.7656           1.4347                  1.5779              1.8454              2.2495                 2.6581     
     12         12.998           1.9367                  2.0246              2.1961              2.4767                    2.8     
     13         16.875           2.3099                   2.364               2.476              2.6699                 2.9198     
     14         21.455           2.5887                  2.6239              2.6967              2.8321                 3.0216     
     15         26.797           2.7998                  2.8231              2.8727              2.9673                 3.1096     
     16         32.959            2.963                  2.9785              3.0123              3.0792                  3.186     
     17             40           3.0902                  3.1009              3.1242              3.1721                 3.2523     
     18         47.979           3.1902                  3.1978              3.2144              3.2489                 3.3096     
     19         56.953             3.27                  3.2754              3.2875              3.3128                 3.3588     
     20         66.982           3.3345                  3.3384              3.3471              3.3661                 3.4012     
     21         78.125           3.3871                  3.3899              3.3964              3.4105                 3.4375     
     22         90.439           3.4301                  3.4323              3.4372              3.4479                 3.4688     
     23         103.98           3.4658                  3.4674              3.4712              3.4794                 3.4957     
     24         118.82           3.4957                  3.4969              3.4998              3.5062                  3.519     
     25            135           3.5208                  3.5218               3.524              3.5289                 3.5391     

% Aprime Choice
tb_az_ap = ff_summ_nd_array("MEAN(AP(A,Z))", ap_VFI, true, ["mean"], 4, 1, cl_mp_datasetdesc, ar_permute);

xxx  MEAN(AP(A,Z))  xxxxxxxxxxxxxxxxxxxxxxxxxxx
    group     savings     mean_Hshock__1_8395    mean_Hshock__0_91976    mean_Hshock_0    mean_Hshock_0_91976    mean_Hshock_1_8395
    _____    _________    ___________________    ____________________    _____________    ___________________    __________________

      1              0               1                  1.1435              1.5972              2.5926                  4.162      
      2      0.0097656          1.0463                   1.213              1.6574              2.6157                 4.1667      
      3       0.078125          1.8009                  2.0093              2.1991               2.875                 4.3056      
      4        0.26367          2.9491                  3.0648              3.2454              3.6204                 4.7315      
      5          0.625          4.0602                  4.1806              4.2546              4.5417                 5.4074      
      6         1.2207          5.1481                  5.2454              5.2731              5.4074                 6.0231      
      7         2.1094          6.1389                   6.213                6.25              6.2593                 6.7731      
      8         3.3496          7.0556                  7.1019              7.1713               7.162                 7.5648      
      9              5          7.9537                  7.9815              8.0556              8.0787                 8.3426      
     10         7.1191          8.8611                  8.8889              8.9398              9.0093                 9.0926      
     11         9.7656          9.7824                  9.7963              9.8519              9.9259                 9.9444      
     12         12.998          10.606                   10.63              10.648              10.731                 10.787      
     13         16.875          11.481                  11.491              11.537              11.597                 11.685      
     14         21.455          12.407                  12.407              12.431              12.491                 12.597      
     15         26.797          13.287                  13.301              13.306              13.356                 13.463      
     16         32.959           14.13                   14.13              14.167              14.199                 14.296      
     17             40          14.981                  14.981              14.991              15.032                 15.125      
     18         47.979           15.88                   15.88              15.884              15.921                 15.995      
     19         56.953           16.75                  16.773              16.782              16.796                  16.87      
     20         66.982          17.681                  17.685              17.699              17.722                 17.787      
     21         78.125          18.495                    18.5              18.509              18.551                 18.602      
     22         90.439          19.338                  19.338              19.352               19.37                 19.449      
     23         103.98           20.25                  20.264              20.269              20.278                 20.352      
     24         118.82          21.097                  21.097               21.13              21.144                 21.194      
     25            135          21.963                  21.968              21.977              21.995                 22.046      

% Consumption Choices
tb_az_c = ff_summ_nd_array("MEAN(C(A,Z))", cons_VFI, true, ["mean"], 4, 1, cl_mp_datasetdesc, ar_permute);

xxx  MEAN(C(A,Z))  xxxxxxxxxxxxxxxxxxxxxxxxxxx
    group     savings     mean_Hshock__1_8395    mean_Hshock__0_91976    mean_Hshock_0    mean_Hshock_0_91976    mean_Hshock_1_8395
    _____    _________    ___________________    ____________________    _____________    ___________________    __________________

      1              0          0.30277                0.43205              0.70498             1.2497                 2.3063      
      2      0.0097656          0.31384                0.44176              0.71311             1.2574                 2.3169      
      3       0.078125          0.38061                0.49936                0.768             1.3132                 2.3716      
      4        0.26367          0.50208                 0.6111              0.86902              1.423                  2.516      
      5          0.625          0.67677                0.76238               1.0363             1.5854                 2.6625      
      6         1.2207          0.89732                0.96685               1.2492             1.8485                 2.9934      
      7         2.1094           1.2189                 1.2789                1.543             2.2417                   3.35      
      8         3.3496           1.6892                 1.7561               1.9651             2.6933                 3.7969      
      9              5           2.3251                 2.4024               2.5736             3.2505                 4.4588      
     10         7.1191           3.1269                 3.1903               3.3745             3.9408                 5.4846      
     11         9.7656           4.0839                 4.1689               4.3128              4.829                 6.5432      
     12         12.998           5.4106                  5.457               5.6873             6.1291                 7.7117      
     13         16.875           6.9612                 7.0462               7.1563             7.6332                 9.0535      
     14         21.455           8.5924                 8.7131               8.8962             9.3301                 10.603      
     15         26.797             10.6                 10.647               10.911             11.348                 12.539      
     16         32.959           13.149                 13.269                13.33             13.839                 14.999      
     17             40           16.034                 16.154               16.378             16.792                 17.899      
     18         47.979           18.971                 19.092               19.343             19.756                 20.923      
     19         56.953           22.573                 22.485                22.69             23.274                 24.367      
     20         66.982           26.089                 26.168               26.322             26.797                 27.905      
     21         78.125           30.843                 30.917               31.101              31.36                 32.556      
     22         90.439           35.929                 36.049               36.177             36.667                 37.477      
     23         103.98           40.986                 40.918               41.144             41.731                 42.514      
     24         118.82           47.072                 47.192               47.018             47.525                 48.539      
     25            135           53.493                 53.538               53.682             54.096                 55.054      

Graph Mean Values:

mp_support_graph('cl_st_graph_title') = {'MEAN(value(a,z)), a=x, z=color'};
mp_support_graph('cl_st_ytitle') = {'MEAN(value(a,z))'};
ff_graph_grid((tb_az_v{1:end, 3:end})', ar_st_eta_HS_grid, agrid, mp_support_graph);

Graph Mean Savings Choices:

mp_support_graph('cl_st_graph_title') = {'MEAN(APRIME(a,z)), a=x, z=color'};
mp_support_graph('cl_st_ytitle') = {'MEAN(APRIME(a,z))'};
ff_graph_grid((tb_az_ap{1:end, 3:end})', ar_st_eta_HS_grid, agrid, mp_support_graph);

Graph Mean Consumption:

mp_support_graph('cl_st_graph_title') = {'MEAN(C(a,z)), a=x, z=color'};
mp_support_graph('cl_st_ytitle') = {'MEAN(C(a,z))'};
ff_graph_grid((tb_az_c{1:end, 3:end})', ar_st_eta_HS_grid, agrid, mp_support_graph);

1.4 Analyze Kids and Marriage and Age

Aggregating over education, savings, and shocks, what are the differential effects of Marriage and Age.

% Generate some Data
mp_support_graph = containers.Map('KeyType', 'char', 'ValueType', 'any');
ar_row_grid = ["k0M0", "K1M0", "K2M0", "k0M1", "K1M1", "K2M1"];
mp_support_graph('cl_st_xtitle') = {'Age'};
mp_support_graph('st_legend_loc') = 'best';
mp_support_graph('bl_graph_logy') = true; % do not log
mp_support_graph('st_rounding') = '6.2f'; % format shock legend
mp_support_graph('cl_scatter_shapes') = { 'o', 'd' ,'s', 'o', 'd', 's'};
mp_support_graph('cl_colors') = {'red', 'red', 'red', 'blue', 'blue', 'blue'};

MEAN(VAL(KM,J)), MEAN(AP(KM,J)), MEAN(C(KM,J))

Tabulate value and policies:

% Set
% NaN(n_jgrid,n_agrid,n_etagrid,n_educgrid,n_marriedgrid,n_kidsgrid);
ar_permute = [2,3,4,1,6,5];
% Value Function
tb_az_v = ff_summ_nd_array("MEAN(VAL(KM,J))", V_VFI, true, ["mean"], 3, 1, cl_mp_datasetdesc, ar_permute);

xxx  MEAN(VAL(KM,J))  xxxxxxxxxxxxxxxxxxxxxxxxxxx
    group    kids    marry    mean_age_19    mean_age_22    mean_age_27    mean_age_32    mean_age_37    mean_age_42    mean_age_47    mean_age_52    mean_age_57    mean_age_62    mean_age_67    mean_age_72    mean_age_77    mean_age_82    mean_age_87    mean_age_92    mean_age_97    mean_age_100
    _____    ____    _____    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ____________

      1       1        0          1.402         1.6857          1.8728        1.9257          1.894         1.8046         1.6765          1.521         1.3445         1.1558          0.9567       0.71704       0.023702        0.12932         0.1935         0.2324            0.27        0.31342  
      2       2        0       -0.12483        0.36646          0.7436        0.9457         1.0402         1.0532         1.0089        0.92218        0.80354        0.66431         0.51986       0.30396       -0.48224       -0.32022       -0.20441       -0.12064       -0.046895       0.029025  
      3       3        0       -0.89708       -0.41863       -0.032067       0.18508        0.29597        0.33212        0.31608        0.26209        0.18086       0.082298       -0.023782      -0.21383        -1.1266        -0.8627       -0.64664       -0.47726        -0.33746        -0.1892  
      4       1        1          1.967         2.1822          2.3218        2.3638         2.3393         2.2644         2.1513         2.0064          1.832         1.6337          1.4095        1.1397        0.66739         0.6334        0.58559        0.54789         0.52562        0.51422  
      5       2        1        0.96762         1.2863          1.5349        1.6741          1.739         1.7415         1.6951         1.6078         1.4838          1.329          1.1418       0.90125        0.43962          0.438        0.42018        0.40748         0.40166        0.40636  
      6       3        1        0.51874         0.8123          1.0493        1.1855         1.2514         1.2646         1.2376         1.1769         1.0862        0.96852         0.81856       0.61623        0.17742        0.22234        0.24837        0.27222         0.29305        0.32582  

% Aprime Choice
tb_az_ap = ff_summ_nd_array("MEAN(AP(KM,J))", ap_VFI, true, ["mean"], 3, 1, cl_mp_datasetdesc, ar_permute);

xxx  MEAN(AP(KM,J))  xxxxxxxxxxxxxxxxxxxxxxxxxxx
    group    kids    marry    mean_age_19    mean_age_22    mean_age_27    mean_age_32    mean_age_37    mean_age_42    mean_age_47    mean_age_52    mean_age_57    mean_age_62    mean_age_67    mean_age_72    mean_age_77    mean_age_82    mean_age_87    mean_age_92    mean_age_97    mean_age_100
    _____    ____    _____    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ____________

      1       1        0        12.948         12.924         13.052         13.152         13.224         13.264          13.26         13.144         13.036         12.944         12.848         12.716          11.76          11.48          10.98          10.22          8.98             1      
      2       2        0        12.924          12.88         13.008         13.096          13.16         13.108             13         12.916         12.828         12.768         12.708         12.532          11.68          11.32           10.8           9.96          8.78             1      
      3       3        0         12.86         12.848         12.972         13.084         13.108         13.024          12.94          12.86         12.792         12.736         12.692         12.516          11.64          11.32           10.8           9.98          8.82             1      
      4       1        1         12.86         12.856         12.972         13.076          13.14         13.184         13.156         13.048         12.948          12.84          12.78         12.728          11.76           11.4          10.88             10           8.8             1      
      5       2        1        12.876          12.82         12.956         13.028           13.1         13.124         13.012         12.888         12.784         12.696          12.68          12.58          11.64          11.32           10.7           9.92          8.64             1      
      6       3        1        12.804         12.784         12.912         12.984          13.06         13.036          12.92         12.812         12.716         12.644         12.644         12.524          11.66          11.28           10.7           9.92          8.64             1      

% Consumption Choices
tb_az_c = ff_summ_nd_array("MEAN(C(KM,J))", cons_VFI, true, ["mean"], 3, 1, cl_mp_datasetdesc, ar_permute);

xxx  MEAN(C(KM,J))  xxxxxxxxxxxxxxxxxxxxxxxxxxx
    group    kids    marry    mean_age_19    mean_age_22    mean_age_27    mean_age_32    mean_age_37    mean_age_42    mean_age_47    mean_age_52    mean_age_57    mean_age_62    mean_age_67    mean_age_72    mean_age_77    mean_age_82    mean_age_87    mean_age_92    mean_age_97    mean_age_100
    _____    ____    _____    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ____________

      1       1        0        6.6347         6.7441         6.9773         7.1425         7.2307         7.2843         7.9778          9.774          10.91         11.532         11.822         12.591         14.484         16.598         20.123         24.389         29.942          41.087   
      2       2        0        6.6476         6.7581         6.9904         7.1656         7.2723         8.8488         10.314         11.204         11.744         11.996          12.11         14.207         15.012         17.933         21.133         25.463         30.711          41.087   
      3       3        0        6.6679         6.7696         7.0001         7.1694         7.8468         9.5068         10.698         11.387         11.816         12.031         12.411         14.361         15.226         17.933         21.133          25.34         30.698          41.087   
      4       1        1         6.885         7.0096         7.2673         7.4584         7.5792         7.6332         8.5309         10.294         11.362          12.04         12.305         13.082         14.784         17.354         20.535         24.838         30.413          41.428   
      5       2        1         6.856          6.987         7.2319         7.4245         7.5481         7.8087         9.6961           11.1         11.855         12.287         12.414         13.963         15.314         17.886         21.524         25.522         31.072           41.43   
      6       3        1        6.8672         6.9855         7.2175         7.4148         7.5346         8.6883         10.344         11.392         12.015         12.358         12.399         14.136         15.326         18.258         21.536         25.535         31.085          41.443   

Graph Mean Values:

mp_support_graph('cl_st_graph_title') = {'MEAN(value(KM,J)), a=age, z=kids+marry'};
mp_support_graph('cl_st_ytitle') = {'MEAN(value(KM,J))'};
ff_graph_grid((tb_az_v{1:end, 4:end}), ar_row_grid, age_grid, mp_support_graph);

Graph Mean Savings Choices:

mp_support_graph('cl_st_graph_title') = {'MEAN(APRIME(KM,J)), a=x, z=color'};
mp_support_graph('cl_st_ytitle') = {'MEAN(APRIME(KM,J))'};
ff_graph_grid((tb_az_ap{1:end, 4:end}), ar_row_grid, age_grid, mp_support_graph);

Graph Mean Consumption:

mp_support_graph('cl_st_graph_title') = {'MEAN(C(KM,J)), a=x, z=color'};
mp_support_graph('cl_st_ytitle') = {'MEAN(C(KM,J))'};
ff_graph_grid((tb_az_c{1:end, 4:end}), ar_row_grid, age_grid, mp_support_graph);

1.5 Analyze Education and Marriage and Age

Aggregating over education, savings, and shocks, what are the differential effects of Marriage and Age.

% Generate some Data
mp_support_graph = containers.Map('KeyType', 'char', 'ValueType', 'any');
ar_row_grid = ["E0M0", "E1M0", "E0M1", "E1M1"];
mp_support_graph('cl_st_xtitle') = {'Age'};
mp_support_graph('st_legend_loc') = 'best';
mp_support_graph('bl_graph_logy') = true; % do not log
mp_support_graph('st_rounding') = '6.2f'; % format shock legend
mp_support_graph('cl_scatter_shapes') = {'*', 'p', '*','p' };
mp_support_graph('cl_colors') = {'red', 'red', 'blue', 'blue'};

MEAN(VAL(EKM,J)), MEAN(AP(EKM,J)), MEAN(C(EKM,J))

Tabulate value and policies:

% Set
% NaN(n_jgrid,n_agrid,n_etagrid,n_educgrid,n_marriedgrid,n_kidsgrid);
ar_permute = [2,3,6,1,4,5];
% Value Function
tb_az_v = ff_summ_nd_array("MEAN(VAL(EKM,J))", V_VFI, true, ["mean"], 3, 1, cl_mp_datasetdesc, ar_permute);

xxx  MEAN(VAL(EKM,J))  xxxxxxxxxxxxxxxxxxxxxxxxxxx
    group    edu    marry    mean_age_19    mean_age_22    mean_age_27    mean_age_32    mean_age_37    mean_age_42    mean_age_47    mean_age_52    mean_age_57    mean_age_62    mean_age_67    mean_age_72    mean_age_77    mean_age_82    mean_age_87    mean_age_92    mean_age_97    mean_age_100
    _____    ___    _____    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ____________

      1       0       0       -0.28978       0.072789        0.36537        0.53629        0.6243         0.64554        0.61621         0.548         0.45147        0.33899        0.22549       0.048783       -0.70881       -0.49468       -0.33241        -0.21328      -0.11371       -0.0092708 
      2       1       0        0.54315         1.0162         1.3575         1.5014        1.5291          1.4811         1.3848        1.2555          1.1011        0.92928        0.74303        0.48933       -0.34798       -0.20772       -0.10596       -0.030386      0.037469          0.11144 
      3       0       1        0.77529          1.038         1.2458         1.3693        1.4312          1.4402         1.4059        1.3343          1.2298         1.0982        0.93763        0.72438        0.29041        0.32237        0.33295         0.34258       0.35288          0.37357 
      4       1       1         1.5269         1.8159         2.0249         2.1129        2.1219          2.0734         1.9835        1.8598          1.7049         1.5227         1.3089         1.0471        0.56587        0.54012        0.50314         0.47581       0.46067          0.45737 

% Aprime Choice
tb_az_ap = ff_summ_nd_array("MEAN(AP(EKM,J))", ap_VFI, true, ["mean"], 3, 1, cl_mp_datasetdesc, ar_permute);

xxx  MEAN(AP(EKM,J))  xxxxxxxxxxxxxxxxxxxxxxxxxxx
    group    edu    marry    mean_age_19    mean_age_22    mean_age_27    mean_age_32    mean_age_37    mean_age_42    mean_age_47    mean_age_52    mean_age_57    mean_age_62    mean_age_67    mean_age_72    mean_age_77    mean_age_82    mean_age_87    mean_age_92    mean_age_97    mean_age_100
    _____    ___    _____    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ____________

      1       0       0        12.989         12.979         13.035         13.093         13.131         13.077         13.019         12.931         12.845         12.784         12.688         12.517         11.693         11.373         10.867         10.067           8.88            1      
      2       1       0        12.832         12.789         12.987         13.128         13.197         13.187         13.115         13.016         12.925         12.848         12.811         12.659         11.693         11.373         10.853          10.04           8.84            1      
      3       0       1        12.933         12.923         12.976         13.021         13.072         13.075         12.979         12.875         12.779         12.691         12.648         12.533         11.693         11.333         10.787         9.9467         8.7333            1      
      4       1       1         12.76         12.717         12.917         13.037         13.128         13.155          13.08         12.957         12.853         12.763         12.755         12.688          11.68         11.333         10.733         9.9467         8.6533            1      

% Consumption Choices
tb_az_c = ff_summ_nd_array("MEAN(C(EKM,J))", cons_VFI, true, ["mean"], 3, 1, cl_mp_datasetdesc, ar_permute);

xxx  MEAN(C(EKM,J))  xxxxxxxxxxxxxxxxxxxxxxxxxxx
    group    edu    marry    mean_age_19    mean_age_22    mean_age_27    mean_age_32    mean_age_37    mean_age_42    mean_age_47    mean_age_52    mean_age_57    mean_age_62    mean_age_67    mean_age_72    mean_age_77    mean_age_82    mean_age_87    mean_age_92    mean_age_97    mean_age_100
    _____    ___    _____    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ___________    ____________

      1       0       0        6.6262           6.69         6.8285         6.9343         7.2515         8.4199          9.548         10.625         11.323         11.684         11.977         13.656         14.889         17.471         20.779         25.083         30.429           41.07   
      2       1       0        6.6738         6.8246         7.1501         7.3841         7.6483         8.6734         9.7786         10.952         11.657         12.022         12.252         13.783         14.925         17.506         20.814         25.046         30.472          41.105   
      3       0       1        6.8114         6.8929         7.0479         7.1732           7.26         7.8099         9.3966         10.734         11.535         12.007         12.163         13.648         15.089         17.779         21.123         25.243         30.792          41.376   
      4       1       1        6.9273         7.0952         7.4299          7.692          7.848         8.2769          9.651         11.123         11.953          12.45         12.582         13.806         15.194         17.886         21.273         25.354         30.922          41.491   

Graph Mean Values:

mp_support_graph('cl_st_graph_title') = {'MEAN(value(EM,J)), a=age, z=kids+marry'};
mp_support_graph('cl_st_ytitle') = {'MEAN(value(EM,J))'};
ff_graph_grid((tb_az_v{1:end, 4:end}), ar_row_grid, age_grid, mp_support_graph);

Graph Mean Savings Choices:

mp_support_graph('cl_st_graph_title') = {'MEAN(APRIME(EK,J)), a=x, z=color'};
mp_support_graph('cl_st_ytitle') = {'MEAN(APRIME(EK,J))'};
ff_graph_grid((tb_az_ap{1:end, 4:end}), ar_row_grid, age_grid, mp_support_graph);

Graph Mean Consumption:

mp_support_graph('cl_st_graph_title') = {'MEAN(C(EK,J)), a=x, z=color'};
mp_support_graph('cl_st_ytitle') = {'MEAN(C(EK,J))'};
ff_graph_grid((tb_az_c{1:end, 4:end}), ar_row_grid, age_grid, mp_support_graph);