Skip to content

DC 2R models fail #15

Description

@WesIngwersen

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.

useeior/R/IOFunctions.R

Lines 33 to 42 in 1565a70

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions