Sets and Parameters
WiNDCNational is built using WiNDCContainer
, which provides a flexible way to define and manage sets and parameters within the data model. We will provide a listing of the sets used and demonstrate how to access and view them in code.
The sets and parameters are the same for both the summary
and detailed
tables. For this reason we will use the summary
table as the basis for our examples.
using WiNDCNational
using DataFrames
summary = build_us_table(:summary);
Sets
To view all the sets, use the sets
function:
sets(summary) |> x-> sort(x, [:domain, :name])
Row | name | description | domain |
---|---|---|---|
Symbol | String | Symbol | |
1 | duty | Duty | col |
2 | export | Exports | col |
3 | government_final_demand | Government portions of final demand | col |
4 | import | Imports | col |
5 | investment_final_demand | Investment portions of final demand | col |
6 | margin | Margin sectors | col |
7 | personal_consumption | Personal consumption expenditures | col |
8 | sector | Sectors | col |
9 | subsidy | Subsidy | col |
10 | tax | Tax | col |
11 | trade | Trade | col |
12 | transport | Transport | col |
13 | Capital_Demand | parameter | |
14 | Duty | parameter | |
15 | Export | parameter | |
16 | Final_Demand | Final demand | parameter |
17 | Government_Final_Demand | parameter | |
18 | Household_Supply | Positive values in PCE (negative in USE table) | parameter |
19 | Import | parameter | |
20 | Intermediate_Demand | parameter | |
21 | Intermediate_Supply | parameter | |
22 | Investment_Final_Demand | parameter | |
23 | Labor_Demand | parameter | |
24 | Margin_Demand | Positive values in marginal categories | parameter |
25 | Margin_Supply | Negative values in marginal categories | parameter |
26 | Other_Final_Demand | Non-export components of final demand | parameter |
27 | Output_Tax | parameter | |
28 | Personal_Consumption | Negative values in PCE (positive in USE table) | parameter |
29 | Sector_Subsidy | parameter | |
30 | Subsidy | parameter | |
31 | Supply | Supply (or output) sections of the IO table | parameter |
32 | Tax | parameter | |
33 | Use | Use (or input) sections of the IO table | parameter |
34 | Value_Added | Value added | parameter |
35 | capital_demand | Gross operating surplus | row |
36 | commodity | Commodities | row |
37 | labor_demand | Compensation of employees | row |
38 | output_tax | Output tax | row |
39 | sector_subsidy | Sector subsidy | row |
40 | year | year |
The |> x -> sort(x, :[:domain, :name])
sorts the sets by their domain, or the column in the data table where the set elements are located, and their name.
By convention we use snake_case
for sets that do not have the parameter
domain.
Let's consider the set margin
with domain col
. I would like to view the elements:
elements(summary, :margin)
Row | name | description | set |
---|---|---|---|
Any | Any | Symbol | |
1 | Trade | Trade margins | margin |
2 | Trans | Transport margins | margin |
The values in the name
column are the elements of the set, they are NAICS codes as they appear in the BEA input/output tables. To examine the actual data use:
table(summary, :margin) |> x -> first(x, 5)
Row | row | col | year | parameter | value |
---|---|---|---|---|---|
Any | Symbol? | Int64 | Symbol | Float64 | |
1 | 111CA | Trans | 1998 | margin_demand | 20.257 |
2 | 113FF | Trans | 1998 | margin_demand | 2.421 |
3 | 211 | Trans | 1998 | margin_demand | 22.533 |
4 | 212 | Trans | 1998 | margin_demand | 14.247 |
5 | 321 | Trans | 1998 | margin_demand | 4.592 |
This will show the first 5 rows of the data table restricted to the margin
set. Recall margin
had domain col
and that is the column where the elements live. To demonstrate the multiple values in col
, just view the unique values:
table(summary, :margin) |> x -> unique(x, :col)
Row | row | col | year | parameter | value |
---|---|---|---|---|---|
Any | Symbol? | Int64 | Symbol | Float64 | |
1 | 111CA | Trans | 1998 | margin_demand | 20.257 |
2 | 111CA | Trade | 1998 | margin_demand | 45.523 |
Because we are only viewing the first few rows, we only see the Trans
code. We can further filter the data by specifying a particular element:
table(summary, :margin => :Trade) |> x -> first(x, 5)
Row | row | col | year | parameter | value |
---|---|---|---|---|---|
Any | Symbol? | Int64 | Symbol | Float64 | |
1 | 111CA | Trade | 1998 | margin_demand | 45.523 |
2 | 113FF | Trade | 1998 | margin_demand | 5.41 |
3 | 211 | Trade | 1998 | margin_demand | 3.609 |
4 | 212 | Trade | 1998 | margin_demand | 2.508 |
5 | 321 | Trade | 1998 | margin_demand | 17.94 |
Again, we can extract the unique values:
table(summary, :margin => :Trade) |> x -> unique(x, :col)
Row | row | col | year | parameter | value |
---|---|---|---|---|---|
Any | Symbol? | Int64 | Symbol | Float64 | |
1 | 111CA | Trade | 1998 | margin_demand | 45.523 |
Parameters
Parameters are just sets with domain :parameter
.
sets(summary) |> x-> subset(x, :domain => ByRow(==(:parameter)))
Row | name | description | domain |
---|---|---|---|
Symbol | String | Symbol | |
1 | Export | parameter | |
2 | Subsidy | parameter | |
3 | Labor_Demand | parameter | |
4 | Capital_Demand | parameter | |
5 | Investment_Final_Demand | parameter | |
6 | Import | parameter | |
7 | Sector_Subsidy | parameter | |
8 | Government_Final_Demand | parameter | |
9 | Duty | parameter | |
10 | Intermediate_Demand | parameter | |
11 | Intermediate_Supply | parameter | |
12 | Tax | parameter | |
13 | Output_Tax | parameter | |
14 | Value_Added | Value added | parameter |
15 | Final_Demand | Final demand | parameter |
16 | Other_Final_Demand | Non-export components of final demand | parameter |
17 | Use | Use (or input) sections of the IO table | parameter |
18 | Supply | Supply (or output) sections of the IO table | parameter |
19 | Margin_Demand | Positive values in marginal categories | parameter |
20 | Margin_Supply | Negative values in marginal categories | parameter |
21 | Household_Supply | Positive values in PCE (negative in USE table) | parameter |
22 | Personal_Consumption | Negative values in PCE (positive in USE table) | parameter |
By convention, parameter names are capital-version of snake_case
. Sets are required to have distinct names and this avoid conflicts.
Extracting parameters is identical to extracting sets.
table(summary, :Intermediate_Demand) |> x -> first(x, 5)
Row | row | col | year | parameter | value |
---|---|---|---|---|---|
Any | Symbol? | Int64 | Symbol | Float64 | |
1 | 111CA | 111CA | 1998 | intermediate_demand | -33.87 |
2 | 113FF | 111CA | 1998 | intermediate_demand | -12.047 |
3 | 212 | 111CA | 1998 | intermediate_demand | -1.67 |
4 | 22 | 111CA | 1998 | intermediate_demand | -3.378 |
5 | 23 | 111CA | 1998 | intermediate_demand | -0.796 |
We can extract multiple parameters:
table(summary, :Intermediate_Demand, :Intermediate_Supply) |> x -> first(x, 5)
Row | row | col | year | parameter | value |
---|---|---|---|---|---|
Any | Symbol? | Int64 | Symbol | Float64 | |
1 | 111CA | 111CA | 1998 | intermediate_demand | -33.87 |
2 | 113FF | 111CA | 1998 | intermediate_demand | -12.047 |
3 | 212 | 111CA | 1998 | intermediate_demand | -1.67 |
4 | 22 | 111CA | 1998 | intermediate_demand | -3.378 |
5 | 23 | 111CA | 1998 | intermediate_demand | -0.796 |
Some parameters are composites of multiple parameters:
elements(summary, :Value_Added)
Row | name | description | set |
---|---|---|---|
Any | Any | Symbol | |
1 | labor_demand | Value added | Value_Added |
2 | capital_demand | Value added | Value_Added |
Composite Parameters
Some parameters are require aggregations and can't be extracted directly. Here is a full list of these parameters:
zero_profit
market_clearance
margin_balance
gross_output
armington_supply
output_tax
sectoral_output
output_tax_rate
absorption_tax
absorption_tax_rate
import_tariff_rate
balance_of_payments
This page was generated using Literate.jl.