MomentOpt.jl
Simulated Method of Moments for Julia
A package providing supporting infrastructure and algorithms to perform Simulated Method of Moments.
Features
- 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.
MomentOpt.MProb
— Type.Minimisation 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)
MomentOpt.addEvalFunc!(m,MomentOpt.objfunc_norm)
MomentOpt.addMoment!
— Method.addMoment!(m::MProb,name::String,value,weight)
MomentOpt.addMoment!
— Method.addMoment!(m::MProb,name::String,value)
MomentOpt.addMoment!
— Method.addMoment!(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
MomentOpt.addMoment!
— Method.addMoment!(m::MProb,name::Symbol,value)
MomentOpt.addParam!
— Method.Add initial parameter values to an MProb
minimisation problem.
MomentOpt.addParam!
— Method.Add initial parameter values to an MProb
minimisation problem.
Arguments:
p
: A Dict with (String,Number) pairs
MomentOpt.addSampledParam!
— Function.Add parameters to be sampled to an MProb
.
d
: a Dict with a triple (init,lb,ub)
as value for each key.
MomentOpt.addSampledParam!
— Method.Add parameters to be sampled to an MProb
.
MomentOpt.evaluateObjective
— Method.MomentOpt.evaluateObjective
— Method.evaluateObjective(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)
MomentOpt.mapto_01
— Method.mapto_01(p::OrderedDict,lb::Vector{Float64},ub::Vector{Float64})
map param to [0,1]
MomentOpt.mapto_ab
— Method.mapto_ab(p::Vector{Float64},lb::Vector{Float64},ub::Vector{Float64})
map param from [0,1] to [a,b]
MomentOpt.ms_names
— Method.Get the name of moments
MomentOpt.ps2s_names
— Method.Get sampled parameter names from the MProb
MomentOpt.ps_names
— Method.Get all parameter names from the MProb