SMM.jl
Simulated Method of Moments (SMM) for Julia
A package providing supporting infrastructure and algorithms to perform Simulated Method of Moments.
Features
- Fully fledged SMM infrastructure to track moments and function evaluations.
- Supply your own objective function to be optimized.
- Optimization can be carried out in parallel.
- Diagnostic tools illustrating the proposal distribution as well as markov chain statistics.
- Includes a parellel tempering likelihood-free optimizer using MCMC technology and a coordinate descent optimizer.
For some example usage see the Examples page.
Manual Outline
MProb
: Minimisation/Maximisation Problems
- A core object of this library is the
MProb
type, specifying an optimisation problem.
SMM.MProb
— TypeMinimisation Problem: MProb
A moment minimsation problem is defined by an objective function that depends on a vector of unknown parameters params_to_sample
, and a set of datamoments moments
. The key idea here is the one of simulated method of moments, where we use params_to_sample
to simulate a model, some moments of which will be compared to moments from the data.
Fields:
initial_value
: initial parameter value as a dictparams_to_sample
:OrderedDict
with lower and upper boundsobjfunc
: objective functionobjfunc_opts
: options passed to the objective function, e.g. printlevelmoments
: a dictionary or dataframe of data moments to track
Example:
pb = Dict(p1" => [0.2,-2,2] , "p2" => [-0.2,-2,2] )
moms = DataFrame(name=["mu2","mu1"],value=[0.0,0.0],weight=rand(2))
m = MProb()
addSampledParam!(m,pb)
addMoment!(m,moms)
SMM.addEvalFunc!(m,SMM.objfunc_norm)
SMM.addMoment!
— MethodaddMoment!(m::MProb,name::String,value,weight)
SMM.addMoment!
— MethodaddMoment!(m::MProb,name::String,value)
SMM.addMoment!
— MethodaddMoment!(m::MProb,name::Symbol,value,weight)
Add Moments to an MProb
. Adds a single moment to the mprob.
name
: the name of the moment as a Symbol value
: value of the moment weight
: weight in the objective function
SMM.addMoment!
— MethodaddMoment!(m::MProb,name::Symbol,value)
SMM.addParam!
— MethodAdd initial parameter values to an MProb
minimisation problem.
SMM.addParam!
— MethodAdd initial parameter values to an MProb
minimisation problem.
Arguments:
p
: A Dict with (String,Number) pairs
SMM.addSampledParam!
— FunctionAdd parameters to be sampled to an MProb
.
d
: a Dict with a triple (init,lb,ub)
as value for each key.
SMM.addSampledParam!
— MethodAdd parameters to be sampled to an MProb
.
SMM.evaluateObjective
— MethodSMM.evaluateObjective
— MethodevaluateObjective(m::MProb,p::Union{Dict,OrderedDict};noseed=false)
Evaluate the objective function of an MProb
at a given parameter vector p
. Set noseed
to true
if you want to generate new random draws for shocks in the objective function (necessary for estimation of standard errors in get_stdErrors
, for example)
SMM.mapto_01
— Methodmapto_01(p::OrderedDict,lb::Vector{Float64},ub::Vector{Float64})
map param to [0,1]
SMM.mapto_ab
— Methodmapto_ab(p::Vector{Float64},lb::Vector{Float64},ub::Vector{Float64})
map param from [0,1] to [a,b]
SMM.ms_names
— MethodGet the name of moments
SMM.ps2s_names
— MethodGet sampled parameter names from the MProb
SMM.ps_names
— MethodGet all parameter names from the MProb