estimate: Estimate a Linear DSGE Model by Maximum Likelihood

View source: R/estimate.R

estimateR Documentation

Estimate a Linear DSGE Model by Maximum Likelihood

Description

Estimates the parameters of a linear DSGE model by maximizing the log-likelihood computed via the Kalman filter.

Usage

estimate(
  model,
  data,
  start = NULL,
  fixed = NULL,
  method = "BFGS",
  control = list(),
  shock_start = NULL,
  demean = TRUE,
  hessian = TRUE,
  presample = 0L
)

Arguments

model

A dsge_model object created by dsge_model(), a dsgenl_model, or a Dynare model imported with read_dynare().

data

A data frame, matrix, or ts object containing the observed variables. Column names must match the observed control variable names in the model.

start

Named list of starting values for free parameters. Overrides any starting values specified in the model.

fixed

Named list of fixed parameter values. Overrides any fixed values specified in the model.

method

Optimization method passed to stats::optim(). Default is "BFGS".

control

Control list passed to stats::optim().

shock_start

Named numeric vector of starting values for shock standard deviations. If NULL, defaults are set based on data variability.

demean

Logical. If TRUE (default), observed variables are demeaned before estimation.

hessian

Logical. If TRUE (default), the Hessian is computed at the solution for standard errors.

presample

Integer. Number of initial observations used only to initialise the Kalman filter and excluded from the likelihood (as Dynare's presample option). Default 0; for a model imported with read_dynare(), the value in the file's estimation command.

Details

The estimator optimizes over the structural parameters and the log standard deviations of the shocks. Shock standard deviations are parameterized in log-space to ensure positivity.

If the optimizer encounters parameter values for which the model is not saddle-path stable, the log-likelihood is set to -Inf.

Value

An object of class "dsge_fit".

Examples


# Define a simple AR(1) model
m <- dsge_model(
  obs(y ~ z),
  state(z ~ rho * z),
  start = list(rho = 0.5)
)

# Simulate some data
set.seed(42)
e <- rnorm(200)
z <- numeric(200)
for (i in 2:200) z[i] <- 0.8 * z[i-1] + e[i]
dat <- data.frame(y = z)

fit <- estimate(m, data = dat)
summary(fit)



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