Building a 2R model for DC (District of Columbia) fails
2025-11-10 14:11:38.659461 INFO::Initializing Chain Price Index tables...
Error in solve.default(x_hat) :
system is computationally singular: reciprocal condition number = 1.73848e-18
The failure can be traced back to the attempt to compute CPI for commodities and the need to estimate a market shares matrix to do so to transform industry CPI. The commodity output vector cannot be inverted due to a negative value for output for one commodity, which is very near 0 but slightly less than 0.
|
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])){ |
|
IO_transactions_df[s, s] <- 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)) |
|
A <- Z %*% solve(x_hat) |
Building a 2R model for DC (District of Columbia) fails
The failure can be traced back to the attempt to compute CPI for commodities and the need to estimate a market shares matrix to do so to transform industry CPI. The commodity output vector cannot be inverted due to a negative value for output for one commodity, which is very near 0 but slightly less than 0.
useeior/R/IOFunctions.R
Lines 33 to 42 in 1565a70