gmm_estimate: Generalised Method of Moments (GMM) Estimation

View source: R/moment-estimation.R

gmm_estimateR Documentation

Generalised Method of Moments (GMM) Estimation

Description

Estimates the free parameters of a linear DSGE model by matching model-implied moments to empirical moments from observed data. Model-implied moments are computed analytically via the Lyapunov solution of the state covariance.

Usage

gmm_estimate(
  model,
  data,
  moments,
  params_start,
  shock_sd_start,
  weight = NULL,
  lower = NULL,
  upper = NULL,
  method = "Nelder-Mead",
  control = list()
)

Arguments

model

A dsge_model object.

data

Matrix or data frame of observed variables; column names must match a subset of the model's observables.

moments

Character vector naming the moments to match. Each element uses the same naming convention as endogenous_prior:

  • "sd:<var>" – standard deviation of <var>.

  • "var:<var>" – variance of <var>.

  • "cov:<v1>:<v2>" – covariance between <v1> and <v2>.

  • "ac1:<var>" – lag-1 autocorrelation of <var>.

  • "cor:<v1>:<v2>" – contemporaneous correlation.

params_start

Named numeric vector of starting values for the structural parameters.

shock_sd_start

Named numeric vector of starting values for shock standard deviations.

weight

Optional positive-definite weighting matrix. Default identity (one-step GMM). Pass "optimal" to run a two-step estimator where the second-step weight is the inverse Newey-West covariance of the empirical moments.

lower, upper

Bounds (-Inf, Inf by default).

method

Optimiser method for optim. Default "Nelder-Mead".

control

optim control list.

Value

An object of class "dsge_gmm".

References

Hansen, L.P. (1982). Large sample properties of generalized method of moments estimators. Econometrica, 50(4), 1029-1054.

Examples


nk <- dsge_model(
  obs(p ~ beta * lead(p) + kappa * x),
  unobs(x ~ lead(x) - (r - lead(p) - g)),
  obs(r ~ psi * p + u),
  state(u ~ rhou * u),
  state(g ~ rhog * g),
  fixed = list(beta = 0.99),
  start = list(kappa = 0.1, psi = 1.5, rhou = 0.7, rhog = 0.9))
sol <- solve_dsge(nk,
  params   = c(kappa = 0.1, psi = 1.5, rhou = 0.7, rhog = 0.9),
  shock_sd = c(e.u = 1, e.g = 0.5))
set.seed(1)
H <- sol$H; G <- sol$G; M <- sol$M
TT <- 200
xst <- matrix(0, TT, nrow(H))
y_obs <- matrix(0, TT, nrow(G))
for (t in 2:TT) {
  e <- rnorm(ncol(M)) * c(1, 0.5)
  xst[t, ] <- as.numeric(H %*% xst[t-1, ] + M %*% e)
  y_obs[t, ] <- as.numeric(G %*% xst[t, ])
}
colnames(y_obs) <- rownames(G)
y_obs <- as.data.frame(y_obs[, nk$variables$observed])
est <- gmm_estimate(nk, y_obs,
  moments = c("sd:p","sd:r","ac1:p","ac1:r"),
  params_start   = c(kappa = 0.1, psi = 1.5, rhou = 0.7, rhog = 0.9),
  shock_sd_start = c(e.u = 1.0, e.g = 0.5),
  control = list(maxit = 100))
print(est)



dsge documentation built on Sept. 25, 2026, 5:08 p.m.