View and download the notebook here!
Method of Simulated Moments Criterion
respy can construct a criterion function for estimation with the Method of Simulated Moments (MSM) (McFadden, 1989) that can easily be passed on to an optimizer for estimation. MSM estimation requires a number of calibration choices and respy’s interface is designed to allow users as much flexibility as possible when setting up a criterion function for estimation. This guide discusses the functions of the interface with focus on the different options for specifying inputs. For a concise
overview of all functions, we refer users to the respy API.
API
For all functions see respy API.
Introductory Example
The following section discusses all the arguments of the interface’s core function get_moment_errors_func
in detail using an example model. The function processes all arguments needed for estimation such as the empirical moments and weighting matrix to construct a functools.partial
which only requires the parameter vector as input and is thus ideal to use for optimization.
MSM Criterion Function
We can now construct the criterion function for estimation. get_moment_errors_func
will return a function that holds all elements but the params
argument fixed and can thus easily be passed on to an optimizer. The function will return a value of 0 if we use the true parameter vector as input.
Using a different parameter vector will result in a value different from 0.
If we set return_scalar
to False, the function will return the a dictionary with more extensive information instead.
dict_keys(['value', 'root_contributions', 'comparison_plot_data', 'simulated_moments'])
Examples of the dictionary entries are shown below:
array([ 0.178, 0.204, 0.196, 0.168, 0.165, 0.133, 0.072, 0.048,
-0.006, 0.012])
|
moment_column |
moment_index |
value |
moment_set |
kind |
0 |
a |
0 |
0.428 |
0 |
empirical |
1 |
a |
1 |
0.476 |
0 |
empirical |
2 |
a |
2 |
0.493 |
0 |
empirical |
3 |
a |
3 |
0.481 |
0 |
empirical |
4 |
a |
4 |
0.488 |
0 |
empirical |
|
a |
b |
edu |
home |
mean |
std |
Period |
|
|
|
|
|
|
0 |
0.250 |
0.013 |
0.0 |
0.737 |
18656.778322 |
2466.027332 |
1 |
0.272 |
0.009 |
0.0 |
0.719 |
18471.207370 |
2383.080064 |
2 |
0.297 |
0.012 |
0.0 |
0.691 |
18540.220326 |
2161.267108 |
3 |
0.313 |
0.011 |
0.0 |
0.676 |
18750.979003 |
2491.027312 |
4 |
0.323 |
0.009 |
0.0 |
0.668 |
18891.761467 |
2626.142919 |