estim_wrap: Estimation of the D-DFM model for given data and model...

View source: R/estimation_tools.R

estim_wrapR Documentation

Estimation of the D-DFM model for given data and model specification

Description

estim_wrap estimates the model for a given data matrix and a vector of Kronecker indices. The user must also specify the maximum number of iterations used for the estimation as well as the convergence criterion.

Usage

estim_wrap(
  df,
  nu,
  degs = NULL,
  maxit = 250,
  conv_crit = 0.001,
  init0 = 1,
  verbose = TRUE,
  h = 50
)

Arguments

df

T x n data matrix, where T and n are the time series and cross-sectional dimensions, respectively

nu

q-dimensional vector of Kronecker indices

degs

Optional, vector of length 2, defining the lag orders of c(z) and d(z)

maxit

Maximum number of iterations in the estimation procedure, defaults to 250

conv_crit

Convergence criterion in the estimation, defaults to 1e-3

init0

For the estimation of initial values, specify either

  1. a positive integer, with init0 = 1: "no bootstrap"; or

  2. a positive integer, with init0 > 1: "number of bootstrap draws"; or

  3. a list of elements containing pre-specified initial values of the SSM and (q x q) covariance matrix of error term in state equation

verbose

Should the estimation process be printed?

h

The IRF horizon

Value

a list of elements

Sigma

The (q x q) reduced form residual covariance matrix

ll_val

The log-likelihood value of the model

conv_stat

Convergence criterion and the model log-likelihood value for every iteration of the EM algorithm

npar

The number of estimated parameters in c(z) and d(z)

aic

Akaike IC for the model

bic

Bayesian IC for the model

hqic

Hannan-Quinn IC for the model

rmfd_final

The final model in rmfd format

irf

The estimated raw impulse response function in an array

Examples

df <- FRED_light$df
# small Kronecker index dimension, should converge fast
nu <- c(1,1)
est_obj <- estim_wrap(df = df, nu = nu)
# graphical analysis of the convergence of the EM algorithm
## Not run: 
# create data frame containing the number of iterations, log-likelihood
# value of the model for given iteration and the convergence
# criterion for plotting purposes
d <- data.frame("iter" = 1:length(est_obj$conv_stat$ll_value),
                "loglik" = est_obj$conv_stat$ll_value,
                "conv.log10" = est_obj$conv_stat$conv_cr %>% log10)
opar <- par()$mar # save default plot setup
par(mar = c(5,5,2,5))
with(d, plot(iter, conv.log10, type="l", col="red3",
             ylab=expression(log[10](italic(Delta))),
             ylim=c(-3,0)))
par(new = T)
with(d, plot(iter, loglik, pch=1, axes=F, xlab=NA, ylab=NA, cex=1.2))
axis(side = 4)
mtext(side = 4, line = 3, 'model log likelihood value')
legend("topleft",
       legend=c(expression(log[10](italic(Delta))), "log-likelihood"),
       lty=c(1,0), pch=c(NA, 1), col=c("red3", "black"))
# reset graphical parameters to default
par(new = FALSE, mar = opar)
## End(Not run)

juhokalle/rmfd4dfm documentation built on July 18, 2024, 10:19 p.m.