Bayesian Quasi-Likelihood
Estimation of nonlinear GMM involves the use of optimization solvers. An alternative approach that circumvents the need for such solvers treats the criterion function as a quasi-likelihood function for tracing out quasi-posterior functions of the parameters, using a Markov Chain Monte Carlo (MCMC) method (Chernozhukov and Hong, 2003). Specifically, we multiply the criterion function shown in Generalized Method of Moments by $-\frac{1}{2}$ to obtain the quasi-likelihood.
MethodOfMoments.jl provides support for incorporating the quasi-likelihood evaluation in a MCMC sampler by implementing the LogDensityProblems.jl interface. This allows the users to leverage readily available MCMC samplers from the Julia ecosystem without the need to defining the quasi-likelihood functions from scratch. For example, packages such as AdvancedMH.jl for Metropolis-Hastings algorithms recognize the capability of MethodOfMoments.jl for evaluating the log-density.
Example: Defining Log-Density for MCMC
We reuse the data and specifications from Example: Exponential Regression with Instruments.
# Assume objects from previous example are already defined
using Distributions
params = (:private=>Uniform(-1,2), :chronic=>Uniform(-1,2),
:female=>Uniform(-1,2), :income=>Uniform(-1,2), :cons=>Normal())
m = BayesianGMM(vce, g, dg, params, 7, length(data))
BayesianGMM with 7 moments and 5 parameters:
private = 1.58101e-322 chronic = 0.00000e+00 female = 0.00000e+00 income = 0.00000e+00 cons = 7.01467e-313
log(posterior) = NaN
Above, we provide the names of each parameter and their prior distributions using distributions defined in Distributions.jl. A BayesianGMM
contains the ingredients required for computing the log-posterior:
θ = [0.5, 1, 1, 0.1, 0.1]
logposterior!(m, θ)
-5.321068026621552
To run a Metropolis-Hastings sampler, we may proceed as follows:
using AdvancedMH, MCMCChains, LinearAlgebra
spl = MetropolisHastings(RandomWalkProposal{true}(MvNormal(zeros(5), 0.5*I(5))))
N = 10_000
chain = sample(m, spl, N, init_params=θ, param_names=m.params, chain_type=Chains)
Chains MCMC chain (10000×6×1 Array{Float64, 3}):
Iterations = 1:1:10000
Number of chains = 1
Samples per chain = 10000
parameters = private, chronic, female, income, cons
internals = lp
Use `describe(chains)` for summary statistics and quantiles.