Build Supply Use Tables#17
Merged
Merged
Conversation
eduaguilera
reviewed
Jun 30, 2025
eduaguilera
reviewed
Jun 30, 2025
eduaguilera
reviewed
Jun 30, 2025
eduaguilera
reviewed
Jun 30, 2025
eduaguilera
reviewed
Jun 30, 2025
eduaguilera
left a comment
Owner
There was a problem hiding this comment.
Very nice contribution. Overall, the only thing I miss is a guideline explaining the genral purpose of all scripts and inputs and outputs, and in what order to run them (or maybe I missed that?)
Collaborator
Author
I would expect more general functions will be created later on when we have all the steps implemented. That being said, for a more detailed explanation I would create an R Markdown article. |
eduaguilera
approved these changes
Jul 1, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It was tough to put everything together, and this part of the model must surely be revisited later for improvements.
For now I tried to group processes into three groups, each one with its logic as to where to get the data from. Some indirect things I also did:
_codeand_namecolumns)add_item_cbs_name,add_area_name,add_item_prod_nameand their counterparts)get_feed_intake,get_primary_production,get_primary_residues). They can be used by anyone who needs to work with those data.Lastly, I paste here an explanation that I initially wrote in an external task for all the steps followed for building the supply and use tables:
The final goal is to get an input-output matrix (concept from economy https://en.wikipedia.org/wiki/Input%E2%80%93output_model, a.k.a. technical coefficient matrix) for the commodity balance sheet items.
Why do we need the previous Supply-Use Table (SUT) format? In fact we don't, but once we have it, implementing item allocation to get technical coefficients is easier.
Why do we need to define processes? This can also be quite arbitrary. The concept of multi-output process is important because we have to allocate (share) its inputs through each of the outputs. NOTE: If we define in the same process two seemingly unrelated outputs we could get bad results when allocating, but we have to deal with it (see processing items below).
The process name is not that important, since we will be losing it anyway when converting to the input-output square matrix. We will generate process 'names' on the fly.
We will identify a process by a pair (proc_group, proc_cbs_code), where proc_cbs_code is the main item considered in the process (if that makes sense, see cases below) and proc_group is (for now) one of three values, which describe the kind of process (related to how its data will be calculated). These are:
Since we will try to generate some process groupings automatically, we won't really need the process correspondence tables we were trying to fill (items_supply.csv, items_use.csv). We might have to use a similar one for the crop production processes since there are some multioutput crops to treat separately.
This should cover most of the relations between items. There might be others that don't fit in here and we should figure that out later on. I also accept feedback.