Have just rolled out CustomModelStats to all the stationary general equilibrium and calibration commands. Works for InfHorz and FHorz, and with/without PTypes.
Basic idea is that you can write a command:
myStats()
that outputs a structure, call it CustomStats, with the values of your ‘custom’ statistics, call them myStat1 and myStat2. So inside the command myStats() you set CustomStats.myStat1 and CustomStats.myStat2.
If you want to use them in stationary general eqm, you set
heteroagentoptions.CustomModelStats=@() myStats()
and you can then use myStat1 and myStat2 in (intermediateEqns and) GeneralEqmEqns.
If you want to use them in calibration, you set
caliboptions.CustomModelStats=@() myStats()
and you can then use myStat1 and myStat2 as targets, putting their ‘data version’ in TargetMoments.CustomModelStats.myStat1 and TargetMoments.CustomModelStats.myStat2
The inputs to CustomModelStats are hardcoded, and depend InfHorz/FHorz, and on PTypes. If you are using
InfHorz: the inputs to CustomModelStats are
myStats(V,Policy,StationaryDist,Parameters,FnsToEvaluate,n_d,n_a,n_z,N_j,d_grid,a_grid,z_grid,pi_z,caliboptions,vfoptions,simoptions)
FHorz: the inputs to CustomModelStats are (just add N_j)
myStats(V,Policy,StationaryDist,Parameters,FnsToEvaluate,n_d,n_a,n_z,N_j,d_grid,a_grid,z_grid,pi_z,caliboptions,vfoptions,simoptions)
InfHorz with PType: the inputs to CustomModelStats are (just add Names_i)
myStats(V,Policy,StationaryDist,Parameters,FnsToEvaluate,n_d,n_a,n_z,Names_i,d_grid,a_grid,z_grid,pi_z,caliboptions,vfoptions,simoptions)
FHorz with PType: the inputs to CustomModelStats are (just add N_j, Names_i)
myStats(V,Policy,StationaryDist,Parameters,FnsToEvaluate,n_d,n_a,n_z,N_j,Names_i,d_grid,a_grid,z_grid,pi_z,caliboptions,vfoptions,simoptions)
[The input caliboptions is when you use caliboptions.CustomModelStats and should be replaced with heteroagentoptions when you set heteroagentoptions.CustomModelStats]
Hopefully this is enough to let you calculate any kind of model statistics you can think of, that can then be used as part of stationary general eqm or for calibration. Note, if you need any other input you can always ‘hide’ it in caliboptions (or heteroagentoptions, as appropriate).
This allows for all sorts of things. Two examples, you could use the statistic ‘expected value fn of firm w.r.t. distribution of unemployed households’ as part of a free-entry condition set up as a GeneralEqmEqn. Or you can simulate panel data and run regressions inside myStats(), and thus calibrate model parameters so you get the same regression results you did in real-world panel data [if this was estimation instead of calibration it would be “Indirect Inference”].