View source: R/moment-estimation.R
| gmm_estimate | R Documentation |
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.
gmm_estimate(
model,
data,
moments,
params_start,
shock_sd_start,
weight = NULL,
lower = NULL,
upper = NULL,
method = "Nelder-Mead",
control = list()
)
model |
A |
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
|
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 |
lower, upper |
Bounds ( |
method |
Optimiser method for |
control |
|
An object of class "dsge_gmm".
Hansen, L.P. (1982). Large sample properties of generalized method of moments estimators. Econometrica, 50(4), 1029-1054.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.