From 838642a056fc4dd6d4e63cb5c9175675fe8496cf Mon Sep 17 00:00:00 2001 From: Franz Mohr Date: Sat, 16 Dec 2023 10:00:56 +0100 Subject: [PATCH] Automatically add constant for sv, if not specified. --- R/add_priors.bvarmodel.R | 5 +++++ R/add_priors.bvecmodel.R | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/R/add_priors.bvarmodel.R b/R/add_priors.bvarmodel.R index 8389951..fe2bb4e 100644 --- a/R/add_priors.bvarmodel.R +++ b/R/add_priors.bvarmodel.R @@ -601,6 +601,11 @@ add_priors.bvarmodel <- function(object, if (object[[i]][["model"]][["sv"]]) { object[[i]][["initial"]][["sigma"]][["h"]] <- log(matrix(u, nrow = NCOL(y), ncol = NROW(y), byrow = TRUE)) object[[i]][["initial"]][["sigma"]][["sigma_h"]] <- matrix(sigma[["sigma_h"]], NROW(y)) + + if (is.null(sigma[["constant"]])) { + warning("Argument 'sigma$constant' not specified. Using the value 0.0001.") + sigma[["constant"]] <- .0001 + } object[[i]][["initial"]][["sigma"]][["constant"]] <- matrix(sigma[["constant"]], NROW(y)) } else { object[[i]][["initial"]][["sigma"]][["sigma_i"]] <- diag(1 / u, NROW(y)) diff --git a/R/add_priors.bvecmodel.R b/R/add_priors.bvecmodel.R index e4e6607..35ee8c1 100644 --- a/R/add_priors.bvecmodel.R +++ b/R/add_priors.bvecmodel.R @@ -706,6 +706,11 @@ add_priors.bvecmodel <- function(object, if (object[[i]][["model"]][["sv"]]) { object[[i]][["initial"]][["sigma"]][["h"]] <- log(matrix(u, nrow = NCOL(y), ncol = NROW(y), byrow = TRUE)) object[[i]][["initial"]][["sigma"]][["sigma_h"]] <- matrix(sigma[["sigma_h"]], NROW(y)) + + if (is.null(sigma[["constant"]])) { + warning("Argument 'sigma$constant' not specified. Using the value 0.0001.") + sigma[["constant"]] <- .0001 + } object[[i]][["initial"]][["sigma"]][["constant"]] <- matrix(sigma[["constant"]], NROW(y)) } else { object[[i]][["initial"]][["sigma"]][["sigma_i"]] <- diag(1 / u, NROW(y))