8000 Import BEA Supply and Use tables by MoLi7 · Pull Request #238 · USEPA/useeior · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Import BEA Supply and Use tables #238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Jul 19, 2023
Merged

Import BEA Supply and Use tables #238

merged 44 commits into from
Jul 19, 2023

Conversation

MoLi7
Copy link
Collaborator
@MoLi7 MoLi7 commented Aug 22, 2022
  • Download and save BEA Supply and Use tables at Detail, Summary, and Sector levels
  • Refactor related functions to adapt to the SUTs
  • Adds Tau: A dataframe of basic to producer price ratio

R/LoadIOTables.R Outdated
@@ -150,6 +153,9 @@ loadIOcodes <- function(specs) {
"GovernmentDemand"),
"Codes")],
use.names = FALSE)
if (specs$BasePriceType == "BAS") {
io_codes$FinalDemandCodes <- io_codes$FinalDemandCodes[!io_codes$FinalDemandCodes %in% io_codes$ImportCodes]
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

io_codes needs further refactoring to handle sectors in SUTs' Use table, because BEA code of 'V002 - Taxes on production and imports, less subsidies' is broken down to the following three sectors in SUTs' Use table.

  • T00OTOP - Other taxes on production, which is part of VA in BAS
  • T00TOP - Taxes on products and imports, which is part of VA in PRO
  • T00SUB - Less: Subsidies, which is part of VA in PRO

Considering modifying schema info tables

R/IOFunctions.R Outdated
UseSUT_BAS <- UseSUT_PRO - sweep(ratio_m,
MARGIN = 1,
STATS = tax_less_subsidies,
FUN = "*")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tax less subsidies was allocated across columns in each row of UseSUT_PRO based on consumption of each commodity (row) by industries (columns).

@MoLi7
Copy link
Collaborator Author
MoLi7 commented Sep 23, 2022

@WesIngwersen I figured that the comm/ind output validation failed because UseBAS was not correctly generated because of margins.

The proposed approach used margins matrix calculated from (UsePUR - UsePRO), both in Make-Use framework, to convert UseSUT_PUR to UseSUT_PRO, but I found that total margins by commodity summed from the matrix do not equal to total margins calculated from the TRADE and TRANS columns in Supply.

Knowing that the output from Supply equals to the output from Use when they are in PUR and BAS, and that the conversion from PUR to BAS used TRADE and TRANS columns in Supply, I would propose to use margins values summed from TRADE and TRANS columns in Supply, allocate them to columns based on the margins matrix calculated from (UsePUR - UsePRO), then subtract the matrix from UseSUT_PUR. This will ensure the totals are balanced and the industry-specific margins effect is preserved.

# Allocate margins_Supply throughout Use based on margins matrix
margins_ratio_m <- margins/rowSums(margins)
margins_ratio_m[is.na(margins_ratio_m)] <- 1/ncol(margins_ratio_m)
UseSUT_PRO <- UseSUT_PUR[rows, cols] - diag(margins_Supply) %*% as.matrix(margins_ratio_m)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8000

This change closes the gap (with diff of +/- $10 Mill.) between commodity output from Supply and that from Use, both in BAS. But there still are noticeable gaps between industry output because the PUR->PRO->BAS conversion adjusted Use by columns but not rows.

I think a RAS balance is needed after the price type conversion, the target row sums will be industry output in BAS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scratch what I said about RAS balance above.

In fact, industry output summed from UseSUT_BAS can never equal to output summed from Supply (BAS), because by definition, industry output (BAS) = intermediate consumption (PUR) + value added (BAS), see excerpts from the BEA tables below.

  • Use
    Screen Shot 2022-09-23 at 1 16 24 PM
  • Supply
    Screen Shot 2022-09-23 at 1 16 43 PM

This means we can (and should) only aim to

  • Ensure commodity output (BAS) are equal between Use (BAS) and Supply (BAS)
  • Calculate industry output (BAS) from Supply (BAS) instead of Use (BAS)

@WesIngwersen

@bl-young bl-young changed the base branch from master to develop October 26, 2022 19:28
@MoLi7
Copy link
Collaborator Author
MoLi7 commented Oct 26, 2022

@WesIngwersen @bl-young @jvendries I made a small change in 1139aae according to my earlier comment and am able to build a USEEIOv2.0.2-411 model all the way to loadDemandVectors. Could you remind me of remaining tasks in this PR if there is any?

@bl-young
Copy link
Collaborator

The two things I remember talking about was a matrix like phi or rho to be able to convert from Basic to Producer price. And also a wrapper function of some kind to produce just the economic portions of the model to avoid failures.

We may also want to confirm that BAS models can be written to excel

@bl-young
Copy link
Collaborator
bl-young commented Oct 26, 2022

@MoLi7 this commit a5a27c6 already in develop may make writing BAS models to excel easier so may want to update from develop to check on that

@bl-young bl-young self-assigned this Jul 13, 2023
@bl-young bl-young marked this pull request as draft July 13, 2023 16:54
@bl-young bl-young marked this pull request as ready for review July 13, 2023 16:54
@bl-young
Copy link
Collaborator

I am finding that we can not build a complete economic model in BAS as there are errors in generating the L matrix.
I can't recall if the goal here was to be able to build a complete model or not, or just to access the SUT and create Tau.
@WesIngwersen @MoLi7

@bl-young bl-young added this to the v1.3 milestone Jul 14, 2023
@jvendries
Copy link
Collaborator

I am finding that we can not build a complete economic model in BAS as there are errors in generating the L matrix. I can't recall if the goal here was to be able to build a complete model or not, or just to access the SUT and create Tau. @WesIngwersen @MoLi7

I also tried building the BAS model and was unable to due to an error when calculating the L matrix. After further inspection, I was able to trace back the error to the model$UseTransactions table, specifically in the 4200ID/US industry column. In the BAS model, there are some values in this column of the table that are not present in (for example) the analogous producer price model. Additionally, the model$Industries vector has a value of 0 for that same sector, which is replaced by a value of 0.001. As a result, the normalized U_n model object has values that are much greater than 1. These values then propagate to the A and L matrix calculations, causing the error.

As a reference, the attached image displays the values for several rows in the 4200ID/US column in the model$UseTransactions and U_n model objects during a BAS model build before the error terminates the run.

Given the above, do we want to proceed with the merge, or should we hold off until we have a better grasp of why these values are been introduced in this column?

image

@bl-young bl-young merged commit 30f572c into develop Jul 19, 2023
@bl-young bl-young deleted the SUT branch July 19, 2023 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0