From 760b93e0d6c8b1d59c8de1cd93d6deaf1ea04c76 Mon Sep 17 00:00:00 2001 From: mitchelloharawild Date: Tue, 1 Oct 2024 20:32:14 +1000 Subject: [PATCH] Fix VECM with constants and AR(p=0) --- R/vecm.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/vecm.R b/R/vecm.R index dad7a84a..59c7bc26 100644 --- a/R/vecm.R +++ b/R/vecm.R @@ -2,7 +2,7 @@ train_vecm <- function(.data, specials, ic, ...) { # Get args p <- specials$AR[[1]]$p - + # Get response variables y <- invoke(cbind, unclass(.data)[measured_vars(.data)]) @@ -29,11 +29,11 @@ estimate_vecm <- function(y, p, sr_xreg, constant, r, ...) { } dy <- diff(y) - if (p > 0) { + # if (p > 0) { # y <- y[-seq_len(p), , drop = FALSE] # dy <- dy[-seq_len(p), , drop = FALSE] - sr_xreg <- sr_xreg[-seq_len(p + 1), , drop = FALSE] - } + # } + sr_xreg <- sr_xreg[-seq_len(p + 1), , drop = FALSE] y_embed <- stats::embed(y, dimension = p + 1) dy_embed <- stats::embed(dy, dimension = p + 1)