Very fast estimation of a small nonlinear model

Given a model and a prior on the parameters, one can generate a sample using a draw (\theta) from the prior, and compute a statistic vector. This can be done many times, giving many draws of the (\theta, Z) pair.

Using the draws, one can fit the mapping Z->theta using a neural net.

Then, to get an estimate with real data, use the real sample value of Z as the input, and use as the estimator the neural net’s fitted value of theta. Computing this estimator take virtually no time, because the estimator has an analytical expression.

Code which illustrates this is at … on_Example. A typical estimation using a sample of size 160, with timing, gives

true estimated
0.300000 0.300863
0.980000 0.980302
0.025000 0.024803
2.500000 2.287299
0.500000 0.489058
0.020000 0.019142
0.700000 0.712426
0.010000 0.012284
0.350000 0.352022

real 0m0.976s
user 0m1.100s
sys 0m1.272s

Another run, with different true parameter values is
true estimated
0.300000 0.299535
0.990000 0.991105
0.040000 0.041075
2.000000 1.925913
0.800000 0.811376
0.030000 0.032641
0.300000 0.253211
0.010000 0.012123
0.300000 0.302839

real 0m1.036s
user 0m1.064s
sys 0m1.344s

This code should be completely stand alone, and should run on Octave or Matlab (Dynare is required in either case). If you would like a direct link for a zip file, it’s …

Any comments or reports of problems running this with Matlab would be much appreciated!

I consolidated git archives. The code is now part of … ference.jl. See the DSGE/EstimationExample directory.

Can anyone confirm that the estimation example code runs on Matlab :question: