From 3d4be93efa6ae338e8f893c584f22ac779311307 Mon Sep 17 00:00:00 2001 From: WesIngwersen Date: Mon, 10 Nov 2025 15:28:45 -0500 Subject: [PATCH] Instead of just adjusting zero values in the sectors intersection with itself and it's output to 0.001 when the output is 0, also do this adjustment when output is negative before trying to invert the output vector --- R/IOFunctions.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/IOFunctions.R b/R/IOFunctions.R index d08087e1..f240a259 100644 --- a/R/IOFunctions.R +++ b/R/IOFunctions.R @@ -32,10 +32,10 @@ adjustOutputbyCPI <- function (outputyear, referenceyear, location_acronym, IsRo #' @return A matrix. normalizeIOTransactions <- function (IO_transactions_df, IO_output_df) { # Replace 0 in IO_transactions_df and IO_output_df with 1E-3 to avoid errors in solve(x_hat) - for (s in names(IO_output_df[IO_output_df == 0])){ + for (s in names(IO_output_df[IO_output_df <= 0])){ IO_transactions_df[s, s] <- 1E-3 } - IO_output_df[IO_output_df == 0] <- 1E-3 + IO_output_df[IO_output_df <= 0] <- 1E-3 Z <- as.matrix(IO_transactions_df) x <- unname(unlist(IO_output_df)) x_hat <- diag(x, length(x), length(x))