Skip to content
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

Rethinking data for IO Chart - current multi-commodity interface #70

Open
WesIngwersen opened this issue Sep 11, 2021 · 6 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@WesIngwersen
Copy link
Collaborator

WesIngwersen commented Sep 11, 2021

Following on a discussion between @WesIngwersen @msrocka @TheTisiboth @LorenHeyns, this issue is for discussion of the IO chart reflecting the current 3-column, multiple-commodity interface

Using this implementation as an example for discussion
image

@WesIngwersen WesIngwersen added the enhancement New feature or request label Sep 11, 2021
@WesIngwersen WesIngwersen self-assigned this Sep 11, 2021
@WesIngwersen
Copy link
Collaborator Author

WesIngwersen commented Sep 11, 2021

I recommend the following:

  1. Do not use per $, instead provide a regional estimate of commodity output, q_c (more on this estimate in another post). This will be much more interesting and useful to the community.

  2. Show direct dollar amounts and direct impacts. This will obviate the complexities of the indirect impact calculations in this chart.
    2.1. Upstream - will show total dollar amount of direct inputs for all combined Commodities. q_c*A
    2.2 . Commodities - Do not select only the top 20 by default. Subselect indicators were direct impacts are relevant...this will exclude energy use and mineral use for instance. The All impacts can be estimated through scaling of the D matrix. q_c*D
    2.3 Downstream - will show total dollar amount of direct uses for all combined Commodities. A*q_c

@WesIngwersen
Copy link
Collaborator Author

WesIngwersen commented Sep 11, 2021

To estimate commodity output for the total, we need to first estimate industry output, then apply the market shares transformation. The new API version (v1.2) and with model v2.0 will be needed in order to get the data that we need for this.

We use a proxy measure of industry output, such as industry wages, w in the following manner:

x_i,c = w_i,c/w_i,t * x_i,t

where x_c,i is industry output for industry i for the community c, w_c is a community wages for industry i, w_i,t is a wages for industry i in the IO model region (US for USEEIOv2.0), and x is the model's provided industry output for industry i. This is a single industry formula but the calculation would be best implemented in a vector form using matrix multiplication to do all at once.

In order to get the index of the wages vectors to match the IO model industries, we will have to map the NAICS based wages data into model sectors using the provided API sectorcrosswalk.csv where we assume the wages sector match those in the NAICS column and we aggregate it to model industries using the provided model industries column.

Once you have a vector x_c of industry output for the community indexed by the model industries, you can use a market shares transformation to derive commodity output for the community, q_c.

q_c = x_c * V\hat{q}^{-1}

where V is the Make table and q is the commodity output vector. More details on V_n found in the useeior model format spec

@ModelEarth
Copy link
Contributor

ModelEarth commented Sep 11, 2021

I've placed the text above at the bottom of the instructional page:

Teachers and Students > Learn about Matrix Algebra
https://model.earth/io/about/matrix/#regional

During work on the new Regional Estimate of Commodity Output display, I would suggest copying and renaming the existing IO Chart code in case we need to tweak the older version for the Oct 2nd web challenge.

The regional filters could use the 2-character "state" values and 7-character "geo" hash values.
The geo values start with the 2-character country code (US).

Fulton and DeKalb counties are:
/#geo=US13121,US13089

Multiple states can be conveyed as:
/#state=GA,FL

I've been using Tabulator to display datasets for a new version of the naics list:
https://model.earth/localsite/info/naics/

We should probably use the term "Payroll" rather than "Wages" to match the labor statistics reporting.

@msrocka
Copy link
Collaborator

msrocka commented Sep 27, 2021

Maybe my understanding of what q_c is is wrong but for me it should be:

  • upstream: A * q_c
  • impacts: D * q_c
  • downstream: q_c' * A (where ' means transpose)

Or not? Here is an example:

q_c is the total commodity output of a community/region, right? It is a column vector that contains the $ amounts of the respective commodity outputs?, e.g.:

q_c = [ 5e6 ; # $ of commodity 1
        3e6 ; # $ of commodity 2
        4e6 ] # $ of commodity 3

A is the commodity * commodity direct requirements matrix with each column j containing the direct requirements to produce 1 $ of j, e.g.:

    # com1  com2  com3  
A = [ 0.15  0.30  0.44 ;  # commodity 1
      0.50  0.11  0.22 ;  # commodity 2
      0.17  0.35  0.20 ]  # commodity 3

To calculate the direct upstreams, you would scale each column A[:,j] with q_c[j] and sum them up, wouldn't you? So

A[:,1]*q_c[1] + A[:,2]*q_c[2] + A[:,3]*q_c[3]

and this is

A * q_c

# = 
#  3.41e6
#  3.71e6
#  2.7e6

For D the same: it contains in each column j the direct impacts related to the production of 1 $ of j, e.g.:

    # com1 com2 com3 
D = [ 2.5  3.0  4.2 ;  # impact 1 per 1 $ 
      1.2  0.7  1.8 ]  # impact 2 per 1 $ 

So, the related impacts would be calculated as:

D * q_c

# = 
#  3.83e7
#  1.53e7

Finally, for the downstream $ flows you would sum up the scaled rows of A[i,:] as these describe where a commodity i is used, right? So

A[1,:]*q_c[1] + A[2,:]*q_c[2] + A[3,:]*q_c[3]

and this is:

q_c' * A

# = 2.93e6  3.23e6  3.66e6

@WesIngwersen
Copy link
Collaborator Author

Thank you @msrocka. I agree with your corrected formulas. I demonstrated this using the model object directly from useeior from a summary level USEEIO model CalculateUpstreamandDownstreamCommodities

@ModelEarth
Copy link
Contributor

Here are samples of displaying Total Amounts that Michael (msrocka) and Leo set up:
https://model.earth/localsite/info/data/totals/

To Do:

Default to Total Amounts on the Inflow-Outflow Chart using the process Wes and Michael posted above.

Displayed Per Dollar when the hash value changes from vtype=total to vtype=perdollar and vtype=both. Demo using links containing these hash values on the sample page. Call the vtype=both link "Total and Per Dollar"
https://model.earth/io/build/iochart.html#sectors=333613,335912,336111

Avoid reloading the data when the vtype hash value changes.
Pre-calculate Per Dollar so the display change is instant.
If it speeds up the initial display, pre-calculate Per Dollar immediately after the initial Total Amount is displayed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants