Package 'ecod025ps1'

Title: ECOD025 - Problem Set 1 about VAR, FA-VAR and DFM models. Install this from the R-Universe.
Description: Using armadillo4r for a straightforward implementation of an EM algorithm and the Kalman filter for DFM.
Authors: Mauricio Vargas Sepulveda [aut, cre] (ORCID: <https://orcid.org/0000-0003-1017-7574>)
Maintainer: Mauricio Vargas Sepulveda <[email protected]>
License: Apache License (>= 2)
Version: 0.1
Built: 2026-05-28 14:59:07 UTC
Source: https://github.com/pachadotdev/ecod025

Help Index


Dynamic Factor Model (DFM)

Description

Estimates a Dynamic Factor Model using PCA initialization and EM algorithm with Kalman filter.

Usage

dfm_model(x, n_factors, p, max_iter, tol, forecast_h)

Arguments

x

Matrix of observed variables (T x N)

n_factors

Number of latent factors (r < N)

p

VAR lag order for factor dynamics (0 for static model)

max_iter

Maximum EM iterations

tol

Convergence tolerance for log-likelihood

forecast_h

Forecast horizon (0 for no forecast)


Factor-Augmented VAR (FA-VAR) Model

Description

Estimates a FA-VAR model using PCA for factor extraction.

Usage

favar_model(y, n_lags, n_factors, p_y, p_f, include_const, forecast_h)

Arguments

y

Time series vector (T x 1)

n_lags

Number of lags of y to include in X for factor extraction

n_factors

Number of latent factors to extract (r < n_lags + 1)

p_y

VAR lag order for y dynamics

p_f

VAR lag order for factor dynamics

include_const

Include constant term in VARs

forecast_h

Forecast horizon (0 for no forecast)


Main VAR estimation function that returns everything

Description

Estimates a VAR model using OLS.

Usage

var_model(y, p, include_const, forecast_h)

Arguments

y

Time series vector (T x 1)

p

Lag order

include_const

Include constant term in VAR

forecast_h

Forecast horizon (0 for no forecast)